Ejemplo n.º 1
0
  @Test(dataProvider = "annotatedRequestHandlerData")
  public void testPatchCollectionItemAnnotatedRequestHandler(
      Class<?> requestHandler,
      boolean collection,
      boolean create,
      boolean read,
      boolean update,
      boolean delete,
      boolean patch,
      boolean resourceAction,
      boolean collectionAction,
      boolean query)
      throws Exception {

    // Given
    Object provider = requestHandler.newInstance();
    Connection connection = Resources.newInternalConnection(createHandler(collection, provider));
    PatchRequest req = Requests.newPatchRequest("/test/fred");

    // When
    Promise<Resource, ResourceException> promise = connection.patchAsync(new RootContext(), req);

    // Then
    if (patch && collection) {
      assertThat(promise).succeeded().withId().isEqualTo("patch-fred");
    } else if (collection) {
      assertThat(promise).failedWithException().isInstanceOf(NotSupportedException.class);
    } else {
      assertThat(promise).failedWithException().isInstanceOf(NotFoundException.class);
    }
  }