### Question:
MsoCloudClientFactoryImpl implements MsoCloudClientFactory { @Override public OpenstackClient getOpenstackClient(@Nonnull String url, @Nonnull String msoId, @Nonnull String msoPass, @Nonnull String regionId, @Nonnull String tenantId, @Nonnull String keystoneVersion, String userDomainName, String projectDomainName) throws HeatBridgeException { Objects.requireNonNull(url, "Null openstack url!"); Objects.requireNonNull(msoId, "Null openstack user id!"); Objects.requireNonNull(msoPass, "Null openstack password!"); Objects.requireNonNull(regionId, "Null regionId ID!"); Objects.requireNonNull(tenantId, "Null tenant ID!"); Objects.requireNonNull(keystoneVersion, "Null keystone version"); if (userDomainName == null) { userDomainName = HeatBridgeConstants.OS_DEFAULT_DOMAIN_NAME; } if (projectDomainName == null) { projectDomainName = HeatBridgeConstants.OS_DEFAULT_DOMAIN_NAME; } try { final OpenstackAccess osAccess = new OpenstackAccessBuilder().setBaseUrl(url) .setUser(msoId) .setPassword(CryptoUtils.decryptCloudConfigPassword(msoPass)) .setRegion(regionId) .setDomainName(userDomainName).setProjectName(projectDomainName).setTenantId(tenantId) .build(); if (keystoneVersion.equals(HeatBridgeConstants.OS_KEYSTONE_V2_KEY)) { return openstackClientFactory.createOpenstackV2Client(osAccess); } else if (keystoneVersion.equals(HeatBridgeConstants.OS_KEYSTONE_V3_KEY)) { return openstackClientFactory.createOpenstackV3Client(osAccess); } throw new OpenstackClientException("Unsupported keystone version! " + keystoneVersion); } catch (OpenstackClientException osClientEx) { logger.error("Error creating OS Client", osClientEx); throw new HeatBridgeException("Client error when authenticating with the Openstack", osClientEx); } } MsoCloudClientFactoryImpl(@Nonnull OpenstackClientFactory openstackClientFactory); @Override OpenstackClient getOpenstackClient(@Nonnull String url, @Nonnull String msoId, @Nonnull String msoPass,
            @Nonnull String regionId, @Nonnull String tenantId, @Nonnull String keystoneVersion, String userDomainName,
            String projectDomainName);  }### Answer:
@Test public void getOpenstackClientWithVersion2() throws Exception { testedObject.getOpenstackClient(URL_V2, MSO_ID, ENCRYPTED_PASSWORD, REGION_ID, TENANT_ID, "v2.0", null, null); verify(openstackClientFactoryMock).createOpenstackV2Client(any(OpenstackAccess.class)); }
@Test public void getOpenstackClientWithVersion3() throws Exception { testedObject.getOpenstackClient(URL_V3, MSO_ID, ENCRYPTED_PASSWORD, REGION_ID, TENANT_ID, "v3", USER_DOMAIN_NAME, PROJECT_DOMAIN_NAME); verify(openstackClientFactoryMock).createOpenstackV3Client(any(OpenstackAccess.class)); }
@Test(expected = HeatBridgeException.class) public void getOpenstackClient_unsupportedVersion() throws Exception { testedObject.getOpenstackClient(URL_WITH_UNSUPPORTED_VERSION, MSO_ID, ENCRYPTED_PASSWORD, REGION_ID, TENANT_ID, "UNKNOWN", USER_DOMAIN_NAME, PROJECT_DOMAIN_NAME); }