use of org.guvnor.ala.ui.client.events.ProviderSelectedEvent in project kie-wb-common by kiegroup.
the class ProviderTypePresenterTest method onProviderSelectTest.
@Test
public void onProviderSelectTest() {
presenter.setup(providerType, providers, provider);
// try the selection of all indexes.
providers.forEach(providerKey -> {
presenter.onProviderSelect(new ProviderSelectedEvent(providerKey));
verify(view, times(1)).select(providerKey.getId());
});
}
use of org.guvnor.ala.ui.client.events.ProviderSelectedEvent in project kie-wb-common by kiegroup.
the class ProviderPresenterTest method prepareRefreshWithNoItems.
/**
* Prepares the refresh action. The refresh action only takes place if the provider has been loaded first.
*/
private void prepareRefreshWithNoItems() {
prepareRuntimesInfo();
// emulate that there are no runtimes.
when(runtimeItems.isEmpty()).thenReturn(true);
// emulate that the presenter was initially loaded. If not the refresh button is not available.
presenter.onProviderSelected(new ProviderSelectedEvent(providerKey));
}
use of org.guvnor.ala.ui.client.events.ProviderSelectedEvent in project kie-wb-common by kiegroup.
the class ProviderPresenterTest method testPipelineExecutionDeletedRefreshRequired.
@Test
public void testPipelineExecutionDeletedRefreshRequired() {
// load the presenter.
prepareRuntimesInfo();
when(runtimeItems.isEmpty()).thenReturn(true);
presenter.onProviderSelected(new ProviderSelectedEvent(providerKey));
PipelineExecutionTraceKey pipelineExecutionTraceKey = mock(PipelineExecutionTraceKey.class);
when(providerStatusPresenter.removeItem(pipelineExecutionTraceKey)).thenReturn(true);
// the status presenter is empty after the removal.
when(providerStatusPresenter.isEmpty()).thenReturn(true);
presenter.onPipelineExecutionChange(new PipelineExecutionChangeEvent(PipelineExecutionChange.DELETED, pipelineExecutionTraceKey));
verify(providerStatusPresenter, times(1)).removeItem(pipelineExecutionTraceKey);
verify(presenter, times(1)).refresh();
}
use of org.guvnor.ala.ui.client.events.ProviderSelectedEvent in project kie-wb-common by kiegroup.
the class ProviderPresenterTest method testOnRemoveProviderWithRuntimes.
@Test
public void testOnRemoveProviderWithRuntimes() {
// emulate that the provider was previously loaded.
prepareRuntimesInfo();
presenter.onProviderSelected(new ProviderSelectedEvent(providerKey));
when(provisioningScreensService.hasRuntimes(providerKey)).thenReturn(true);
presenter.onRemoveProvider();
verify(view, times(1)).showProviderCantBeDeleted();
}
use of org.guvnor.ala.ui.client.events.ProviderSelectedEvent in project kie-wb-common by kiegroup.
the class ProviderPresenterTest method testRemoveProvider.
private void testRemoveProvider(boolean withErrors) {
// emulate that the provider was previously loaded.
prepareRuntimesInfo();
presenter.onProviderSelected(new ProviderSelectedEvent(providerKey));
when(view.getRemoveProviderSuccessMessage()).thenReturn(SUCCESS_MESSAGE);
when(view.getRemoveProviderErrorMessage()).thenReturn(ERROR_MESSAGE);
if (withErrors) {
// make the providerService fail.
prepareServiceCallerError(providerService, providerServiceCaller);
}
// the user confirms the delete operation at a later time from the ui.
presenter.removeProvider();
verify(providerService, times(1)).deleteProvider(providerKey);
verify(providerTypeSelectedEvent, times(1)).fire(new ProviderTypeSelectedEvent(providerKey.getProviderTypeKey()));
if (withErrors) {
verify(notification, times(1)).fire(new NotificationEvent(ERROR_MESSAGE, NotificationEvent.NotificationType.ERROR));
} else {
verify(notification, times(1)).fire(new NotificationEvent(SUCCESS_MESSAGE, NotificationEvent.NotificationType.SUCCESS));
}
}
Aggregations