@Test public void testcreate() throws IOException { String name = "crud controller create"; assertFalse(findByName(name).isPresent()); MvcResult result = performAuthenticatedRequestAndReturn( getAuthentication(), post(getEndPoint()) .contentType(MediaType.APPLICATION_JSON) .content( JsonUtils.JSON_MAPPER.writeValueAsString( createEntity(name)))) // createJson(name) ; assertTrue(findByName(name).isPresent()); }
@Test public void testupdate() throws IOException { String name = "crud controller update"; assertFalse(findByName(name).isPresent()); T entity = createEntity(name); getService().create(entity); assertNotNull(entity.getId()); assertTrue(getService().getById(entity.getId()).isPresent()); name = name + "d"; updateEntity(entity, name); MvcResult result = performAuthenticatedRequestAndReturn( getAuthentication(), put(getEndPoint() + "/" + entity.getId()) .contentType(MediaType.APPLICATION_JSON) .content(JsonUtils.JSON_MAPPER.writeValueAsString(createEntity(name)))); assertTrue(findByName(name).isPresent()); }