Esempio n. 1
0
  @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);
  }
Esempio n. 2
0
 @Test
 public void testCreateRecordAttributeAsChild() {
   response =
       recordEndpoint.createRecord(
           AUTH_TOKEN, AUTH_TOKEN, PLACE, jsonToCreateFromAttributeAsChild);
   assertResponseStatusIs(Response.Status.BAD_REQUEST);
 }
Esempio n. 3
0
  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);
  }
Esempio n. 4
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. 5
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. 6
0
 @Test
 public void testCreateRecordAbstractRecordType() {
   String type = "abstract";
   response = recordEndpoint.createRecord(AUTH_TOKEN, AUTH_TOKEN, type, jsonToCreateFrom);
   assertResponseStatusIs(Response.Status.METHOD_NOT_ALLOWED);
 }
Esempio n. 7
0
 @Test
 public void testCreateRecordBadContentInJson() {
   response = recordEndpoint.createRecord(AUTH_TOKEN, AUTH_TOKEN, PLACE, jsonWithBadContent);
   assertResponseStatusIs(Response.Status.BAD_REQUEST);
 }
Esempio n. 8
0
 @Test
 public void testCreateRecordBadCreatedLocation() {
   String type = "place&& &&\\\\";
   response = recordEndpoint.createRecord(AUTH_TOKEN, AUTH_TOKEN, type, jsonToCreateFrom);
   assertResponseStatusIs(Response.Status.BAD_REQUEST);
 }
Esempio n. 9
0
 @Test
 public void testCreateRecord() {
   response = recordEndpoint.createRecord(AUTH_TOKEN, AUTH_TOKEN, PLACE, jsonToCreateFrom);
   assertResponseStatusIs(Response.Status.CREATED);
   assertTrue(response.getLocation().toString().startsWith("record/" + PLACE));
 }