use of org.uberfire.workbench.events.NotificationEvent in project kie-wb-common by kiegroup.
the class DecisionComponentsItemViewTest method testMakeDragProxyCallbackImplWhenNodeIsDuplicated.
@Test
public void testMakeDragProxyCallbackImplWhenNodeIsDuplicated() {
final ShapeFactory factory = mock(ShapeFactory.class);
final DRGElement drgElement = mock(DRGElement.class);
final int x = 10;
final int y = 20;
final String expectedWarnMessage = "This 'DRGElement' already exists!";
final NotificationEvent.NotificationType expectedWarnType = WARNING;
final Graph<?, Node> graph = mock(Graph.class);
final List<Node> nodes = new ArrayList<>();
final String id1 = "123";
final String id2 = "123";
nodes.add(createNode(id1));
nodes.add(createNode(id2));
when(graph.nodes()).thenReturn(nodes);
when(drgElement.getId()).thenReturn(new Id(id1));
when(clientTranslationService.getValue(DecisionComponentsItemView_DuplicatedNode)).thenReturn(expectedWarnMessage);
doReturn(graph).when(view).getGraph();
view.setIsImported(true);
view.makeDragProxyCallbackImpl(drgElement, factory).onComplete(x, y);
verify(buildCanvasShapeEvent, never()).fire(any());
verify(notificationEvent).fire(notificationEventArgumentCaptor.capture());
final NotificationEvent notificationEvent = notificationEventArgumentCaptor.getValue();
assertEquals(expectedWarnMessage, notificationEvent.getNotification());
assertEquals(expectedWarnType, notificationEvent.getType());
}
use of org.uberfire.workbench.events.NotificationEvent 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));
}
}
use of org.uberfire.workbench.events.NotificationEvent in project kie-wb-common by kiegroup.
the class RuntimePresenterActionsTest method testDeletePipelineConfirmYesAndSuccessful.
@Test
public void testDeletePipelineConfirmYesAndSuccessful() {
preparePipelineDelete();
PipelineExecutionTraceKey currentKey = trace.getKey();
when(translationService.format(RuntimePresenter_PipelineExecutionDeleteSuccessMessage, currentKey.getId())).thenReturn(SUCCESS_MESSAGE);
yesCommandCaptor.getValue().execute();
verify(runtimeService, times(1)).deletePipelineExecution(currentKey);
verify(notificationEvent, times(1)).fire(new NotificationEvent(SUCCESS_MESSAGE, NotificationEvent.NotificationType.SUCCESS));
}
use of org.uberfire.workbench.events.NotificationEvent in project kie-wb-common by kiegroup.
the class NewDeployWizardTest method testStartDeploymentSuccess.
@Test
public void testStartDeploymentSuccess() {
// initialize and start the wizard.
wizard.start(provider, pipelines);
verifyStart();
// e.g. PIPELINE1 was selected.
preSelectForms(PIPELINE1_KEY);
// emulate the user completing the wizard.
preCompleteWizard(PIPELINE1_KEY, RUNTIME);
// emulates the user pressing the finish button
wizard.complete();
// the parameters must the the values collected by the forms.
Map<String, String> expectedPrams = buildExpectedParams(paramsFormsValues);
expectedPrams.put(RUNTIME_NAME, RUNTIME);
verify(runtimeService, times(1)).createRuntime(provider.getKey(), RUNTIME, PIPELINE1_KEY, expectedPrams);
verify(notification, times(1)).fire(new NotificationEvent(SUCCESS_MESSAGE, NotificationEvent.NotificationType.SUCCESS));
verify(refreshRuntimeEvent, times(1)).fire(new RefreshRuntimeEvent(provider.getKey()));
}
use of org.uberfire.workbench.events.NotificationEvent in project kie-wb-common by kiegroup.
the class EnableProviderTypeWizardTest method testEnableProviderSuccess.
@Test
public void testEnableProviderSuccess() {
// initialize and start the wizard.
wizard.start(providerTypeStatus);
// emulate the user completing the wizard.
preCompleteWizard();
// emulates the user pressing the finish button
wizard.complete();
// verify the provider types has been enabled and the proper notifications were fired.
verify(providerTypeService, times(1)).enableProviderTypes(selectedProviders);
verify(notification, times(1)).fire(new NotificationEvent(SUCCESS_MESSAGE, NotificationEvent.NotificationType.SUCCESS));
verify(providerTypeListRefreshEvent, times(1)).fire(new ProviderTypeListRefreshEvent(selectedProviders.get(0).getKey()));
}
Aggregations