use of org.uberfire.workbench.events.NotificationEvent in project kie-wb-common by kiegroup.
the class SnapshotRedeployExecutorTest method testRedeploySingleServerTemplateUpdateServerWitException.
@Test
public void testRedeploySingleServerTemplateUpdateServerWitException() {
doAnswer(invocationOnMock -> {
throw new Exception();
}).when(specManagementServiceMock).updateContainerSpec(anyString(), anyString(), any(), anyBoolean());
final ServerTemplate serverTemplate = new ServerTemplate(SERVER_TEMPLATE_ID, SERVER_TEMPLATE_NAME);
serverTemplate.setMode(KieServerMode.DEVELOPMENT);
ContainerSpec spec = mock(ContainerSpec.class);
when(spec.getId()).thenReturn(context.getContainerId());
when(spec.getStatus()).thenReturn(KieContainerStatus.STARTED);
serverTemplate.addContainerSpec(spec);
when(specManagementServiceMock.listServerTemplates()).thenReturn(new ServerTemplateList(Collections.singletonList(serverTemplate)));
runner.run(context);
verify(buildDialog).startBuild();
verify(buildDialog).showBusyIndicator(CONSTANTS.Building());
ArgumentCaptor<ContainerSpec> containerSpecArgumentCaptor = ArgumentCaptor.forClass(ContainerSpec.class);
verify(specManagementServiceMock).updateContainerSpec(eq(SERVER_TEMPLATE_ID), eq(context.getContainerId()), containerSpecArgumentCaptor.capture(), eq(true));
ContainerSpec containerSpec = containerSpecArgumentCaptor.getValue();
assertEquals(module.getPom().getGav().getArtifactId(), containerSpec.getContainerName());
assertEquals(KieContainerStatus.STARTED, containerSpec.getStatus());
verifyNotification(CONSTANTS.DeployFailed(), NotificationEvent.NotificationType.ERROR);
verify(notificationEvent, times(2)).fire(any(NotificationEvent.class));
verify(buildDialog, atLeastOnce()).stopBuild();
verify(deploymentPopup, never()).show(any());
}
use of org.uberfire.workbench.events.NotificationEvent in project kie-wb-common by kiegroup.
the class SnapshotRedeployExecutorTest method testRedeployWithMultipleTemplatesWithPreviousDeployment.
@Test
public void testRedeployWithMultipleTemplatesWithPreviousDeployment() {
final ServerTemplate serverTemplate = new ServerTemplate(SERVER_TEMPLATE_ID, SERVER_TEMPLATE_NAME);
serverTemplate.setMode(KieServerMode.DEVELOPMENT);
final ServerTemplate serverTemplate2 = new ServerTemplate(SERVER_TEMPLATE_ID2, SERVER_TEMPLATE_NAME2);
serverTemplate2.setMode(KieServerMode.DEVELOPMENT);
ContainerSpec spec = mock(ContainerSpec.class);
when(spec.getId()).thenReturn(context.getContainerId());
serverTemplate2.addContainerSpec(spec);
when(settings.getDeployment(anyString(), anyString())).thenReturn(Optional.of(new SnapshotDeployment(GROUP, ARTIFACT, SERVER_TEMPLATE_ID2)));
when(specManagementServiceMock.listServerTemplates()).thenReturn(new ServerTemplateList(Arrays.asList(serverTemplate, serverTemplate2)));
runner.run(context);
verify(buildDialog).startBuild();
verify(buildDialog).showBusyIndicator(CONSTANTS.Building());
ArgumentCaptor<ContainerSpec> containerSpecArgumentCaptor = ArgumentCaptor.forClass(ContainerSpec.class);
verify(specManagementServiceMock).updateContainerSpec(eq(SERVER_TEMPLATE_ID2), eq(context.getContainerId()), containerSpecArgumentCaptor.capture(), eq(true));
ContainerSpec containerSpec = containerSpecArgumentCaptor.getValue();
assertEquals(module.getPom().getGav().getArtifactId(), containerSpec.getContainerName());
verifyNotification(ProjectEditorResources.CONSTANTS.BuildSuccessful(), NotificationEvent.NotificationType.SUCCESS);
verifyNotification(ProjectEditorResources.CONSTANTS.DeploySuccessfulAndContainerUpdated(), NotificationEvent.NotificationType.SUCCESS);
verify(notificationEvent, times(2)).fire(any(NotificationEvent.class));
verify(buildDialog, atLeastOnce()).stopBuild();
verify(deploymentPopup, never()).show(any());
}
use of org.uberfire.workbench.events.NotificationEvent in project kie-wb-common by kiegroup.
the class VariablesEditorWidgetViewImpl method getDataTypes.
protected void getDataTypes(final String value, final boolean fireEvents) {
final List<String> simpleDataTypes = new ArrayList<String>(Arrays.asList("Boolean", "Float", "Integer", "Object", "String"));
final List<String> simpleDataTypeDisplayNames = new ArrayList<String>(Arrays.asList("Boolean", "Float", "Integer", "Object", "String"));
Set<String> types = StringUtils.getSetDataTypes(value);
clientDataTypesService.call(presenter.getDiagramPath()).then(serverDataTypes -> {
List<List<String>> mergedDataTypes = mergeDataTypes(simpleDataTypes, simpleDataTypeDisplayNames, serverDataTypes, types);
setDataTypes(mergedDataTypes.get(0), mergedDataTypes.get(1));
doSetValue(value, fireEvents, true);
return null;
}).catch_(exception -> {
notification.fire(new NotificationEvent(StunnerFormsClientFieldsConstants.CONSTANTS.Error_retrieving_datatypes(), NotificationEvent.NotificationType.ERROR));
setDataTypes(simpleDataTypes, simpleDataTypeDisplayNames);
doSetValue(value, fireEvents, true);
return null;
});
}
use of org.uberfire.workbench.events.NotificationEvent in project kie-wb-common by kiegroup.
the class ImportRepositoryPopUpPresenterTest method importEmptyRepositoryOnSuccessTest.
@Test
public void importEmptyRepositoryOnSuccessTest() {
final String repositoryUrl = "repoUrl";
final String repositoryAlias = "myRepository";
final OrganizationalUnit orgUnit = mock(OrganizationalUnit.class);
doThrow(new EmptyRemoteRepositoryException(repositoryAlias)).when(importService).getProjects(any(), any());
doReturn(repositoryUrl).when(view).getRepositoryURL();
doReturn(Optional.of(orgUnit)).when(projectContext).getActiveOrganizationalUnit();
presenter.importRepository();
verify(libraryService).createProject(orgUnit, repositoryUrl, repositoryAlias);
verify(view, never()).showError(anyString());
verify(view).hideBusyIndicator();
verify(view).hide();
verify(notificationEvent).fire(any(NotificationEvent.class));
verify(libraryPlaces).goToProject(Mockito.<WorkspaceProject>any());
}
use of org.uberfire.workbench.events.NotificationEvent in project kie-wb-common by kiegroup.
the class ImportRepositoryPopUpPresenterTest method importEmptyRepositoryOnFailureTest.
@Test
public void importEmptyRepositoryOnFailureTest() {
final String repositoryUrl = "repoUrl";
final String repositoryAlias = "myRepository";
final OrganizationalUnit orgUnit = mock(OrganizationalUnit.class);
doThrow(new EmptyRemoteRepositoryException(repositoryAlias)).when(importService).getProjects(any(), any());
doThrow(new RuntimeException()).when(libraryService).createProject(any(), anyString(), anyString());
doReturn(repositoryUrl).when(view).getRepositoryURL();
doReturn(Optional.of(orgUnit)).when(projectContext).getActiveOrganizationalUnit();
presenter.importRepository();
verify(view).showError(Mockito.<String>any());
verify(view).hideBusyIndicator();
verify(view, never()).hide();
verify(notificationEvent, never()).fire(any(NotificationEvent.class));
verify(libraryPlaces, never()).goToProject(Mockito.<WorkspaceProject>any());
}
Aggregations