예제 #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);
  }
예제 #2
0
 @Test
 public void testCreateRecordAttributeAsChild() {
   response =
       recordEndpoint.createRecord(
           AUTH_TOKEN, AUTH_TOKEN, PLACE, jsonToCreateFromAttributeAsChild);
   assertResponseStatusIs(Response.Status.BAD_REQUEST);
 }
예제 #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);
  }
예제 #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);
  }
예제 #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);
  }
예제 #6
0
 @Test
 public void testCreateRecordAbstractRecordType() {
   String type = "abstract";
   response = recordEndpoint.createRecord(AUTH_TOKEN, AUTH_TOKEN, type, jsonToCreateFrom);
   assertResponseStatusIs(Response.Status.METHOD_NOT_ALLOWED);
 }
예제 #7
0
 @Test
 public void testCreateRecordBadContentInJson() {
   response = recordEndpoint.createRecord(AUTH_TOKEN, AUTH_TOKEN, PLACE, jsonWithBadContent);
   assertResponseStatusIs(Response.Status.BAD_REQUEST);
 }
예제 #8
0
 @Test
 public void testCreateRecordBadCreatedLocation() {
   String type = "place&& &&\\\\";
   response = recordEndpoint.createRecord(AUTH_TOKEN, AUTH_TOKEN, type, jsonToCreateFrom);
   assertResponseStatusIs(Response.Status.BAD_REQUEST);
 }
예제 #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));
 }