@Test public void testCreateRecordDuplicateUserSuppliedId() { response = recordEndpoint.createRecord(AUTH_TOKEN, AUTH_TOKEN, PLACE, duplicateTestJson); assertResponseStatusIs(Response.Status.CREATED); response = recordEndpoint.createRecord(AUTH_TOKEN, AUTH_TOKEN, PLACE, duplicateTestJson); assertResponseStatusIs(Response.Status.CONFLICT); }
@Test public void testCreateRecordAttributeAsChild() { response = recordEndpoint.createRecord( AUTH_TOKEN, AUTH_TOKEN, PLACE, jsonToCreateFromAttributeAsChild); assertResponseStatusIs(Response.Status.BAD_REQUEST); }
private void expectTokenForCreateToPrefereblyBeHeaderThanQuery( String headerAuthToken, String queryAuthToken, String authTokenExpected) { SpiderInstanceFactorySpy factorySpy = setupInstanceProviderWithFactorySpy(); response = recordEndpoint.createRecord(headerAuthToken, queryAuthToken, PLACE, jsonToCreateFrom); SpiderCreatorSpy spiderCreatorSpy = factorySpy.spiderCreatorSpy; assertEquals(spiderCreatorSpy.authToken, authTokenExpected); }
@Test public void testCreateRecordUnexpectedError() { DependencyProviderForTest spiderDependencyProvider = new DependencyProviderForTest(); spiderDependencyProvider.setDataValidator(new DataValidatorReturnNullPointer()); SpiderInstanceFactory factory = SpiderInstanceFactoryImp.usingDependencyProvider(spiderDependencyProvider); SpiderInstanceProvider.setSpiderInstanceFactory(factory); response = recordEndpoint.createRecord(AUTH_TOKEN, AUTH_TOKEN, PLACE, jsonToCreateFrom); assertResponseStatusIs(Response.Status.INTERNAL_SERVER_ERROR); }
@Test public void testCreateRecordNotValid() { // uses always invalid validator DependencyProviderForTest spiderDependencyProvider = new DependencyProviderForTest(); spiderDependencyProvider.setDataValidator(new DataValidatorAlwaysInvalidSpy()); SpiderInstanceFactory factory = SpiderInstanceFactoryImp.usingDependencyProvider(spiderDependencyProvider); SpiderInstanceProvider.setSpiderInstanceFactory(factory); response = recordEndpoint.createRecord(AUTH_TOKEN, AUTH_TOKEN, PLACE, jsonToCreateFrom); assertResponseStatusIs(Response.Status.BAD_REQUEST); }
@Test public void testCreateRecordAbstractRecordType() { String type = "abstract"; response = recordEndpoint.createRecord(AUTH_TOKEN, AUTH_TOKEN, type, jsonToCreateFrom); assertResponseStatusIs(Response.Status.METHOD_NOT_ALLOWED); }
@Test public void testCreateRecordBadContentInJson() { response = recordEndpoint.createRecord(AUTH_TOKEN, AUTH_TOKEN, PLACE, jsonWithBadContent); assertResponseStatusIs(Response.Status.BAD_REQUEST); }
@Test public void testCreateRecordBadCreatedLocation() { String type = "place&& &&\\\\"; response = recordEndpoint.createRecord(AUTH_TOKEN, AUTH_TOKEN, type, jsonToCreateFrom); assertResponseStatusIs(Response.Status.BAD_REQUEST); }
@Test public void testCreateRecord() { response = recordEndpoint.createRecord(AUTH_TOKEN, AUTH_TOKEN, PLACE, jsonToCreateFrom); assertResponseStatusIs(Response.Status.CREATED); assertTrue(response.getLocation().toString().startsWith("record/" + PLACE)); }