use of org.kie.workbench.common.screens.server.management.client.events.ServerTemplateListRefresh in project kie-wb-common by kiegroup.
the class ServerTemplatePresenterTest method testCopyTemplate.
@Test
public void testCopyTemplate() {
final String newTemplateName = "NewTemplateName";
doAnswer(new Answer<Void>() {
@Override
public Void answer(final InvocationOnMock invocation) throws Throwable {
final ParameterizedCommand command = (ParameterizedCommand) invocation.getArguments()[0];
if (command != null) {
command.execute(newTemplateName);
}
return null;
}
}).when(copyPresenter).copy(any(ParameterizedCommand.class));
final ServerTemplate serverTemplate = new ServerTemplate("ServerTemplateKeyId", "ServerTemplateKeyName");
presenter.setup(serverTemplate, null);
assertEquals(serverTemplate, presenter.getCurrentServerTemplate());
presenter.copyTemplate();
verify(specManagementService).copyServerTemplate(serverTemplate.getId(), newTemplateName, newTemplateName);
verify(copyPresenter).hide();
final ArgumentCaptor<ServerTemplateListRefresh> serverTemplateCaptor = ArgumentCaptor.forClass(ServerTemplateListRefresh.class);
verify(serverTemplateListRefreshEvent).fire(serverTemplateCaptor.capture());
assertEquals(newTemplateName, serverTemplateCaptor.getValue().getSelectServerTemplateId());
doThrow(new RuntimeException()).when(specManagementService).copyServerTemplate(serverTemplate.getId(), newTemplateName, newTemplateName);
presenter.copyTemplate();
verify(specManagementService, times(2)).copyServerTemplate(serverTemplate.getId(), newTemplateName, newTemplateName);
verify(copyPresenter).errorDuringProcessing(anyString());
}
use of org.kie.workbench.common.screens.server.management.client.events.ServerTemplateListRefresh in project kie-wb-common by kiegroup.
the class NewServerTemplateWizard method complete.
@Override
public void complete() {
final ServerTemplate newServerTemplate = buildServerTemplate();
specManagementService.call(new RemoteCallback<Void>() {
@Override
public void callback(final Void o) {
notification.fire(new NotificationEvent(newTemplatePresenter.getView().getNewServerTemplateWizardSaveSuccess(), NotificationEvent.NotificationType.SUCCESS));
clear();
NewServerTemplateWizard.super.complete();
serverTemplateListRefreshEvent.fire(new ServerTemplateListRefresh(newServerTemplate.getId()));
}
}, new ErrorCallback<Object>() {
@Override
public boolean error(final Object o, final Throwable throwable) {
notification.fire(new NotificationEvent(newTemplatePresenter.getView().getNewServerTemplateWizardSaveError(), NotificationEvent.NotificationType.ERROR));
NewServerTemplateWizard.this.pageSelected(0);
NewServerTemplateWizard.this.start();
return false;
}
}).saveServerTemplate(newServerTemplate);
}
use of org.kie.workbench.common.screens.server.management.client.events.ServerTemplateListRefresh in project kie-wb-common by kiegroup.
the class NewServerTemplateWizardTest method testComplete.
@Test
public void testComplete() {
when(newTemplatePresenter.isProcessCapabilityChecked()).thenReturn(true);
when(newContainerFormPresenter.isEmpty()).thenReturn(true);
when(newContainerFormPresenter.isEmpty()).thenReturn(true);
when(newTemplatePresenter.getTemplateName()).thenReturn("template-name");
final String successMessage = "SUCCESS";
when(newTemplatePresenterView.getNewServerTemplateWizardSaveSuccess()).thenReturn(successMessage);
newServerTemplateWizard.complete();
verify(notification).fire(new NotificationEvent(successMessage, NotificationEvent.NotificationType.SUCCESS));
verifyClear();
verify(serverTemplateListRefreshEvent).fire(new ServerTemplateListRefresh("template-name"));
doThrow(new RuntimeException()).when(specManagementService).saveServerTemplate(any(ServerTemplate.class));
final String errorMessage = "ERROR";
when(newTemplatePresenterView.getNewServerTemplateWizardSaveError()).thenReturn(errorMessage);
newServerTemplateWizard.complete();
verify(notification).fire(new NotificationEvent(errorMessage, NotificationEvent.NotificationType.ERROR));
verify(newServerTemplateWizard).pageSelected(0);
verify(newServerTemplateWizard).start();
verify(newContainerFormPresenter).initialise();
}
Aggregations