@Test public void submitCompleteWhenImportIsFailureTest() { reset(view); String response = "ERROR"; when(view.getProjectName()).thenReturn(PROJECT_NAME); presenter.onSubmitComplete(response); verify(view).setLoaderVisibility(eq(false)); verify(view).setInputsEnableState(eq(true)); verify(dtoFactory).createDtoFromJson(response, ImportResponse.class); verify(view).closeDialog(); verify(importProjectNotificationSubscriber, never()).onSuccess(); verify(importProjectNotificationSubscriber).onFailure(anyString()); verify(projectServiceClient).delete(eq(PROJECT_NAME), Matchers.<AsyncRequestCallback<Void>>anyObject()); }
@Override public void onSubmitComplete(String result) { try { showProcessing(false); result = extractFromHtmlFormat(result); if (result.isEmpty()) { importFailure(locale.importProjectMessageFailure()); return; } ImportResponse importResponse = dtoFactory.createDtoFromJson(result, ImportResponse.class); if (importResponse.getProjectDescriptor() == null) { importFailure(JsonHelper.parseJsonMessage(result)); return; } importSuccess(importResponse); } catch (Exception e) { importFailure(result); } }
LocalZipImporterPagePresenter implements LocalZipImporterPageView.ActionDelegate { @Override public void onSubmitComplete(String result) { try { showProcessing(false); result = extractFromHtmlFormat(result); if (result.isEmpty()) { importFailure(locale.importProjectMessageFailure()); return; } ImportResponse importResponse = dtoFactory.createDtoFromJson(result, ImportResponse.class); if (importResponse.getProjectDescriptor() == null) { importFailure(JsonHelper.parseJsonMessage(result)); return; } importSuccess(importResponse); } catch (Exception e) { importFailure(result); } } }
LocalZipImporterPagePresenter implements LocalZipImporterPageView.ActionDelegate { @Override public void onSubmitComplete(String result) { try { showProcessing(false); result = extractFromHtmlFormat(result); if (result.isEmpty()) { importFailure(locale.importProjectMessageFailure()); return; } ImportResponse importResponse = dtoFactory.createDtoFromJson(result, ImportResponse.class); if (importResponse.getProjectDescriptor() == null) { importFailure(JsonHelper.parseJsonMessage(result)); return; } importSuccess(importResponse); } catch (Exception e) { importFailure(result); } } @Inject  LocalZipImporterPagePresenter(LocalZipImporterPageView view,
                                         DtoFactory dtoFactory,
                                         CoreLocalizationConstant locale,
                                         @Named("restContext") String restContext,
                                         @Named("workspaceId") String workspaceId,
                                         EventBus eventBus,
                                         VfsServiceClient vfsServiceClient,
                                         ProjectServiceClient projectServiceClient,
                                         DialogFactory dialogFactory,
                                         ImportProjectNotificationSubscriber importProjectNotificationSubscriber); }
LocalZipImporterPagePresenter implements LocalZipImporterPageView.ActionDelegate { @Override public void onSubmitComplete(String result) { try { showProcessing(false); result = extractFromHtmlFormat(result); if (result.isEmpty()) { importFailure(locale.importProjectMessageFailure()); return; } ImportResponse importResponse = dtoFactory.createDtoFromJson(result, ImportResponse.class); if (importResponse.getProjectDescriptor() == null) { importFailure(JsonHelper.parseJsonMessage(result)); return; } importSuccess(importResponse); } catch (Exception e) { importFailure(result); } } @Inject  LocalZipImporterPagePresenter(LocalZipImporterPageView view,
                                         DtoFactory dtoFactory,
                                         CoreLocalizationConstant locale,
                                         @Named("restContext") String restContext,
                                         @Named("workspaceId") String workspaceId,
                                         EventBus eventBus,
                                         VfsServiceClient vfsServiceClient,
                                         ProjectServiceClient projectServiceClient,
                                         DialogFactory dialogFactory,
                                         ImportProjectNotificationSubscriber importProjectNotificationSubscriber); void show(); @Override void projectNameChanged(); @Override void fileNameChanged(); @Override void onSubmitComplete(String result); @Override void onCancelClicked(); @Override void onImportClicked(); }
LocalZipImporterPagePresenter implements LocalZipImporterPageView.ActionDelegate { @Override public void onSubmitComplete(String result) { try { showProcessing(false); result = extractFromHtmlFormat(result); if (result.isEmpty()) { importFailure(locale.importProjectMessageFailure()); return; } ImportResponse importResponse = dtoFactory.createDtoFromJson(result, ImportResponse.class); if (importResponse.getProjectDescriptor() == null) { importFailure(JsonHelper.parseJsonMessage(result)); return; } importSuccess(importResponse); } catch (Exception e) { importFailure(result); } } @Inject  LocalZipImporterPagePresenter(LocalZipImporterPageView view,
                                         DtoFactory dtoFactory,
                                         CoreLocalizationConstant locale,
                                         @Named("restContext") String restContext,
                                         @Named("workspaceId") String workspaceId,
                                         EventBus eventBus,
                                         VfsServiceClient vfsServiceClient,
                                         ProjectServiceClient projectServiceClient,
                                         DialogFactory dialogFactory,
                                         ImportProjectNotificationSubscriber importProjectNotificationSubscriber); void show(); @Override void projectNameChanged(); @Override void fileNameChanged(); @Override void onSubmitComplete(String result); @Override void onCancelClicked(); @Override void onImportClicked();  }