@Test public void addSetMembers() throws Exception { ConceptSetRow conceptRow = new ConceptSetRow(); conceptRow.name = "New concept"; conceptRow.conceptClass = "New Class"; conceptRow.description = "some description"; List<KeyValue> children = new ArrayList<>(); children.add(new KeyValue("1", "Child1")); children.add(new KeyValue("2", "Child2")); conceptRow.children = children; Messages persistErrorMessages = conceptSetPersister.persist(conceptRow); assertTrue(persistErrorMessages.isEmpty()); Context.openSession(); Context.authenticate("admin", "test"); Concept persistedConcept = conceptService.getConceptByName(conceptRow.name); assertNotNull(persistedConcept); assertEquals(conceptRow.name, persistedConcept.getName(Context.getLocale()).getName()); assertEquals(conceptRow.conceptClass, persistedConcept.getConceptClass().getName()); assertEquals("some description", persistedConcept.getDescription().getDescription()); assertEquals(2, persistedConcept.getSetMembers().size()); assertEquals("some description", persistedConcept.getDescription().getDescription()); assertEquals(0, persistedConcept.getSynonyms().size()); assertTrue(persistedConcept.isSet()); Context.flushSession(); Context.closeSession(); }
@Test public void shouldPersistNewConceptSetWithNameClassDescriptionInputOnly() throws Exception { ConceptSetRow conceptRow = new ConceptSetRow(); conceptRow.name = "New concept"; conceptRow.conceptClass = "New Class"; conceptRow.description = "some description"; Messages persistErrorMessages = conceptSetPersister.persist(conceptRow); assertTrue(persistErrorMessages.isEmpty()); Context.openSession(); Context.authenticate("admin", "test"); Concept persistedConcept = conceptService.getConceptByName(conceptRow.name); assertNotNull(persistedConcept); assertEquals(conceptRow.name, persistedConcept.getName(Context.getLocale()).getName()); assertEquals(conceptRow.conceptClass, persistedConcept.getConceptClass().getName()); assertEquals("some description", persistedConcept.getDescription().getDescription()); assertEquals(0, persistedConcept.getSynonyms().size()); assertTrue(persistedConcept.isSet()); Context.flushSession(); Context.closeSession(); }