use of org.kie.server.controller.api.model.spec.ServerTemplate in project kie-wb-common by kiegroup.
the class ServerTemplatePresenterTest method testOnServerInstanceUpdated.
@Test
public void testOnServerInstanceUpdated() {
final ServerTemplate serverTemplate = new ServerTemplate("ServerTemplateId", "ServerTemplateName");
presenter.setup(serverTemplate, null);
assertEquals(serverTemplate, presenter.getCurrentServerTemplate());
final ServerInstance serverInstance = new ServerInstance(serverTemplate.getId(), "serverName", "serverInstanceId", "url", "1.0", Collections.<Message>emptyList(), Collections.<Container>emptyList());
presenter.onServerInstanceUpdated(new ServerInstanceUpdated(serverInstance));
presenter.onServerInstanceUpdated(new ServerInstanceUpdated(serverInstance));
verify(view).addServerInstance(eq(serverInstance.getServerTemplateId()), eq(serverInstance.getServerInstanceId()), eq(serverInstance.getServerName()), any(Command.class));
presenter.onServerInstanceDeleted(new ServerInstanceDeleted(serverInstance.getServerInstanceId()));
presenter.onServerInstanceUpdated(new ServerInstanceUpdated(serverInstance));
verify(view, times(2)).addServerInstance(eq(serverInstance.getServerTemplateId()), eq(serverInstance.getServerInstanceId()), eq(serverInstance.getServerName()), any(Command.class));
}
use of org.kie.server.controller.api.model.spec.ServerTemplate in project kie-wb-common by kiegroup.
the class ServerTemplatePresenterTest method testSetup.
@Test
public void testSetup() {
final ServerTemplate serverTemplate = new ServerTemplate("ServerTemplateKeyId", "ServerTemplateKeyName");
final ServerInstanceKey serverInstanceKey = new ServerInstanceKey("serverTemplateId", "serverName", "serverInstanceId", "url");
serverTemplate.addServerInstance(serverInstanceKey);
final ReleaseId releaseId = new ReleaseId("org.kie", "container", "1.0.0");
final ContainerSpec containerSpec = new ContainerSpec("containerId", "containerName", serverTemplate, releaseId, KieContainerStatus.CREATING, null);
serverTemplate.addContainerSpec(containerSpec);
final ContainerSpec containerSpec1 = new ContainerSpec("containerId1", "containerName1", serverTemplate, new ReleaseId("org.kie", "container2", "1.0.0"), KieContainerStatus.CREATING, null);
serverTemplate.addContainerSpec(containerSpec1);
presenter.setup(serverTemplate, containerSpec);
assertEquals(serverTemplate, presenter.getCurrentServerTemplate());
verify(view).clear();
verify(view).setTemplate(serverTemplate.getId(), serverTemplate.getName());
verify(view).setProcessCapability(false);
verify(view).setRulesCapability(false);
verify(view).setPlanningCapability(false);
verify(view).addContainer(eq(containerSpec.getServerTemplateKey().getId()), eq(containerSpec.getId()), eq(containerSpec.getContainerName()), any(Command.class));
verify(view).addContainer(eq(containerSpec1.getServerTemplateKey().getId()), eq(containerSpec1.getId()), eq(containerSpec1.getContainerName()), any(Command.class));
final ArgumentCaptor<ContainerSpecSelected> selectedCaptor = ArgumentCaptor.forClass(ContainerSpecSelected.class);
verify(containerSpecSelectedEvent).fire(selectedCaptor.capture());
assertEquals(containerSpec, selectedCaptor.getValue().getContainerSpecKey());
verify(view).addServerInstance(eq(serverInstanceKey.getServerTemplateId()), eq(serverInstanceKey.getServerInstanceId()), eq(serverInstanceKey.getServerName()), any(Command.class));
}
use of org.kie.server.controller.api.model.spec.ServerTemplate 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();
}
use of org.kie.server.controller.api.model.spec.ServerTemplate in project kie-wb-common by kiegroup.
the class NewContainerFormPresenterTest method testOnDependencyPathSelectedEventWithDefaultContainerNameWhenContainerNameIsNotEmpty.
@Test
public void testOnDependencyPathSelectedEventWithDefaultContainerNameWhenContainerNameIsNotEmpty() {
final String path = "org:kie:1.0";
final String templateId = "templateId";
final GAV gav = new GAV(path);
final ServerTemplate serverTemplate = mock(ServerTemplate.class);
when(serverTemplate.getId()).thenReturn(templateId);
when(m2RepoService.loadGAVFromJar(path)).thenReturn(gav);
when(specManagementService.validContainerId(templateId, path)).thenReturn(path);
when(view.getContainerName()).thenReturn("custom");
presenter.setServerTemplate(serverTemplate);
presenter.asWidget();
presenter.onDependencyPathSelectedEvent(new DependencyPathSelectedEvent(artifactListWidgetPresenter, path));
verify(view, never()).setContainerName(path);
}
use of org.kie.server.controller.api.model.spec.ServerTemplate in project kie-wb-common by kiegroup.
the class NewContainerFormPresenterTest method testIsValid.
@Test
public void testIsValid() {
when(view.getContainerName()).thenReturn(" ").thenReturn("containerName").thenReturn("");
when(view.getGroupId()).thenReturn(" ").thenReturn("groupId").thenReturn("");
when(view.getArtifactId()).thenReturn(" ").thenReturn("artifactId").thenReturn("");
when(view.getVersion()).thenReturn(" ").thenReturn("1.0").thenReturn("");
assertTrue(presenter.isValid());
verify(view).noErrors();
presenter.setServerTemplate(new ServerTemplate());
assertTrue(presenter.isValid());
verify(view).noErrorOnContainerName();
verify(view).noErrorOnGroupId();
verify(view).noErrorOnArtifactId();
verify(view).noErrorOnVersion();
assertFalse(presenter.isValid());
verify(view).errorOnContainerName();
verify(view).errorOnGroupId();
verify(view).errorOnArtifactId();
verify(view).errorOnVersion();
}
Aggregations