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