コード例 #1
0
 private JerseyRequest<ClientResource> prepareDetailsRequest() {
   JerseyRequest<ClientResource> request =
       buildRequest(
           sessionStorage, ClientResource.class, new String[] {"/resources", resourceUri});
   request.addParams(params);
   if (isRootFolder(resourceUri)) {
     request.setAccept(ResourceMediaType.FOLDER_JSON);
   } else {
     request.setAccept(ResourceMediaType.FILE_JSON);
   }
   return request;
 }
  @Test
  /** for {@link SingleThumbnailAdapter#get()} */
  public void should_return_proper_operation_result() {

    // Given
    mockStatic(JerseyRequest.class);
    when(buildRequest(
            eq(sessionStorageMock),
            eq(InputStream.class),
            eq(new String[] {"/thumbnails", "/public/Samples/Reports/07g.RevenueDetailReport"}),
            any(DefaultErrorHandler.class)))
        .thenReturn(jerseyRequestMock);
    when(jerseyRequestMock.setAccept("image/jpeg")).thenReturn(jerseyRequestMock);
    when(jerseyRequestMock.get()).thenReturn(operationResultMock);
    SingleThumbnailAdapter thumbnailAdapter = new SingleThumbnailAdapter(sessionStorageMock);
    thumbnailAdapter.report("/public/Samples/Reports/07g.RevenueDetailReport");

    // When
    OperationResult<InputStream> retrieved = thumbnailAdapter.get();

    // Then
    assertNotNull(retrieved);
    assertSame(retrieved, operationResultMock);
    verify(jerseyRequestMock).setAccept(eq("image/jpeg"));
    verify(jerseyRequestMock).get();
    verifyStatic(times(1));
    buildRequest(
        eq(sessionStorageMock),
        eq(InputStream.class),
        eq(new String[] {"/thumbnails", "/public/Samples/Reports/07g.RevenueDetailReport"}),
        any(DefaultErrorHandler.class));
  }
コード例 #3
0
 private <ResourceType extends ClientResource>
     JerseyRequest<ResourceType> preparePatchResourceRequest(
         Class<ResourceType> resourceTypeClass) {
   JerseyRequest<ResourceType> request =
       buildRequest(sessionStorage, resourceTypeClass, new String[] {"/resources", resourceUri});
   request.setAccept(
       MimeTypeUtil.toCorrectContentMime(
           sessionStorage.getConfiguration(),
           ResourcesTypeResolverUtil.getMimeType(resourceTypeClass)));
   request.addHeader("X-HTTP-Method-Override", "PATCH");
   return request;
 }