Search in sources :

Example 11 with ProviderSelectedEvent

use of org.guvnor.ala.ui.client.events.ProviderSelectedEvent in project kie-wb-common by kiegroup.

the class ProviderPresenterTest method testOnRuntimeDeletedRefreshRequired.

@Test
public void testOnRuntimeDeletedRefreshRequired() {
    // load the presenter.
    prepareRuntimesInfo();
    when(runtimeItems.isEmpty()).thenReturn(true);
    presenter.onProviderSelected(new ProviderSelectedEvent(providerKey));
    RuntimeKey runtimeKey = mock(RuntimeKey.class);
    when(runtimeKey.getProviderKey()).thenReturn(providerKey);
    when(providerStatusPresenter.removeItem(runtimeKey)).thenReturn(true);
    // the provider status presenter is empty after the removal.
    when(providerStatusPresenter.isEmpty()).thenReturn(true);
    presenter.onRuntimeChange(new RuntimeChangeEvent(RuntimeChange.DELETED, runtimeKey));
    verify(providerStatusPresenter, times(1)).removeItem(runtimeKey);
    verify(presenter, times(1)).refresh();
}
Also used : ProviderSelectedEvent(org.guvnor.ala.ui.client.events.ProviderSelectedEvent) RuntimeKey(org.guvnor.ala.ui.model.RuntimeKey) RuntimeChangeEvent(org.guvnor.ala.ui.events.RuntimeChangeEvent) Test(org.junit.Test)

Example 12 with ProviderSelectedEvent

use of org.guvnor.ala.ui.client.events.ProviderSelectedEvent in project kie-wb-common by kiegroup.

the class ProviderPresenterTest method prepareRefreshWithItems.

/**
 * Prepares the refresh action. The refresh action only takes place if the provider has been loaded first.
 */
private void prepareRefreshWithItems() {
    prepareRuntimesInfo();
    // emulate that there are runtimes.
    when(runtimeItems.isEmpty()).thenReturn(false);
    // 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 13 with ProviderSelectedEvent

use of org.guvnor.ala.ui.client.events.ProviderSelectedEvent in project kie-wb-common by kiegroup.

the class ProviderPresenterTest method testOnRemoveProviderWithNoRuntimesSuccessful.

@Test
public void testOnRemoveProviderWithNoRuntimesSuccessful() {
    // emulate that the provider was previously loaded.
    prepareRuntimesInfo();
    presenter.onProviderSelected(new ProviderSelectedEvent(providerKey));
    when(provisioningScreensService.hasRuntimes(providerKey)).thenReturn(false);
    presenter.onRemoveProvider();
    verify(view, never()).showProviderCantBeDeleted();
    verify(view, times(1)).confirmRemove(any(Command.class));
}
Also used : ProviderSelectedEvent(org.guvnor.ala.ui.client.events.ProviderSelectedEvent) Command(org.uberfire.mvp.Command) Test(org.junit.Test)

Example 14 with ProviderSelectedEvent

use of org.guvnor.ala.ui.client.events.ProviderSelectedEvent in project kie-wb-common by kiegroup.

the class ProviderPresenterTest method testPipelineExecutionDeleted.

@Test
public void testPipelineExecutionDeleted() {
    // 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 provider status presenter is not empty after the removal.
    when(providerStatusPresenter.isEmpty()).thenReturn(false);
    presenter.onPipelineExecutionChange(new PipelineExecutionChangeEvent(PipelineExecutionChange.DELETED, pipelineExecutionTraceKey));
    verify(providerStatusPresenter, times(1)).removeItem(pipelineExecutionTraceKey);
}
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 15 with ProviderSelectedEvent

use of org.guvnor.ala.ui.client.events.ProviderSelectedEvent in project kie-wb-common by kiegroup.

the class ProviderPresenterTest method testOnRuntimeDeleted.

@Test
public void testOnRuntimeDeleted() {
    // load the presenter.
    prepareRuntimesInfo();
    when(runtimeItems.isEmpty()).thenReturn(true);
    presenter.onProviderSelected(new ProviderSelectedEvent(providerKey));
    RuntimeKey runtimeKey = mock(RuntimeKey.class);
    when(runtimeKey.getProviderKey()).thenReturn(providerKey);
    when(providerStatusPresenter.removeItem(runtimeKey)).thenReturn(true);
    // the provider status presenter is not empty after the removal.
    when(providerStatusPresenter.isEmpty()).thenReturn(false);
    presenter.onRuntimeChange(new RuntimeChangeEvent(RuntimeChange.DELETED, runtimeKey));
    verify(providerStatusPresenter, times(1)).removeItem(runtimeKey);
}
Also used : ProviderSelectedEvent(org.guvnor.ala.ui.client.events.ProviderSelectedEvent) RuntimeKey(org.guvnor.ala.ui.model.RuntimeKey) RuntimeChangeEvent(org.guvnor.ala.ui.events.RuntimeChangeEvent) Test(org.junit.Test)

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