use of org.kie.workbench.common.screens.server.management.client.events.ServerTemplateSelected in project kie-wb-common by kiegroup.
the class ServerManagementBrowserPresenterTest method testOnDelete.
@Test
public void testOnDelete() {
final ServerInstanceKey serverInstanceKey = new ServerInstanceKey("serverInstanceKeyId", "serverName", "serverInstanceId", "url");
final ServerTemplate serverTemplate = new ServerTemplate("ServerTemplateId", "ServerTemplateName");
serverTemplate.addServerInstance(serverInstanceKey);
when(serverTemplatePresenter.getCurrentServerTemplate()).thenReturn(serverTemplate);
final ServerTemplateKey serverTemplateKey = new ServerTemplateKey("ServerTemplateKeyId", "ServerTemplateKeyName");
final List<ServerTemplateKey> serverTemplateKeys = Collections.singletonList(serverTemplateKey);
when(specManagementService.listServerTemplateKeys()).thenReturn(new ServerTemplateKeyList(serverTemplateKeys));
presenter.onDelete(new ServerInstanceDeleted(serverInstanceKey.getServerInstanceId()));
verify(navigationPresenter).setup(serverTemplateKey, serverTemplateKeys);
final ArgumentCaptor<ServerTemplateSelected> templateSelectedCaptor = ArgumentCaptor.forClass(ServerTemplateSelected.class);
verify(serverTemplateSelectedEvent).fire(templateSelectedCaptor.capture());
assertEquals(serverTemplateKey, templateSelectedCaptor.getValue().getServerTemplateKey());
}
use of org.kie.workbench.common.screens.server.management.client.events.ServerTemplateSelected in project kie-wb-common by kiegroup.
the class ServerManagementBrowserPresenterTest method testOnSelectedNonEmptyServerTemplate.
@Test
public void testOnSelectedNonEmptyServerTemplate() {
final ServerTemplate serverTemplate = new ServerTemplate("ServerTemplateId", "ServerTemplateName");
final ContainerSpec toBeSelected = mock(ContainerSpec.class);
serverTemplate.addContainerSpec(toBeSelected);
when(toBeSelected.getId()).thenReturn("other-id");
final ContainerSpec forcedToBeSelected = mock(ContainerSpec.class);
when(forcedToBeSelected.getId()).thenReturn("container-id");
serverTemplate.addContainerSpec(forcedToBeSelected);
final ServerTemplateKey serverTemplateKey = new ServerTemplateKey("ServerTemplateKeyId", "ServerTemplateKeyName");
when(specManagementService.getServerTemplate(serverTemplateKey.getId())).thenReturn(serverTemplate);
final ServerTemplatePresenter.View serverView = mock(ServerTemplatePresenter.View.class);
when(serverTemplatePresenter.getView()).thenReturn(serverView);
presenter.onSelected(new ServerTemplateSelected(serverTemplateKey));
verify(view).setServerTemplate(serverView);
verify(specManagementService).getServerTemplate(serverTemplateKey.getId());
verify(serverTemplatePresenter).setup(serverTemplate, toBeSelected);
presenter.onSelected(new ServerTemplateSelected(serverTemplateKey, "container-id"));
verify(serverTemplatePresenter).setup(serverTemplate, forcedToBeSelected);
}
use of org.kie.workbench.common.screens.server.management.client.events.ServerTemplateSelected in project kie-wb-common by kiegroup.
the class ContainerPresenterTest method testRemoveContainer.
@Test
public void testRemoveContainer() {
doAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
final Command command = (Command) invocation.getArguments()[0];
if (command != null) {
command.execute();
}
return null;
}
}).when(view).confirmRemove(any(Command.class));
final String successMessage = "SUCCESS";
when(view.getRemoveContainerSuccessMessage()).thenReturn(successMessage);
presenter.loadContainers(containerSpecData);
presenter.removeContainer();
verify(specManagementService).deleteContainerSpec(serverTemplateKey.getId(), containerSpec.getId());
final ArgumentCaptor<NotificationEvent> notificationCaptor = ArgumentCaptor.forClass(NotificationEvent.class);
verify(notification).fire(notificationCaptor.capture());
final NotificationEvent event = notificationCaptor.getValue();
assertEquals(NotificationEvent.NotificationType.SUCCESS, event.getType());
assertEquals(successMessage, event.getNotification());
final ArgumentCaptor<ServerTemplateSelected> serverTemplateSelectedCaptor = ArgumentCaptor.forClass(ServerTemplateSelected.class);
verify(serverTemplateSelectedEvent).fire(serverTemplateSelectedCaptor.capture());
assertEquals(serverTemplateKey.getId(), serverTemplateSelectedCaptor.getValue().getServerTemplateKey().getId());
final String errorMessage = "ERROR";
when(view.getRemoveContainerErrorMessage()).thenReturn(errorMessage);
doThrow(new RuntimeException()).when(specManagementService).deleteContainerSpec(serverTemplateKey.getId(), containerSpec.getId());
presenter.removeContainer();
verify(notification).fire(new NotificationEvent(errorMessage, NotificationEvent.NotificationType.ERROR));
verify(serverTemplateSelectedEvent, times(2)).fire(new ServerTemplateSelected(containerSpec.getServerTemplateKey()));
}
use of org.kie.workbench.common.screens.server.management.client.events.ServerTemplateSelected in project kie-wb-common by kiegroup.
the class NewContainerWizard method saveContainerSpec.
protected void saveContainerSpec(final ContainerSpec newContainer) {
newContainerFormPresenter.showBusyIndicator(newContainer.getReleasedId().toString());
specManagementService.call(new RemoteCallback<Void>() {
@Override
public void callback(final Void o) {
notification.fire(new NotificationEvent(newContainerFormPresenter.getView().getNewContainerWizardSaveSuccess(), NotificationEvent.NotificationType.SUCCESS));
clear();
NewContainerWizard.super.complete();
serverTemplateSelectedEvent.fire(new ServerTemplateSelected(serverTemplate, newContainer.getId()));
newContainerFormPresenter.hideBusyIndicator();
}
}, new ErrorCallback<Object>() {
@Override
public boolean error(final Object o, final Throwable throwable) {
newContainerFormPresenter.hideBusyIndicator();
notification.fire(new NotificationEvent(newContainerFormPresenter.getView().getNewContainerWizardSaveError(), NotificationEvent.NotificationType.ERROR));
NewContainerWizard.this.pageSelected(0);
NewContainerWizard.this.start();
return false;
}
}).saveContainerSpec(newContainerFormPresenter.getServerTemplate().getId(), newContainer);
}
use of org.kie.workbench.common.screens.server.management.client.events.ServerTemplateSelected in project kie-wb-common by kiegroup.
the class ServerNavigationPresenterTest method testOnSelect.
@Test
public void testOnSelect() {
final ServerTemplateKey serverTemplateKey = new ServerTemplateKey("ServerTemplateKeyId", "ServerTemplateKeyName");
presenter.onSelect(new ServerTemplateSelected(serverTemplateKey));
verify(view).select(serverTemplateKey.getId());
}
Aggregations