@Test public void submitCompleteWhenImportIsSuccessTest() { reset(view); ImportResponse importResponse = mock(ImportResponse.class); ProjectDescriptor projectDescriptor = mock(ProjectDescriptor.class); when(dtoFactory.createDtoFromJson(anyString(), Matchers.<Class<ImportResponse>>anyObject())).thenReturn(importResponse); when(importResponse.getProjectDescriptor()).thenReturn(projectDescriptor); presenter.onSubmitComplete(RESPONSE); verify(view).setLoaderVisibility(eq(false)); verify(view).setInputsEnableState(eq(true)); verify(dtoFactory).createDtoFromJson(PARSED_RESPONSE, ImportResponse.class); verify(view).closeDialog(); verify(importProjectNotificationSubscriber).onSuccess(); verify(eventBus).fireEvent(Matchers.<Event<OpenProjectEvent>>anyObject()); verify(importProjectNotificationSubscriber, never()).onFailure(anyString()); }
@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();  }