use of org.uberfire.workbench.events.NotificationEvent in project kie-wb-common by kiegroup.
the class AbstractBuildAndDeployExecutor method notifyUpdateSuccess.
protected void notifyUpdateSuccess() {
notificationEvent.fire(new NotificationEvent(CONSTANTS.DeploySuccessfulAndContainerUpdated(), NotificationEvent.NotificationType.SUCCESS).setAutoHide(false).setNavigation(CONSTANTS.ViewDeploymentDetails(), new DefaultPlaceRequest(SERVER_MANAGEMENT)));
finish();
}
use of org.uberfire.workbench.events.NotificationEvent in project kie-wb-common by kiegroup.
the class AbstractBuildAndDeployExecutor method saveContainerSpecAndMaybeStartContainer.
protected void saveContainerSpecAndMaybeStartContainer(final BuildExecutionContext context, final ContainerSpec containerSpec) {
specManagementService.call(ignore -> {
if (!context.isStartContainer()) {
notificationEvent.fire(new NotificationEvent(CONSTANTS.DeploySuccessful(), NotificationEvent.NotificationType.SUCCESS).setAutoHide(false).setNavigation(CONSTANTS.ViewDeploymentDetails(), new DefaultPlaceRequest(SERVER_MANAGEMENT)));
finish();
return;
}
specManagementService.call(ignore2 -> {
notificationEvent.fire(new NotificationEvent(CONSTANTS.DeploySuccessfulAndContainerStarted(), NotificationEvent.NotificationType.SUCCESS).setAutoHide(false).setNavigation(CONSTANTS.ViewDeploymentDetails(), new DefaultPlaceRequest(SERVER_MANAGEMENT)));
finish();
}, (o, throwable) -> {
notificationEvent.fire(new NotificationEvent(CONSTANTS.DeploySuccessfulButContainerFailedToStart(), NotificationEvent.NotificationType.WARNING).setAutoHide(false).setNavigation(CONSTANTS.ViewDeploymentDetails(), new DefaultPlaceRequest(SERVER_MANAGEMENT)));
finish();
return false;
}).startContainer(containerSpec);
}, (o, throwable) -> {
notificationEvent.fire(new NotificationEvent(CONSTANTS.DeployFailed(), NotificationEvent.NotificationType.ERROR).setAutoHide(false).setNavigation(CONSTANTS.ViewDeploymentDetails(), new DefaultPlaceRequest(SERVER_MANAGEMENT)));
finish();
return false;
}).saveContainerSpec(context.getServerTemplate().getId(), containerSpec);
}
use of org.uberfire.workbench.events.NotificationEvent in project kie-wb-common by kiegroup.
the class AbstractBuildAndDeployExecutor method buildDeployWithoutServerTemplate.
private void buildDeployWithoutServerTemplate(final BuildExecutionContext context, final DeploymentMode mode) {
showBuildMessage();
buildServiceCaller.call((RemoteCallback<BuildResults>) result -> {
if (result.getErrorMessages().isEmpty()) {
notificationEvent.fire(new NotificationEvent(CONSTANTS.BuildSuccessful(), NotificationEvent.NotificationType.SUCCESS));
notificationEvent.fire(new NotificationEvent(CONSTANTS.DeploymentSkippedDueToNoServerTemplateConfiguredForMode(preferedKieServerMode.name().toLowerCase()), NotificationEvent.NotificationType.WARNING).setAutoHide(false).setNavigation(CONSTANTS.ViewDeploymentDetails(), new DefaultPlaceRequest(SERVER_MANAGEMENT)));
} else {
notificationEvent.fire(new NotificationEvent(CONSTANTS.BuildFailed(), NotificationEvent.NotificationType.ERROR));
}
buildResultsEvent.fire(result);
finish();
}, (ErrorCallback<Message>) (message, throwable) -> {
buildDeployWithoutServerTemplate(context, DeploymentMode.FORCED);
return false;
}).buildAndDeploy(context.getModule(), mode);
}
use of org.uberfire.workbench.events.NotificationEvent in project kie-wb-common by kiegroup.
the class ContainerPresenterTest method testStartContainer.
@Test
public void testStartContainer() {
when(runtimeManagementService.getContainersByContainerSpec(serverTemplateKey.getId(), containerSpec.getId())).thenReturn(containerSpecData);
presenter.loadContainers(containerSpecData);
presenter.startContainer();
verify(view, times(2)).setContainerStartState(State.DISABLED);
verify(view, times(2)).setContainerStopState(State.ENABLED);
final String errorMessage = "ERROR";
when(view.getStartContainerErrorMessage()).thenReturn(errorMessage);
doThrow(new RuntimeException()).when(specManagementService).startContainer(containerSpecData.getContainerSpec());
presenter.startContainer();
verify(notification).fire(new NotificationEvent(errorMessage, NotificationEvent.NotificationType.ERROR));
verify(view, times(3)).setContainerStartState(State.DISABLED);
verify(view, times(3)).setContainerStopState(State.ENABLED);
verify(view, times(3)).enableRemoveButton();
}
use of org.uberfire.workbench.events.NotificationEvent in project kie-wb-common by kiegroup.
the class ContainerPresenterTest method testStopContainer.
@Test
public void testStopContainer() {
when(runtimeManagementService.getContainersByContainerSpec(serverTemplateKey.getId(), containerSpec.getId())).thenReturn(containerSpecData);
presenter.loadContainers(containerSpecData);
presenter.stopContainer();
verify(view, times(2)).setContainerStartState(State.DISABLED);
verify(view, times(2)).setContainerStopState(State.ENABLED);
verify(view, times(2)).enableRemoveButton();
final String errorMessage = "ERROR";
when(view.getStopContainerErrorMessage()).thenReturn(errorMessage);
doThrow(new RuntimeException()).when(specManagementService).stopContainer(containerSpecData.getContainerSpec());
presenter.stopContainer();
verify(notification).fire(new NotificationEvent(errorMessage, NotificationEvent.NotificationType.ERROR));
verify(view, times(3)).setContainerStartState(State.DISABLED);
verify(view, times(3)).setContainerStopState(State.ENABLED);
}
Aggregations