@Test public void testConnection_WithOpenStack_WithIgnoreControllerException_WithIgnoreProviderException_WhenRabbitClientConnectionThrowsSignalException_WhenMqClientIsConnected_ReturnsSuccessful() throws Throwable { DryRunRequest<VirtualizationConnectorRequest> request = VirtualizationConnectorUtilTestData.generateOpenStackVCWithSDN(); RabbitMQRunner runner = Mockito.mock(RabbitMQRunner.class); this.util.activeRunner = runner; @SuppressWarnings("unchecked") HashMap<Long, OsRabbitMQClient> map = mock(HashMap.class); when(runner.getVcToRabbitMQClientMap()).thenReturn(map); OsRabbitMQClient mqClient = mock(OsRabbitMQClient.class); doReturn(mqClient).when(map).get(any(Integer.class)); doReturn(true).when(mqClient).isConnected(); request.getDto().setId(20l); List<ErrorType> errorList = new ArrayList<>(); errorList.add(ErrorType.CONTROLLER_EXCEPTION); errorList.add(ErrorType.PROVIDER_EXCEPTION); request.addErrorsToIgnore(errorList); VirtualizationConnector vc = VirtualizationConnectorEntityMgr.createEntity(request.getDto(), this.encrypter); doThrow(mock(ShutdownSignalException.class)).when(this.rabbitClient).testConnection(); DryRunRequest<VirtualizationConnectorRequest> spyRequest = spy(request); this.util.checkConnection(spyRequest, vc); verify(spyRequest, times(1)).isIgnoreErrorsAndCommit(ErrorType.CONTROLLER_EXCEPTION); verify(spyRequest, times(1)).isIgnoreErrorsAndCommit(ErrorType.PROVIDER_EXCEPTION); verify(this.rabbitClient, times(1)).testConnection(); }
public <T extends VirtualizationConnectorDto> void checkConnection(DryRunRequest<T> request, VirtualizationConnector vc) throws Exception { if (!request.isSkipAllDryRun()) { ErrorTypeException errorTypeException = null; final ArrayList<CertificateResolverModel> certificateResolverModels = new ArrayList<>(); if (this.managerFactory == null) { this.managerFactory = X509TrustManagerFactory.getInstance(); } if (vc.getVirtualizationType().equals(VirtualizationType.OPENSTACK)) { errorTypeException = checkOpenstackConnection(request, certificateResolverModels, vc); } else if (vc.getVirtualizationType().equals(VirtualizationType.KUBERNETES)) { errorTypeException = checkKubernetesConnection(request, certificateResolverModels, vc); } this.managerFactory.clearListener(); if (!certificateResolverModels.isEmpty() && errorTypeException != null) { throw new SslCertificatesExtendedException(errorTypeException, certificateResolverModels); } else if (errorTypeException != null) { throw errorTypeException; } } }
VirtualizationConnectorUtil { public <T extends VirtualizationConnectorDto> void checkConnection(DryRunRequest<T> request, VirtualizationConnector vc) throws Exception { if (!request.isSkipAllDryRun()) { ErrorTypeException errorTypeException = null; final ArrayList<CertificateResolverModel> certificateResolverModels = new ArrayList<>(); if (this.managerFactory == null) { this.managerFactory = X509TrustManagerFactory.getInstance(); } if (vc.getVirtualizationType().equals(VirtualizationType.OPENSTACK)) { errorTypeException = checkOpenstackConnection(request, certificateResolverModels, vc); } else if (vc.getVirtualizationType().equals(VirtualizationType.KUBERNETES)) { errorTypeException = checkKubernetesConnection(request, certificateResolverModels, vc); } this.managerFactory.clearListener(); if (!certificateResolverModels.isEmpty() && errorTypeException != null) { throw new SslCertificatesExtendedException(errorTypeException, certificateResolverModels); } else if (errorTypeException != null) { throw errorTypeException; } } } }
VirtualizationConnectorUtil { public <T extends VirtualizationConnectorDto> void checkConnection(DryRunRequest<T> request, VirtualizationConnector vc) throws Exception { if (!request.isSkipAllDryRun()) { ErrorTypeException errorTypeException = null; final ArrayList<CertificateResolverModel> certificateResolverModels = new ArrayList<>(); if (this.managerFactory == null) { this.managerFactory = X509TrustManagerFactory.getInstance(); } if (vc.getVirtualizationType().equals(VirtualizationType.OPENSTACK)) { errorTypeException = checkOpenstackConnection(request, certificateResolverModels, vc); } else if (vc.getVirtualizationType().equals(VirtualizationType.KUBERNETES)) { errorTypeException = checkKubernetesConnection(request, certificateResolverModels, vc); } this.managerFactory.clearListener(); if (!certificateResolverModels.isEmpty() && errorTypeException != null) { throw new SslCertificatesExtendedException(errorTypeException, certificateResolverModels); } else if (errorTypeException != null) { throw errorTypeException; } } }  }
VirtualizationConnectorUtil { public <T extends VirtualizationConnectorDto> void checkConnection(DryRunRequest<T> request, VirtualizationConnector vc) throws Exception { if (!request.isSkipAllDryRun()) { ErrorTypeException errorTypeException = null; final ArrayList<CertificateResolverModel> certificateResolverModels = new ArrayList<>(); if (this.managerFactory == null) { this.managerFactory = X509TrustManagerFactory.getInstance(); } if (vc.getVirtualizationType().equals(VirtualizationType.OPENSTACK)) { errorTypeException = checkOpenstackConnection(request, certificateResolverModels, vc); } else if (vc.getVirtualizationType().equals(VirtualizationType.KUBERNETES)) { errorTypeException = checkKubernetesConnection(request, certificateResolverModels, vc); } this.managerFactory.clearListener(); if (!certificateResolverModels.isEmpty() && errorTypeException != null) { throw new SslCertificatesExtendedException(errorTypeException, certificateResolverModels); } else if (errorTypeException != null) { throw errorTypeException; } } }  void checkConnection(DryRunRequest<T> request,  VirtualizationConnector vc); }
VirtualizationConnectorUtil { public <T extends VirtualizationConnectorDto> void checkConnection(DryRunRequest<T> request, VirtualizationConnector vc) throws Exception { if (!request.isSkipAllDryRun()) { ErrorTypeException errorTypeException = null; final ArrayList<CertificateResolverModel> certificateResolverModels = new ArrayList<>(); if (this.managerFactory == null) { this.managerFactory = X509TrustManagerFactory.getInstance(); } if (vc.getVirtualizationType().equals(VirtualizationType.OPENSTACK)) { errorTypeException = checkOpenstackConnection(request, certificateResolverModels, vc); } else if (vc.getVirtualizationType().equals(VirtualizationType.KUBERNETES)) { errorTypeException = checkKubernetesConnection(request, certificateResolverModels, vc); } this.managerFactory.clearListener(); if (!certificateResolverModels.isEmpty() && errorTypeException != null) { throw new SslCertificatesExtendedException(errorTypeException, certificateResolverModels); } else if (errorTypeException != null) { throw errorTypeException; } } }  void checkConnection(DryRunRequest<T> request,  VirtualizationConnector vc);  }