use of org.kie.server.controller.api.model.spec.ContainerConfig in project kie-wb-common by kiegroup.
the class BuildExecutorTest method testMakeConfigsWhenServerTemplateHasProcessCapability.
@Test
public void testMakeConfigsWhenServerTemplateHasProcessCapability() {
final ServerTemplate serverTemplate = mock(ServerTemplate.class);
final RuleConfig ruleConfig = mock(RuleConfig.class);
final ProcessConfig processConfig = mock(ProcessConfig.class);
doReturn(ruleConfig).when(buildExecutor).makeRuleConfig();
doReturn(processConfig).when(buildExecutor).makeProcessConfig(new HashMap<>());
doReturn(true).when(buildExecutor).hasProcessCapability(any());
final Map<Capability, ContainerConfig> configs = buildExecutor.makeConfigs(serverTemplate, new HashMap<>());
assertTrue(configs.keySet().contains(Capability.RULE));
assertTrue(configs.keySet().contains(Capability.PROCESS));
assertTrue(configs.values().contains(ruleConfig));
assertTrue(configs.values().contains(processConfig));
assertEquals(2, configs.size());
}
use of org.kie.server.controller.api.model.spec.ContainerConfig in project kie-wb-common by kiegroup.
the class ServerTemplateVFSStorageTest method createServerTemplateWithContainer.
/*
* helper method to setup template container and container spec
*/
protected void createServerTemplateWithContainer() {
serverTemplate = new ServerTemplate();
serverTemplate.setName("test server");
serverTemplate.setId(UUID.randomUUID().toString());
Map<Capability, ContainerConfig> configs = new HashMap<Capability, ContainerConfig>();
ruleConfig = new RuleConfig();
ruleConfig.setPollInterval(1000l);
ruleConfig.setScannerStatus(KieScannerStatus.STARTED);
configs.put(Capability.RULE, ruleConfig);
processConfig = new ProcessConfig();
processConfig.setKBase("defaultKieBase");
processConfig.setKSession("defaultKieSession");
processConfig.setMergeMode("MERGE_COLLECTION");
processConfig.setRuntimeStrategy("PER_PROCESS_INSTANCE");
configs.put(Capability.PROCESS, processConfig);
containerSpec = new ContainerSpec();
containerSpec.setId("test container");
containerSpec.setServerTemplateKey(new ServerTemplateKey(serverTemplate.getId(), serverTemplate.getName()));
containerSpec.setReleasedId(new ReleaseId("org.kie", "kie-server-kjar", "1.0"));
containerSpec.setStatus(KieContainerStatus.STOPPED);
containerSpec.setConfigs(configs);
serverTemplate.addContainerSpec(containerSpec);
container = new Container();
container.setServerInstanceId(serverTemplate.getId());
container.setServerTemplateId(serverTemplate.getId());
container.setResolvedReleasedId(containerSpec.getReleasedId());
container.setContainerName(containerSpec.getContainerName());
container.setContainerSpecId(containerSpec.getId());
container.setUrl("http://fake.server.net/kie-server");
}
use of org.kie.server.controller.api.model.spec.ContainerConfig in project kie-wb-common by kiegroup.
the class NewContainerWizard method complete.
@Override
public void complete() {
final Map<Capability, ContainerConfig> mapConfig = new HashMap<Capability, ContainerConfig>();
if (getPages().size() == 2) {
mapConfig.put(Capability.PROCESS, processConfigPagePresenter.buildProcessConfig());
}
mapConfig.put(Capability.RULE, new RuleConfig(null, KieScannerStatus.STOPPED));
final ContainerSpec newContainer = newContainerFormPresenter.buildContainerSpec(newContainerFormPresenter.getServerTemplate().getId(), mapConfig);
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()));
}
}, new ErrorCallback<Object>() {
@Override
public boolean error(final Object o, final Throwable throwable) {
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.server.controller.api.model.spec.ContainerConfig in project kie-wb-common by kiegroup.
the class NewServerTemplateWizard method buildServerTemplate.
private ServerTemplate buildServerTemplate() {
final Collection<String> capabilities = new ArrayList<String>();
final Map<Capability, ServerConfig> capabilityConfig = new HashMap<Capability, ServerConfig>();
final Map<Capability, ContainerConfig> capabilityContainerConfig = new HashMap<Capability, ContainerConfig>();
final Collection<ContainerSpec> containersSpec = new ArrayList<ContainerSpec>();
if (newTemplatePresenter.isProcessCapabilityChecked()) {
capabilities.add(Capability.PROCESS.toString());
if (!newContainerFormPresenter.isEmpty()) {
capabilityContainerConfig.put(Capability.PROCESS, processConfigPagePresenter.buildProcessConfig());
}
}
capabilityContainerConfig.put(Capability.RULE, new RuleConfig(null, KieScannerStatus.STOPPED));
if (newTemplatePresenter.isRuleCapabilityChecked()) {
capabilities.add(Capability.RULE.toString());
}
if (newTemplatePresenter.isPlanningCapabilityChecked()) {
capabilities.add(Capability.PLANNING.toString());
}
if (!newContainerFormPresenter.isEmpty()) {
containersSpec.add(newContainerFormPresenter.buildContainerSpec(newTemplatePresenter.getTemplateName(), capabilityContainerConfig));
}
return new ServerTemplate(newTemplatePresenter.getTemplateName(), newTemplatePresenter.getTemplateName(), capabilities, capabilityConfig, containersSpec);
}
use of org.kie.server.controller.api.model.spec.ContainerConfig in project kie-wb-common by kiegroup.
the class ContainerRemoteStatusPresenterTest method testOnServerInstanceUpdatedNewInstance.
@Test
public void testOnServerInstanceUpdatedNewInstance() {
presenter = spy(new ContainerRemoteStatusPresenter(logger, view, presenterProvider));
final ContainerCardPresenter cardPresenter = mock(ContainerCardPresenter.class);
when(cardPresenter.getView()).thenReturn(mock(ContainerCardPresenter.View.class));
final ContainerCardPresenter cardPresenter2 = mock(ContainerCardPresenter.class);
when(cardPresenter2.getView()).thenReturn(mock(ContainerCardPresenter.View.class));
final ContainerCardPresenter cardPresenter3 = mock(ContainerCardPresenter.class);
when(cardPresenter3.getView()).thenReturn(mock(ContainerCardPresenter.View.class));
doReturn(cardPresenter).doReturn(cardPresenter2).doReturn(cardPresenter3).when(presenterProvider).get();
final ServerInstance serverInstance = new ServerInstance("templateId", "serverInstanceId", "serverInstanceId", "url", "1.0", Collections.<Message>emptyList(), Collections.<Container>emptyList());
final Container existingContainer = new Container("containerToBeRemovedSpecId", "containerToBeRemovedName", serverInstance, Collections.<Message>emptyList(), null, null);
existingContainer.setStatus(KieContainerStatus.STARTED);
final ServerInstance newServerInstance = new ServerInstance("templateId", "newserverInstanceId", "newserverInstanceId", "url", "1.0", Collections.<Message>emptyList(), Collections.<Container>emptyList());
final Container newContainer = new Container("containerSpecId", "containerName", newServerInstance, Collections.<Message>emptyList(), null, null);
newContainer.setStatus(KieContainerStatus.STARTED);
newServerInstance.addContainer(newContainer);
presenter.setup(new ContainerSpec("containerSpecId", "containerName", new ServerTemplateKey("templateId", "templateId"), new ReleaseId(), KieContainerStatus.STARTED, Collections.<Capability, ContainerConfig>emptyMap()), Arrays.asList(existingContainer));
verify(cardPresenter).setup(toKey(serverInstance), existingContainer);
presenter.onServerInstanceUpdated(new ServerInstanceUpdated(newServerInstance));
// One container added
verify(cardPresenter2).setup(toKey(newServerInstance), newContainer);
final Container newContainer2 = new Container("containerSpecId", "containerNameX", newServerInstance, Collections.<Message>emptyList(), null, null);
newContainer2.setStatus(KieContainerStatus.STARTED);
newServerInstance.addContainer(newContainer2);
// One new container added to existing server
presenter.onServerInstanceUpdated(new ServerInstanceUpdated(newServerInstance));
verify(cardPresenter3).setup(newContainer2.getServerInstanceKey(), newContainer2);
}
Aggregations