@Test public void testNoFileSelected() { when(options.getFormFileName()).thenReturn(null); uploader.create(pkg, "file", presenter); verify(busyIndicatorView, never()).showBusyIndicator(any(String.class)); verify(options, never()).upload(any(Consumer.class), any(Consumer.class)); }
@Override public void create(final org.guvnor.common.services.project.model.Package pkg, final String baseFileName, final NewResourcePresenter presenter) { String targetFileName; String extension; final String originalFileName = options.getFormFileName(); final String providedFileName = baseFileName; if (originalFileName == null || "".equals(originalFileName)) { Window.alert(CommonConstants.INSTANCE.UploadSelectAFile()); return; } if (providedFileName.contains(".")) { targetFileName = providedFileName; extension = getExtension(providedFileName); } else { extension = getExtension(originalFileName); targetFileName = providedFileName + "." + extension; } busyIndicatorView.showBusyIndicator(GuvnorDefaultEditorConstants.INSTANCE.Uploading()); moduleService.call(getResolvePathSuccessCallback(targetFileName, presenter), new HasBusyIndicatorDefaultErrorCallback(busyIndicatorView)).resolveDefaultPath(pkg, extension); }
NewFileUploader extends DefaultNewResourceHandler { @Override public void create(final org.guvnor.common.services.project.model.Package pkg, final String baseFileName, final NewResourcePresenter presenter) { String targetFileName; String extension; final String originalFileName = options.getFormFileName(); final String providedFileName = baseFileName; if (originalFileName == null || "".equals(originalFileName)) { Window.alert(CommonConstants.INSTANCE.UploadSelectAFile()); return; } if (providedFileName.contains(".")) { targetFileName = providedFileName; extension = getExtension(providedFileName); } else { extension = getExtension(originalFileName); targetFileName = providedFileName + "." + extension; } busyIndicatorView.showBusyIndicator(GuvnorDefaultEditorConstants.INSTANCE.Uploading()); moduleService.call(getResolvePathSuccessCallback(targetFileName, presenter), new HasBusyIndicatorDefaultErrorCallback(busyIndicatorView)).resolveDefaultPath(pkg, extension); } }
NewFileUploader extends DefaultNewResourceHandler { @Override public void create(final org.guvnor.common.services.project.model.Package pkg, final String baseFileName, final NewResourcePresenter presenter) { String targetFileName; String extension; final String originalFileName = options.getFormFileName(); final String providedFileName = baseFileName; if (originalFileName == null || "".equals(originalFileName)) { Window.alert(CommonConstants.INSTANCE.UploadSelectAFile()); return; } if (providedFileName.contains(".")) { targetFileName = providedFileName; extension = getExtension(providedFileName); } else { extension = getExtension(originalFileName); targetFileName = providedFileName + "." + extension; } busyIndicatorView.showBusyIndicator(GuvnorDefaultEditorConstants.INSTANCE.Uploading()); moduleService.call(getResolvePathSuccessCallback(targetFileName, presenter), new HasBusyIndicatorDefaultErrorCallback(busyIndicatorView)).resolveDefaultPath(pkg, extension); } NewFileUploader(); @Inject  NewFileUploader(final PlaceManager placeManager,
                           final DefaultEditorNewFileUpload options,
                           final AnyResourceTypeDefinition resourceType,
                           final BusyIndicatorView busyIndicatorView,
                           final Caller<KieModuleService> moduleService); }
NewFileUploader extends DefaultNewResourceHandler { @Override public void create(final org.guvnor.common.services.project.model.Package pkg, final String baseFileName, final NewResourcePresenter presenter) { String targetFileName; String extension; final String originalFileName = options.getFormFileName(); final String providedFileName = baseFileName; if (originalFileName == null || "".equals(originalFileName)) { Window.alert(CommonConstants.INSTANCE.UploadSelectAFile()); return; } if (providedFileName.contains(".")) { targetFileName = providedFileName; extension = getExtension(providedFileName); } else { extension = getExtension(originalFileName); targetFileName = providedFileName + "." + extension; } busyIndicatorView.showBusyIndicator(GuvnorDefaultEditorConstants.INSTANCE.Uploading()); moduleService.call(getResolvePathSuccessCallback(targetFileName, presenter), new HasBusyIndicatorDefaultErrorCallback(busyIndicatorView)).resolveDefaultPath(pkg, extension); } NewFileUploader(); @Inject  NewFileUploader(final PlaceManager placeManager,
                           final DefaultEditorNewFileUpload options,
                           final AnyResourceTypeDefinition resourceType,
                           final BusyIndicatorView busyIndicatorView,
                           final Caller<KieModuleService> moduleService); @Override String getDescription(); @Override IsWidget getIcon(); @Override ResourceTypeDefinition getResourceType(); @Override void create(final org.guvnor.common.services.project.model.Package pkg,
                       final String baseFileName,
                       final NewResourcePresenter presenter); @Override boolean isProjectAsset(); }
NewFileUploader extends DefaultNewResourceHandler { @Override public void create(final org.guvnor.common.services.project.model.Package pkg, final String baseFileName, final NewResourcePresenter presenter) { String targetFileName; String extension; final String originalFileName = options.getFormFileName(); final String providedFileName = baseFileName; if (originalFileName == null || "".equals(originalFileName)) { Window.alert(CommonConstants.INSTANCE.UploadSelectAFile()); return; } if (providedFileName.contains(".")) { targetFileName = providedFileName; extension = getExtension(providedFileName); } else { extension = getExtension(originalFileName); targetFileName = providedFileName + "." + extension; } busyIndicatorView.showBusyIndicator(GuvnorDefaultEditorConstants.INSTANCE.Uploading()); moduleService.call(getResolvePathSuccessCallback(targetFileName, presenter), new HasBusyIndicatorDefaultErrorCallback(busyIndicatorView)).resolveDefaultPath(pkg, extension); } NewFileUploader(); @Inject  NewFileUploader(final PlaceManager placeManager,
                           final DefaultEditorNewFileUpload options,
                           final AnyResourceTypeDefinition resourceType,
                           final BusyIndicatorView busyIndicatorView,
                           final Caller<KieModuleService> moduleService); @Override String getDescription(); @Override IsWidget getIcon(); @Override ResourceTypeDefinition getResourceType(); @Override void create(final org.guvnor.common.services.project.model.Package pkg,
                       final String baseFileName,
                       final NewResourcePresenter presenter); @Override boolean isProjectAsset();  }