LOVManagerBean implements ILOVManagerLocal { @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override public void createLov(String workspaceId, String name, List<NameValuePair> nameValuePairList) throws UserNotFoundException, UserNotActiveException, WorkspaceNotFoundException, AccessRightException, ListOfValuesAlreadyExistsException, CreationException, WorkspaceNotEnabledException { userManager.checkWorkspaceWriteAccess(workspaceId); if (name == null || name.trim().isEmpty()) { throw new CreationException("LOVNameEmptyException"); } if (nameValuePairList == null || nameValuePairList.isEmpty()) { throw new CreationException("LOVPossibleValueException"); } Workspace workspace = workspaceDAO.loadWorkspace(workspaceId); ListOfValues lov = new ListOfValues(workspace, name); lov.setValues(nameValuePairList); lovDAO.createLOV(lov); }  @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override List<ListOfValues> findLOVFromWorkspace(String workspaceId); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override ListOfValues findLov(ListOfValuesKey lovKey); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override void createLov(String workspaceId, String name, List<NameValuePair> nameValuePairList); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override void deleteLov(ListOfValuesKey lovKey); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override ListOfValues updateLov(ListOfValuesKey lovKey, String name, String workspaceId, List<NameValuePair> nameValuePairList); @RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID) @Override boolean isLOVDeletable(ListOfValuesKey lovKey);  }
@Test public void creationNominal() throws Exception { Mockito.when(userManager.checkWorkspaceWriteAccess(workspace.getId())).thenReturn(user); Mockito.when(userManager.checkWorkspaceReadAccess(workspace.getId())).thenReturn(user); Mockito.when(workspaceDAO.loadWorkspace(workspace.getId())).thenReturn(workspace); List<NameValuePair> possibleValue = new ArrayList<>(); possibleValue.add(new NameValuePair("first", "value")); lovManager.createLov(workspace.getId(), "NominalName", possibleValue); }
@Test (expected = CreationException.class) public void creationNoName() throws Exception { Mockito.when(userManager.checkWorkspaceWriteAccess(workspace.getId())).thenReturn(user); Mockito.when(userManager.checkWorkspaceReadAccess(workspace.getId())).thenReturn(user); List<NameValuePair> possibleValue = new ArrayList<>(); possibleValue.add(new NameValuePair("first", "value")); lovManager.createLov(workspace.getId(), null, possibleValue); }
@Test (expected = CreationException.class) public void creationNoPossibleValue() throws Exception { Mockito.when(userManager.checkWorkspaceWriteAccess(workspace.getId())).thenReturn(user); Mockito.when(userManager.checkWorkspaceReadAccess(workspace.getId())).thenReturn(user); lovManager.createLov(workspace.getId(), "Name", null); }