@Test public void testForNonUniqueCodeListNotExisting() { String name = "TestCodeList"; String catId = "1"; String codeSystemId = "2"; String steward = "TestSteward"; String stewardOther = null; String oid = "3"; ManageCodeListDetailModel model1 = new ManageCodeListDetailModel(); model1.setName(name); model1.setCategory(catId); model1.setCodeSystem(codeSystemId); model1.setSteward(steward); model1.setStewardOther(stewardOther); model1.setOid(oid); // // editing a code list so that it matches a different existing code list // ManageCodeListDetailModel model = new ManageCodeListDetailModel(); model.setName(name); model.setCategory(catId); model.setSteward(steward); model.setCodeSystem(codeSystemId); CodeList existingCl = new CodeList(); String id = "id"; model.setExistingCodeList(false); existingCl.setId(id); EasyMock.expect(codeListDAO.getCodeList(model1, LoggedInUserUtil.getLoggedInUser())) .andReturn(existingCl); EasyMock.replay(codeListDAO); assertFalse(codeListService.isCodeListUnique(model)); }
@Test public void testForNonUniqueGroupedCodeListExistingMatch() throws Exception { String name = "TestCodeList"; String catId = "1"; String steward = "TestSteward"; // // editing a code list so that it matches a different existing code list // ManageCodeListDetailModel model = new ManageCodeListDetailModel(); model.setName(name); model.setCategory(catId); model.setSteward(steward); ListObject codeList = new ListObject(); ListObject existingCl = new ListObject(); String id = "id"; model.setID(id); model.setExistingCodeList(true); existingCl.setId(id); EasyMock.expect(listObjectDAO.find(id)).andReturn(codeList); EasyMock.expect( listObjectDAO.getListObject(name, steward, catId, LoggedInUserUtil.getLoggedInUser())) .andReturn(existingCl); EasyMock.replay(listObjectDAO); assertTrue(codeListService.isGroupedCodeListUnique(model)); }