@Test public void testGetContainersRemoteOperationWhenResponseTypeIsNotSUCCESS() { doReturn(containerResource).when(response).getResult(); doReturn(response).when(client).getContainerInfo(any()); doReturn(ServiceResponse.ResponseType.FAILURE).when(response).getType(); final KieServerInstanceManager.RemoteKieServerOperation<Void> operation = instanceManager.getContainersRemoteOperation(serverTemplate, containerSpec); operation.doOperation(client, container); verify(container, never()).setContainerSpecId(any()); verify(container, never()).setContainerName(any()); verify(container, never()).setResolvedReleasedId(any()); verify(container, never()).setServerTemplateId(any()); verify(container, never()).setStatus(any()); verify(container, never()).setMessages(any()); }
RemoteKieServerOperation<Void> getContainersRemoteOperation(final ServerTemplate serverTemplate, final ContainerSpec containerSpec) { return new RemoteKieServerOperation<Void>() { @Override public Void doOperation(KieServicesClient client, Container container) { final ServiceResponse<KieContainerResource> response = client.getContainerInfo(containerSpec.getId()); final KieContainerResource containerResource = response.getResult(); if (response.getType().equals(ServiceResponse.ResponseType.SUCCESS)) { container.setContainerSpecId(containerResource.getContainerId()); container.setContainerName(containerResource.getContainerAlias()); container.setResolvedReleasedId(containerResource.getResolvedReleaseId() == null ? containerResource.getReleaseId() : containerResource.getResolvedReleaseId()); container.setServerTemplateId(serverTemplate.getId()); container.setStatus(containerResource.getStatus()); container.setMessages(containerResource.getMessages()); } return null; } }; }
KieServerInstanceManager { RemoteKieServerOperation<Void> getContainersRemoteOperation(final ServerTemplate serverTemplate, final ContainerSpec containerSpec) { return new RemoteKieServerOperation<Void>() { @Override public Void doOperation(KieServicesClient client, Container container) { final ServiceResponse<KieContainerResource> response = client.getContainerInfo(containerSpec.getId()); final KieContainerResource containerResource = response.getResult(); if (response.getType().equals(ServiceResponse.ResponseType.SUCCESS)) { container.setContainerSpecId(containerResource.getContainerId()); container.setContainerName(containerResource.getContainerAlias()); container.setResolvedReleasedId(containerResource.getResolvedReleaseId() == null ? containerResource.getReleaseId() : containerResource.getResolvedReleaseId()); container.setServerTemplateId(serverTemplate.getId()); container.setStatus(containerResource.getStatus()); container.setMessages(containerResource.getMessages()); } return null; } }; } }
KieServerInstanceManager { RemoteKieServerOperation<Void> getContainersRemoteOperation(final ServerTemplate serverTemplate, final ContainerSpec containerSpec) { return new RemoteKieServerOperation<Void>() { @Override public Void doOperation(KieServicesClient client, Container container) { final ServiceResponse<KieContainerResource> response = client.getContainerInfo(containerSpec.getId()); final KieContainerResource containerResource = response.getResult(); if (response.getType().equals(ServiceResponse.ResponseType.SUCCESS)) { container.setContainerSpecId(containerResource.getContainerId()); container.setContainerName(containerResource.getContainerAlias()); container.setResolvedReleasedId(containerResource.getResolvedReleaseId() == null ? containerResource.getReleaseId() : containerResource.getResolvedReleaseId()); container.setServerTemplateId(serverTemplate.getId()); container.setStatus(containerResource.getStatus()); container.setMessages(containerResource.getMessages()); } return null; } }; } KieServerInstanceManager(); }
KieServerInstanceManager { RemoteKieServerOperation<Void> getContainersRemoteOperation(final ServerTemplate serverTemplate, final ContainerSpec containerSpec) { return new RemoteKieServerOperation<Void>() { @Override public Void doOperation(KieServicesClient client, Container container) { final ServiceResponse<KieContainerResource> response = client.getContainerInfo(containerSpec.getId()); final KieContainerResource containerResource = response.getResult(); if (response.getType().equals(ServiceResponse.ResponseType.SUCCESS)) { container.setContainerSpecId(containerResource.getContainerId()); container.setContainerName(containerResource.getContainerAlias()); container.setResolvedReleasedId(containerResource.getResolvedReleaseId() == null ? containerResource.getReleaseId() : containerResource.getResolvedReleaseId()); container.setServerTemplateId(serverTemplate.getId()); container.setStatus(containerResource.getStatus()); container.setMessages(containerResource.getMessages()); } return null; } }; } KieServerInstanceManager(); static KieServerInstanceManager getInstance(); List<Container> startScanner(ServerTemplate serverTemplate,
                                        final ContainerSpec containerSpec,
                                        final long interval); List<Container> stopScanner(ServerTemplate serverTemplate,
                                       final ContainerSpec containerSpec); List<Container> scanNow(ServerTemplate serverTemplate,
                                   final ContainerSpec containerSpec); synchronized List<Container> startContainer(final ServerTemplate serverTemplate,
                                                       final ContainerSpec containerSpec); synchronized List<Container> stopContainer(ServerTemplate serverTemplate,
                                                      final ContainerSpec containerSpec); List<Container> upgradeContainer(final ServerTemplate serverTemplate,
                                            final ContainerSpec containerSpec); List<Container> upgradeContainer(final ServerTemplate serverTemplate,
                                            final ContainerSpec containerSpec,
                                            final boolean resetBeforeUpdate); List<Container> upgradeAndStartContainer(final ServerTemplate serverTemplate,
                                                    final ContainerSpec containerSpec); List<Container> upgradeAndStartContainer(final ServerTemplate serverTemplate,
                                                    final ContainerSpec containerSpec,
                                                    final boolean resetBeforeUpdate); List<Container> getContainers(final ServerTemplate serverTemplate,
                                         final ContainerSpec containerSpec); List<Container> getContainers(ServerInstanceKey serverInstanceKey); synchronized List<Container> activateContainer(final ServerTemplate serverTemplate, final ContainerSpec containerSpec); synchronized List<Container> deactivateContainer(final ServerTemplate serverTemplate, final ContainerSpec containerSpec); boolean isAlive(ServerInstanceKey serverInstanceKey); }
