ProjectProblemResolver implements ProjectProblemDialogCallback { public void resolve(final @NotNull ProjectDescriptor projectDescriptor) { this.projectDescriptor = projectDescriptor; final Unmarshallable<List<SourceEstimation>> unmarshaller = dtoUnmarshallerFactory.newListUnmarshaller(SourceEstimation.class); projectServiceClient.resolveSources(projectDescriptor.getPath(), new AsyncRequestCallback<List<SourceEstimation>>(unmarshaller) { @Override protected void onSuccess(List<SourceEstimation> result) { problemDialogPresenter.showDialog(result, ProjectProblemResolver.this); } @Override protected void onFailure(Throwable exception) { problemDialogPresenter.showDialog(null, ProjectProblemResolver.this); } }); } @Inject  ProjectProblemResolver(final ProjectServiceClient projectServiceClient,
                                  final EventBus eventBus,
                                  final DtoFactory dtoFactory,
                                  final NotificationManager notificationManager,
                                  final DtoUnmarshallerFactory dtoUnmarshallerFactory,
                                  final ProjectProblemDialogPresenter problemDialogPresenter); void resolve(final @NotNull ProjectDescriptor projectDescriptor); @Override void onConfigure(@Nullable SourceEstimation estimatedType); @Override void onOpenAsIs(); @Override void onOpenAs(@Nullable SourceEstimation estimatedType);  }
@Test public void testOnResolveWhenRequestIsSuccess() throws Exception { List<SourceEstimation> list = new ArrayList<>(1); SourceEstimation mavenSourceEstimation = mock(SourceEstimation.class); SourceEstimation phpSourceEstimation = mock(SourceEstimation.class); list.add(mavenSourceEstimation); list.add(phpSourceEstimation); when(projectDescriptor.getPath()).thenReturn(PROJECT_PATH); resolver.resolve(projectDescriptor); verify(projectServiceClient).resolveSources(anyString(), resolveSourceCallbackCaptor.capture()); AsyncRequestCallback<List<SourceEstimation>> resolveSourceCallback = resolveSourceCallbackCaptor.getValue(); GwtReflectionUtils.callOnSuccess(resolveSourceCallback, list); verify(dtoUnmarshallerFactory).newListUnmarshaller(anyObject()); verify(problemDialogPresenter).showDialog(eq(list), eq(resolver)); }
@Test public void testOnResolveWhenRequestIsFailure() throws Exception { when(projectDescriptor.getPath()).thenReturn(PROJECT_PATH); resolver.resolve(projectDescriptor); verify(projectServiceClient).resolveSources(anyString(), resolveSourceCallbackCaptor.capture()); AsyncRequestCallback<List<SourceEstimation>> resolveSourceCallback = resolveSourceCallbackCaptor.getValue(); GwtReflectionUtils.callOnFailure(resolveSourceCallback, mock(Throwable.class)); verify(dtoUnmarshallerFactory).newListUnmarshaller(anyObject()); verify(problemDialogPresenter).showDialog(isNull(List.class), eq(resolver)); }