ViewServiceMemory extends ViewService { @Override public long addView(View view) { view.setUuid(UUID.randomUUID().toString()); int seq = list.size(); list.add(view); view.setId(seq); return seq; }  View find(int id); View find(String id); List<Object> findAll(); void delete(int id); void delete(Map<String, String> parameterMap); void update(Object layerClass); int insert(Object layerClass); @Override boolean hasPermissionToAlterView(View view, User user); @Override List<View> getViews(int page, int pagesize); @Override View getViewWithConf(long viewId); @Override View getViewWithConfByUuId(String uuId); @Override View getViewWithConfByOldId(long oldId); @Override View getViewWithConf(String viewName); @Override List<View> getViewsForUser(long userId); @Override long addView(View view); @Override void updateAccessFlag(View view); @Override void updateView(View view); @Override void deleteViewById(long id); @Override void deleteViewByUserId(long id); @Override void updateViewUsage(View view); @Override long getDefaultViewId(); @Override long getDefaultViewIdForRole(String roleName); @Override long getDefaultViewId(User user); @Override void resetUsersDefaultViews(long userId); @Override boolean isSystemDefaultView(long id); @Override long getSystemDefaultViewId(Collection<Role> roles); @Override List<Long> getSystemDefaultViewIds(); @Override void updatePublishedView(View view); @Override void updateBundleSettingsForView(long viewId, Bundle bundle);  }
@Test public void testAddView() throws ViewException { List<Object> all = viewService.findAll(); assertNotNull(all); assertEquals(0, all.size()); View view = new View(); view.setName("bazqux"); view.setType("RANDOM"); assertEquals(-1L, view.getId()); assertNull(view.getUuid()); viewService.addView(view); assertEquals(0L, view.getId()); assertNotNull(view.getUuid()); assertEquals(36, view.getUuid().length()); all = viewService.findAll(); assertNotNull(all); assertEquals(1, all.size()); Object obj = all.get(0); if (!(obj instanceof View)) { fail("Expected obj to be instanceof View"); return; } assertTrue(view == obj); }