KieServerInstanceManager { RemoteKieServerOperation<Void> getContainersRemoteOperation(final ServerTemplate serverTemplate, final ContainerSpec containerSpec) { return new RemoteKieServerOperation<Void>() { @Override public Void doOperation(KieServicesClient client, Container container) { final ServiceResponse<KieContainerResource> response = client.getContainerInfo(containerSpec.getId()); final KieContainerResource containerResource = response.getResult(); if (response.getType().equals(ServiceResponse.ResponseType.SUCCESS)) { container.setContainerSpecId(containerResource.getContainerId()); container.setContainerName(containerResource.getContainerAlias()); container.setResolvedReleasedId(containerResource.getResolvedReleaseId() == null ? containerResource.getReleaseId() : containerResource.getResolvedReleaseId()); container.setServerTemplateId(serverTemplate.getId()); container.setStatus(containerResource.getStatus()); container.setMessages(containerResource.getMessages()); } return null; } }; } KieServerInstanceManager(); static KieServerInstanceManager getInstance(); List<Container> startScanner(ServerTemplate serverTemplate,
                                        final ContainerSpec containerSpec,
                                        final long interval); List<Container> stopScanner(ServerTemplate serverTemplate,
                                       final ContainerSpec containerSpec); List<Container> scanNow(ServerTemplate serverTemplate,
                                   final ContainerSpec containerSpec); synchronized List<Container> startContainer(final ServerTemplate serverTemplate,
                                                       final ContainerSpec containerSpec); synchronized List<Container> stopContainer(ServerTemplate serverTemplate,
                                                      final ContainerSpec containerSpec); List<Container> upgradeContainer(final ServerTemplate serverTemplate,
                                            final ContainerSpec containerSpec); List<Container> upgradeContainer(final ServerTemplate serverTemplate,
                                            final ContainerSpec containerSpec,
                                            final boolean resetBeforeUpdate); List<Container> upgradeAndStartContainer(final ServerTemplate serverTemplate,
                                                    final ContainerSpec containerSpec); List<Container> upgradeAndStartContainer(final ServerTemplate serverTemplate,
                                                    final ContainerSpec containerSpec,
                                                    final boolean resetBeforeUpdate); List<Container> getContainers(final ServerTemplate serverTemplate,
                                         final ContainerSpec containerSpec); List<Container> getContainers(ServerInstanceKey serverInstanceKey); synchronized List<Container> activateContainer(final ServerTemplate serverTemplate, final ContainerSpec containerSpec); synchronized List<Container> deactivateContainer(final ServerTemplate serverTemplate, final ContainerSpec containerSpec); boolean isAlive(ServerInstanceKey serverInstanceKey);  }