@Test /* code */ public void givenResourceDoesNotExist_whenResourceIsUpdated_then404IsReceived() { // Given final T unpersistedEntity = createNewResource(); unpersistedEntity.setId(IDUtil.randomPositiveLong()); // When final Response response = getApi().updateAsResponse(unpersistedEntity); // Then assertThat(response.getStatusCode(), is(404)); }
@Test @Ignore( "this was written for a neo4j persistence engine, which treats null ids differently than Hibernate") /* code */ public void whenResourceIsRetrievedByNegativeId_then409IsReceived() { final Long id = IDUtil.randomNegativeLong(); // When final Response res = getApi().findOneByUriAsResponse(getUri() + WebConstants.PATH_SEP + id, null); // Then assertThat(res.getStatusCode(), is(409)); }
@Override @Test public final void givenResourceWithNameAndIdExists_whenResourceIsSearchedByIncorrectIdAndIncorrectName_thenResourceIsNotFound() { final T existingResource = getApi().create(createNewResource()); // When final List<T> found = getApi() .searchAll( ClientConstraintsUtil.createIdConstraint(EQ, IDUtil.randomPositiveLong()), ClientConstraintsUtil.createNameConstraint(EQ, randomAlphabetic(8))); // Then assertThat(found, not(hasItem(existingResource))); }