use of org.uberfire.workbench.events.NotificationEvent in project kie-wb-common by kiegroup.
the class ContainerRulesConfigPresenterTest method testStopScannerError.
@Test
public void testStopScannerError() {
doThrow(new RuntimeException()).when(ruleCapabilitiesService).stopScanner(eq(containerSpec));
when(view.getStopScannerErrorMessage()).thenReturn("ERROR");
presenter.setup(containerSpec, ruleConfig);
presenter.stopScanner();
verify(notification).fire(new NotificationEvent("ERROR", NotificationEvent.NotificationType.ERROR));
verify(view).setStartScannerState(State.ENABLED);
verify(view).setStopScannerState(State.DISABLED);
verify(view).setScanNowState(State.ENABLED);
verify(view).setUpgradeState(State.ENABLED);
}
use of org.uberfire.workbench.events.NotificationEvent in project kie-wb-common by kiegroup.
the class ContainerRulesConfigPresenterTest method testUpgrade.
@Test
public void testUpgrade() {
final String version = "1.0";
presenter.setup(containerSpec, ruleConfig);
presenter.upgrade(version);
verify(view).disableActions();
final ArgumentCaptor<ReleaseId> releaseIdCaptor = ArgumentCaptor.forClass(ReleaseId.class);
verify(ruleCapabilitiesService).upgradeContainer(eq(containerSpec), releaseIdCaptor.capture());
assertEquals(version, releaseIdCaptor.getValue().getVersion());
verify(view).setStartScannerState(State.ENABLED);
verify(view).setStopScannerState(State.DISABLED);
verify(view).setScanNowState(State.ENABLED);
verify(view).setUpgradeState(State.ENABLED);
verify(notification).fire(new NotificationEvent(SUCCESS_UPGRADE, NotificationEvent.NotificationType.SUCCESS));
}
use of org.uberfire.workbench.events.NotificationEvent in project kie-wb-common by kiegroup.
the class ContainerRulesConfigPresenterTest method testScanNowError.
@Test
public void testScanNowError() {
doThrow(new RuntimeException()).when(ruleCapabilitiesService).scanNow(eq(containerSpec));
when(view.getScanNowErrorMessage()).thenReturn("ERROR");
presenter.setup(containerSpec, ruleConfig);
presenter.scanNow();
verify(notification).fire(new NotificationEvent("ERROR", NotificationEvent.NotificationType.ERROR));
verify(view).setStartScannerState(State.ENABLED);
verify(view).setStopScannerState(State.DISABLED);
verify(view).setScanNowState(State.ENABLED);
verify(view).setUpgradeState(State.ENABLED);
}
use of org.uberfire.workbench.events.NotificationEvent in project kie-wb-common by kiegroup.
the class NewContainerWizardTest method testCompleteByCanNotFind.
@Test
public void testCompleteByCanNotFind() {
final ServerTemplate serverTemplate = new ServerTemplate("ServerTemplateId", "ServerTemplateName");
serverTemplate.getCapabilities().add(Capability.PROCESS.toString());
final ContainerSpec containerSpec = new ContainerSpec();
containerSpec.setId("containerSpecId");
PageResponse<JarListPageRow> response = new PageResponse<JarListPageRow>();
JarListPageRow jarListPageRow = new JarListPageRow();
GAV gav = new GAV("test", "test", "1.0");
containerSpec.setReleasedId(new ReleaseId(gav.getGroupId(), gav.getArtifactId(), gav.getVersion()));
jarListPageRow.setGav(new GAV("test1", "test1", "2.0"));
jarListPageRow.setPath("test_path");
response.setPageRowList(Arrays.asList(jarListPageRow));
when(m2RepoService.listArtifacts(any())).thenReturn(response);
when(newContainerFormPresenter.buildContainerSpec(eq(serverTemplate.getId()), anyMap())).thenReturn(containerSpec);
when(newContainerFormPresenter.getServerTemplate()).thenReturn(serverTemplate);
final String successMessage = "SUCCESS";
doNothing().when(specManagementService).saveContainerSpec(anyString(), any(ContainerSpec.class));
when(newContainerFormPresenterView.getNewContainerWizardSaveSuccess()).thenReturn(successMessage);
newContainerWizard.setServerTemplate(serverTemplate);
newContainerWizard.complete();
verify(processConfigPagePresenter).buildProcessConfig();
verify(newContainerFormPresenter).buildContainerSpec(eq(serverTemplate.getId()), anyMap());
ArgumentCaptor<Command> captureCommand = ArgumentCaptor.forClass(Command.class);
verify(confirmPopup).show(any(), any(), any(), captureCommand.capture());
captureCommand.getValue().execute();
final ArgumentCaptor<NotificationEvent> eventCaptor = ArgumentCaptor.forClass(NotificationEvent.class);
verify(notification).fire(eventCaptor.capture());
final NotificationEvent event = eventCaptor.getValue();
assertEquals(successMessage, event.getNotification());
assertEquals(NotificationEvent.NotificationType.SUCCESS, event.getType());
final ArgumentCaptor<ServerTemplateSelected> serverTemplateEventCaptor = ArgumentCaptor.forClass(ServerTemplateSelected.class);
verify(serverTemplateSelectedEvent).fire(serverTemplateEventCaptor.capture());
final ServerTemplateSelected serverEvent = serverTemplateEventCaptor.getValue();
assertEquals(serverTemplate, serverEvent.getServerTemplateKey());
assertEquals(containerSpec.getId(), serverEvent.getContainerId());
verifyClear();
}
use of org.uberfire.workbench.events.NotificationEvent in project kie-wb-common by kiegroup.
the class NewContainerWizardTest method testPageSelectedCanNotFind.
@Test
public void testPageSelectedCanNotFind() {
PageResponse<JarListPageRow> response = new PageResponse<JarListPageRow>();
JarListPageRow jarListPageRow = new JarListPageRow();
GAV gav = new GAV("test", "test", "");
jarListPageRow.setGav(new GAV("test1", "test1", "1.0"));
jarListPageRow.setPath("test_path");
response.setPageRowList(Arrays.asList(jarListPageRow));
when(m2RepoService.listArtifacts(any())).thenReturn(response);
when(newContainerFormPresenter.getCurrentGAV()).thenReturn(gav);
final String gavNotFind = "NOTFIND";
when(newContainerFormPresenterView.getNewContainerGAVNotExist(any())).thenReturn(gavNotFind);
newContainerWizard.pages.add(mock(WizardPage.class));
newContainerWizard.pages.add(mock(WizardPage.class));
newContainerWizard.pageSelected(1);
final ArgumentCaptor<NotificationEvent> eventCaptor = ArgumentCaptor.forClass(NotificationEvent.class);
verify(notification).fire(eventCaptor.capture());
final NotificationEvent event = eventCaptor.getValue();
assertEquals(gavNotFind, event.getNotification());
}
Aggregations