public void select(final String id) { serverTemplateSelectedEvent.fire(new ServerTemplateSelected(new ServerTemplateKey(id, ""))); }
@Override public ServerTemplate store(ServerTemplate serverTemplate) { synchronized (store) { storeKeys.put(serverTemplate.getId(), new ServerTemplateKey(serverTemplate.getId(), serverTemplate.getName())); return store.put(serverTemplate.getId(), serverTemplate); } }
private ContainerSpecKey buildContainerSpecKey( final Container container ) { return new ContainerSpecKey( container.getContainerSpecId(), container.getContainerName(), new ServerTemplateKey( container.getServerInstanceKey().getServerTemplateId(), "" ) ); } }
@Override public ServerTemplate update(ServerTemplate serverTemplate) { ServerTemplate updated = null; synchronized (templateMap) { templateKeyMap.put(serverTemplate.getId(), new ServerTemplateKey(serverTemplate.getId(),serverTemplate.getName())); updated = templateMap.put(serverTemplate.getId(),serverTemplate); writeTemplateMap(); } return updated; }
@Override public ServerTemplate store(ServerTemplate serverTemplate) { ServerTemplate template = null; synchronized (templateMap) { templateKeyMap.put(serverTemplate.getId(), new ServerTemplateKey(serverTemplate.getId(), serverTemplate.getName())); template = templateMap.put(serverTemplate.getId(), serverTemplate); writeTemplateMap(); } return template; }
private ContainerSpec copy(final ContainerSpec origin, final String newServerTemplateId, final String newServerTemplateName) { final Map<Capability, ContainerConfig> configMap = origin.getConfigs(); for (Map.Entry<Capability, ContainerConfig> entry : origin.getConfigs().entrySet()) { configMap.put(entry.getKey(), copy(entry.getValue())); } return new ContainerSpec(origin.getId(), origin.getContainerName(), new ServerTemplateKey(newServerTemplateId, newServerTemplateName), new ReleaseId(origin.getReleasedId()), origin.getStatus(), configMap); }
public ContainerSpec buildContainerSpec(final String serverTemplateId, final Map<Capability, ContainerConfig> configs) { return new ContainerSpec(view.getContainerName(), view.getContainerAlias(), new ServerTemplateKey(serverTemplateId, null), new ReleaseId(view.getGroupId(), view.getArtifactId(), view.getVersion()), view.isStartContainer() ? KieContainerStatus.STARTED : KieContainerStatus.STOPPED, configs); }
@BeforeClass public static void beforeClass() { templateMap = Maps.newConcurrentMap(); for (int x = 0; x < 3; x++) { StringBuilder templateName = new StringBuilder("test server : ").append(x); ServerTemplate template = createServerTemplateWithContainer(templateName.toString(),x+1); ServerTemplateKey key = new ServerTemplateKey(template.getId(), template.getName()); templateMap.put(key, template); } }
@Test public void testRefresh() { final ContainerSpecKey containerSpecKey = new ContainerSpecKey( "id", "name", new ServerTemplateKey() ); presenter.setup( containerSpecKey ); presenter.refresh(); final ArgumentCaptor<RefreshRemoteServers> refreshRemoteServersCaptor = ArgumentCaptor.forClass( RefreshRemoteServers.class ); verify( refreshRemoteServersEvent ).fire( refreshRemoteServersCaptor.capture() ); assertEquals( containerSpecKey, refreshRemoteServersCaptor.getValue().getContainerSpecKey() ); }
@Test public void testOnOpen() { final ServerTemplateKey serverTemplateKey = new ServerTemplateKey( "ServerTemplateKeyId", "ServerTemplateKeyName" ); final List<ServerTemplateKey> serverTemplateKeys = Collections.singletonList( serverTemplateKey ); when( specManagementService.listServerTemplateKeys() ).thenReturn( new ServerTemplateKeyList(serverTemplateKeys) ); presenter.onOpen(); verify( navigationPresenter ).setup( serverTemplateKey, serverTemplateKeys ); final ArgumentCaptor<ServerTemplateSelected> templateSelectedCaptor = ArgumentCaptor.forClass( ServerTemplateSelected.class ); verify( serverTemplateSelectedEvent ).fire( templateSelectedCaptor.capture() ); assertEquals( serverTemplateKey, templateSelectedCaptor.getValue().getServerTemplateKey() ); }
@Test public void testOnServerDeleted() { final ServerTemplateKey serverTemplateKey = new ServerTemplateKey( "ServerTemplateKeyId", "ServerTemplateKeyName" ); final List<ServerTemplateKey> serverTemplateKeys = Collections.singletonList( serverTemplateKey ); when( specManagementService.listServerTemplateKeys() ).thenReturn( new ServerTemplateKeyList(serverTemplateKeys) ); presenter.onServerDeleted( new ServerTemplateDeleted() ); verify( navigationPresenter ).setup( serverTemplateKey, serverTemplateKeys ); final ArgumentCaptor<ServerTemplateSelected> templateSelectedCaptor = ArgumentCaptor.forClass( ServerTemplateSelected.class ); verify( serverTemplateSelectedEvent ).fire( templateSelectedCaptor.capture() ); assertEquals( serverTemplateKey, templateSelectedCaptor.getValue().getServerTemplateKey() ); }
@Test //Test fix for GUVNOR-3579 public void testLoadWhenRuntimeManagementServiceReturnsInvalidData() { ContainerSpecData badData = new ContainerSpecData(null, null); when(runtimeManagementService.getContainersByContainerSpec(anyObject(), anyObject())).thenReturn(badData); ContainerSpecKey lookupKey = new ContainerSpecKey("dummyId", "dummyName", new ServerTemplateKey("keyId", "keyName")); presenter.load(lookupKey); // Doesn't throw NPE when ContainerSpecData contain nulls verify(view, never()).setContainerName(anyString()); }
private ContainerSpec makeContainerSpec(final String containerId, final String containerAlias, final ServerTemplate serverTemplate, final Map<String, String> parameters) { final ReleaseId releaseId = makeReleaseId(); final KieContainerStatus status = KieContainerStatus.STOPPED; final ServerTemplateKey serverTemplateKey = new ServerTemplateKey(serverTemplate.getId(), serverTemplate.getId()); return new ContainerSpec(containerId, containerAlias, serverTemplateKey, releaseId, status, makeConfigs(serverTemplate, parameters)); }
@Test public void testSetupList() { final ServerTemplateKey serverTemplateKey = new ServerTemplateKey( "ServerTemplateKeyId", "ServerTemplateKeyName" ); final ServerTemplateKey serverTemplateKey2 = new ServerTemplateKey( "ServerTemplateKeyId2", "ServerTemplateKeyName2" ); presenter.setup( serverTemplateKey, Collections.singletonList( serverTemplateKey2 ) ); verify( view ).clean(); verify( view ).addTemplate( serverTemplateKey.getId(), serverTemplateKey.getName() ); verify( view ).addTemplate( serverTemplateKey2.getId(), serverTemplateKey2.getName() ); }
@Test public void testSetup() { final ContainerSpecKey containerSpecKey = new ContainerSpecKey( "id", "container-name", new ServerTemplateKey( "template-id", "template-name" ) ); final ProcessConfig processConfig = new ProcessConfig( RuntimeStrategy.PER_REQUEST.toString(), "kbase", "ksession", MergeMode.KEEP_ALL.toString() ); presenter.setup( containerSpecKey, processConfig ); verify( view ).enableActions(); verify( processConfigPresenter ).setup( containerSpecKey, processConfig ); verify( processConfigPresenter ).setProcessConfig( processConfig ); }
@Test public void testSetup() { final ServerTemplateKey serverTemplateKey = new ServerTemplateKey( "ServerTemplateKeyId", "ServerTemplateKeyName" ); presenter.setup( serverTemplateKey, Collections.singletonList( serverTemplateKey ) ); verify( view ).clean(); verify( view ).addTemplate( serverTemplateKey.getId(), serverTemplateKey.getName() ); }
@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() ); }
@Test public void testOnSelectedServerTemplate() { final ServerTemplate serverTemplate = new ServerTemplate( "ServerTemplateId", "ServerTemplateName" ); 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 ); final ServerContainerEmptyPresenter.View serverEmptyView = mock( ServerContainerEmptyPresenter.View.class ); when( serverContainerEmptyPresenter.getView() ).thenReturn( serverEmptyView ); presenter.onSelected( new ServerTemplateSelected( serverTemplateKey ) ); verify( view ).setServerTemplate( serverView ); verify( specManagementService ).getServerTemplate( serverTemplateKey.getId() ); verify( serverContainerEmptyPresenter ).setTemplate( serverTemplate ); verify( view ).setContent( serverEmptyView ); verify( serverTemplatePresenter ).setup( serverTemplate, null ); }
@Test public void testOnSelect() { final ServerTemplateKey serverTemplateKey = new ServerTemplateKey( "ServerTemplateKeyId", "ServerTemplateKeyName" ); presenter.onSelect( new ServerTemplateSelected( serverTemplateKey ) ); verify( view ).select( serverTemplateKey.getId() ); }
@Test public void testOnContainerSelect() { final ServerTemplateKey serverTemplateKey = new ServerTemplateKey( "ServerTemplateKeyId", "ServerTemplateKeyName" ); final ContainerSpecKey containerSpecKey = new ContainerSpecKey( "containerId", "containerName", serverTemplateKey ); presenter.onContainerSelect( new ContainerSpecSelected( containerSpecKey ) ); verify( view ).selectContainer( serverTemplateKey.getId(), containerSpecKey.getId() ); }