use of org.kie.workbench.common.screens.server.management.client.events.ServerTemplateSelected in project kie-wb-common by kiegroup.
the class NewContainerWizardTest method testComplete.
@Test
public void testComplete() {
final ServerTemplate serverTemplate = new ServerTemplate("ServerTemplateId", "ServerTemplateName");
serverTemplate.getCapabilities().add(Capability.PROCESS.toString());
final ContainerSpec containerSpec = new ContainerSpec();
containerSpec.setId("containerSpecId");
when(newContainerFormPresenter.buildContainerSpec(eq(serverTemplate.getId()), anyMap())).thenReturn(containerSpec);
when(newContainerFormPresenter.getServerTemplate()).thenReturn(serverTemplate);
final String successMessage = "SUCCESS";
when(newContainerFormPresenterView.getNewContainerWizardSaveSuccess()).thenReturn(successMessage);
newContainerWizard.setServerTemplate(serverTemplate);
newContainerWizard.complete();
verify(processConfigPagePresenter).buildProcessConfig();
verify(newContainerFormPresenter).buildContainerSpec(eq(serverTemplate.getId()), anyMap());
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();
doThrow(new RuntimeException()).when(specManagementService).saveContainerSpec(anyString(), any(ContainerSpec.class));
final String errorMessage = "ERROR";
when(newContainerFormPresenterView.getNewContainerWizardSaveError()).thenReturn(errorMessage);
newContainerWizard.complete();
verify(notification).fire(new NotificationEvent(errorMessage, NotificationEvent.NotificationType.ERROR));
verify(newContainerWizard).pageSelected(0);
verify(newContainerWizard).start();
verify(newContainerFormPresenter).initialise();
}
Aggregations