@Test public void testHandle() throws IOException, FileUploadException { BlobStoreMultipartForm uploadedForm = new BlobStoreMultipartForm(); TempBlobFormField field = new TempBlobFormField("asset1", "foo.jar", mock(TempBlob.class)); uploadedForm.putFile("asset1", field); when(blobStoreAwareMultipartHelper.parse(anyObject(), anyObject())).thenReturn(uploadedForm); when(handlerA.handle(anyObject(), anyObject())).thenReturn(mock(UploadResponse.class)); underTest.handle(repository, request); verify(handlerA, times(1)).handle(repository, componentUploadCaptor.getValue()); verify(handlerB, never()).handle(anyObject(), anyObject()); reset(handlerA, handlerB); when(handlerB.getDefinition()).thenReturn(uploadB); when(handlerB.getValidatingComponentUpload(anyObject())).thenReturn(validatingComponentUpload); when(handlerB.handle(anyObject(), anyObject())).thenReturn(mock(UploadResponse.class)); when(repository.getFormat()).thenReturn(new Format("b") { }); underTest.handle(repository, request); verify(handlerB, times(1)).handle(repository, componentUploadCaptor.getValue()); verify(handlerA, never()).handle(anyObject(), anyObject()); }
@Override public UploadResponse handle(final Repository repository, final HttpServletRequest request) throws IOException { checkNotNull(repository); checkNotNull(request); if (!repository.getConfiguration().isOnline()) { throw new ValidationErrorsException("Repository offline"); } UploadHandler uploadHandler = getUploadHandler(repository); ComponentUpload upload = create(repository, request); logUploadDetails(upload, repository); try { return uploadHandler.handle(repository, uploadHandler.getValidatingComponentUpload(upload).getComponentUpload()); } finally { for (AssetUpload assetUpload : upload.getAssetUploads()) { assetUpload.getPayload().close(); } } }
UploadManagerImpl extends ComponentSupport implements UploadManager { @Override public UploadResponse handle(final Repository repository, final HttpServletRequest request) throws IOException { checkNotNull(repository); checkNotNull(request); if (!repository.getConfiguration().isOnline()) { throw new ValidationErrorsException("Repository offline"); } UploadHandler uploadHandler = getUploadHandler(repository); ComponentUpload upload = create(repository, request); logUploadDetails(upload, repository); try { return uploadHandler.handle(repository, uploadHandler.getValidatingComponentUpload(upload).getComponentUpload()); } finally { for (AssetUpload assetUpload : upload.getAssetUploads()) { assetUpload.getPayload().close(); } } } }
UploadManagerImpl extends ComponentSupport implements UploadManager { @Override public UploadResponse handle(final Repository repository, final HttpServletRequest request) throws IOException { checkNotNull(repository); checkNotNull(request); if (!repository.getConfiguration().isOnline()) { throw new ValidationErrorsException("Repository offline"); } UploadHandler uploadHandler = getUploadHandler(repository); ComponentUpload upload = create(repository, request); logUploadDetails(upload, repository); try { return uploadHandler.handle(repository, uploadHandler.getValidatingComponentUpload(upload).getComponentUpload()); } finally { for (AssetUpload assetUpload : upload.getAssetUploads()) { assetUpload.getPayload().close(); } } } @Inject  UploadManagerImpl(final Map<String, UploadHandler> uploadHandlers,
                           final UploadComponentMultipartHelper multipartHelper); }
UploadManagerImpl extends ComponentSupport implements UploadManager { @Override public UploadResponse handle(final Repository repository, final HttpServletRequest request) throws IOException { checkNotNull(repository); checkNotNull(request); if (!repository.getConfiguration().isOnline()) { throw new ValidationErrorsException("Repository offline"); } UploadHandler uploadHandler = getUploadHandler(repository); ComponentUpload upload = create(repository, request); logUploadDetails(upload, repository); try { return uploadHandler.handle(repository, uploadHandler.getValidatingComponentUpload(upload).getComponentUpload()); } finally { for (AssetUpload assetUpload : upload.getAssetUploads()) { assetUpload.getPayload().close(); } } } @Inject  UploadManagerImpl(final Map<String, UploadHandler> uploadHandlers,
                           final UploadComponentMultipartHelper multipartHelper); @Override Collection<UploadDefinition> getAvailableDefinitions(); @Override UploadResponse handle(final Repository repository, final HttpServletRequest request); @Override UploadDefinition getByFormat(final String format); @Override Content handle(
      final Repository repository, final File content, final String path); }
UploadManagerImpl extends ComponentSupport implements UploadManager { @Override public UploadResponse handle(final Repository repository, final HttpServletRequest request) throws IOException { checkNotNull(repository); checkNotNull(request); if (!repository.getConfiguration().isOnline()) { throw new ValidationErrorsException("Repository offline"); } UploadHandler uploadHandler = getUploadHandler(repository); ComponentUpload upload = create(repository, request); logUploadDetails(upload, repository); try { return uploadHandler.handle(repository, uploadHandler.getValidatingComponentUpload(upload).getComponentUpload()); } finally { for (AssetUpload assetUpload : upload.getAssetUploads()) { assetUpload.getPayload().close(); } } } @Inject  UploadManagerImpl(final Map<String, UploadHandler> uploadHandlers,
                           final UploadComponentMultipartHelper multipartHelper); @Override Collection<UploadDefinition> getAvailableDefinitions(); @Override UploadResponse handle(final Repository repository, final HttpServletRequest request); @Override UploadDefinition getByFormat(final String format); @Override Content handle(
      final Repository repository, final File content, final String path);  }