Search in sources :

Example 1 with ProviderSelectedEvent

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());
    });
}
Also used : ProviderSelectedEvent(org.guvnor.ala.ui.client.events.ProviderSelectedEvent) Test(org.junit.Test)

Example 2 with ProviderSelectedEvent

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));
}
Also used : ProviderSelectedEvent(org.guvnor.ala.ui.client.events.ProviderSelectedEvent)

Example 3 with ProviderSelectedEvent

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();
}
Also used : ProviderSelectedEvent(org.guvnor.ala.ui.client.events.ProviderSelectedEvent) PipelineExecutionChangeEvent(org.guvnor.ala.ui.events.PipelineExecutionChangeEvent) PipelineExecutionTraceKey(org.guvnor.ala.ui.model.PipelineExecutionTraceKey) Test(org.junit.Test)

Example 4 with ProviderSelectedEvent

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();
}
Also used : ProviderSelectedEvent(org.guvnor.ala.ui.client.events.ProviderSelectedEvent) Test(org.junit.Test)

Example 5 with ProviderSelectedEvent

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));
    }
}
Also used : ProviderSelectedEvent(org.guvnor.ala.ui.client.events.ProviderSelectedEvent) ProviderTypeSelectedEvent(org.guvnor.ala.ui.client.events.ProviderTypeSelectedEvent) NotificationEvent(org.uberfire.workbench.events.NotificationEvent)

Aggregations

ProviderSelectedEvent (org.guvnor.ala.ui.client.events.ProviderSelectedEvent)15 Test (org.junit.Test)12 PipelineExecutionChangeEvent (org.guvnor.ala.ui.events.PipelineExecutionChangeEvent)2 RuntimeChangeEvent (org.guvnor.ala.ui.events.RuntimeChangeEvent)2 PipelineExecutionTraceKey (org.guvnor.ala.ui.model.PipelineExecutionTraceKey)2 RuntimeKey (org.guvnor.ala.ui.model.RuntimeKey)2 AddNewRuntimeEvent (org.guvnor.ala.ui.client.events.AddNewRuntimeEvent)1 ProviderTypeSelectedEvent (org.guvnor.ala.ui.client.events.ProviderTypeSelectedEvent)1 Command (org.uberfire.mvp.Command)1 NotificationEvent (org.uberfire.workbench.events.NotificationEvent)1