@Test public void shouldCreateAConceptSource() throws Exception { long originalCount = getAllCount(); SimpleObject conceptSource = new SimpleObject(); conceptSource.add("name", "test name"); conceptSource.add("description", "test description"); String json = new ObjectMapper().writeValueAsString(conceptSource); MockHttpServletRequest req = request(RequestMethod.POST, getURI()); req.setContent(json.getBytes()); SimpleObject newConceptSource = deserialize(handle(req)); Assert.assertNotNull(PropertyUtils.getProperty(newConceptSource, "uuid")); Assert.assertEquals(originalCount + 1, getAllCount()); }
@Test public void shouldEditAConceptSource() throws Exception { final String newName = "updated name"; SimpleObject conceptSource = new SimpleObject(); conceptSource.add("name", newName); String json = new ObjectMapper().writeValueAsString(conceptSource); MockHttpServletRequest req = request(RequestMethod.POST, getURI() + "/" + getUuid()); req.setContent(json.getBytes()); handle(req); Assert.assertEquals(newName, service.getConceptSourceByUuid(getUuid()).getName()); }