@BeforeMethod public void beforeMethod() { SpiderInstanceFactory factory = SpiderInstanceFactoryImp.usingDependencyProvider(new DependencyProviderForTest()); SpiderInstanceProvider.setSpiderInstanceFactory(factory); UriInfo uriInfo = new TestUri(); recordEndpoint = new RecordEndpoint(uriInfo); }
@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); }
private void setNotAuthorized() { SpiderInstanceFactory factory = SpiderInstanceFactoryImp.usingDependencyProvider( new DependencyProviderForTestNotAuthorized()); SpiderInstanceProvider.setSpiderInstanceFactory(factory); }