use of org.onap.so.db.catalog.beans.CloudSite in project so by onap.
the class CloudConfigTest method testGetCloudSite.
/**
* This method implements a test for the getCloudSite method.
*/
@Test
public final void testGetCloudSite() {
CloudSite site1 = con.getCloudSite("MTN13").get();
assertEquals("mtn13", site1.getRegionId());
assertEquals("mtn13", site1.getIdentityServiceId());
assertEquals("MDT13", site1.getClli());
assertEquals("3.0", site1.getCloudVersion());
}
use of org.onap.so.db.catalog.beans.CloudSite in project so by onap.
the class MsoTenantUtilsFactoryTest method getTenantUtils_shouldReturnNull_forInvalidServerType.
@Test
public void getTenantUtils_shouldReturnNull_forInvalidServerType() throws MsoCloudSiteNotFound {
// GIVEN
String cloudSiteId = "CloudSiteId";
CloudSite cloudSite = mock(CloudSite.class, RETURNS_DEEP_STUBS);
given(cloudConfig.getCloudSite(cloudSiteId)).willReturn(Optional.of(cloudSite));
// WHEN
MsoTenantUtils tenantUtils = msoTenantUtilsFactory.getTenantUtils(cloudSiteId);
// THEN
assertThat(tenantUtils).isNull();
}
use of org.onap.so.db.catalog.beans.CloudSite in project so by onap.
the class MsoTenantUtilsFactoryTest method shouldReturnAppropriateUtilsInstanceForGivenServerType.
private <T extends MsoTenantUtils> void shouldReturnAppropriateUtilsInstanceForGivenServerType(ServerType serverType, T expectedInstance) throws MsoCloudSiteNotFound {
// GIVEN
String cloudSiteId = "CloudSiteId";
CloudSite cloudSite = mock(CloudSite.class, RETURNS_DEEP_STUBS);
given(cloudSite.getIdentityService().getIdentityServerType()).willReturn(serverType);
given(cloudConfig.getCloudSite(cloudSiteId)).willReturn(Optional.of(cloudSite));
// WHEN
MsoTenantUtils tenantUtils = msoTenantUtilsFactory.getTenantUtils(cloudSiteId);
// THEN
assertThat(tenantUtils).isEqualTo(expectedInstance);
}
use of org.onap.so.db.catalog.beans.CloudSite in project so by onap.
the class OofInfraUtils method createCloudSite.
/**
* This method creates a cloudsite in catalog database.
*
* @param cloudSite
*
* @return void
*/
public void createCloudSite(CloudSite cloudSite, DelegateExecution execution) {
String endpoint = UrnPropertiesReader.getVariable("mso.catalog.db.spring.endpoint", execution);
String auth = UrnPropertiesReader.getVariable("mso.db.auth", execution);
try {
CloudSite getCloudsite;
CatalogDbClient client = new CatalogDbClient(endpoint, auth);
getCloudsite = Optional.ofNullable(client.getCloudSite(cloudSite.getId(), endpoint + "/cloudSite/")).orElse(new CloudSite());
if (!cloudSite.getId().equals(getCloudsite.getId())) {
client.postOofHomingCloudSite(cloudSite);
logger.debug("Did not findd cloudsite : {}", cloudSite.getId());
logger.debug("Will create cloudSite: {}", cloudSite.toString());
} else {
logger.debug("Found cloudsite : {}", cloudSite.getId());
logger.debug("Will not create cloudSite: {}", cloudSite.toString());
}
} catch (Exception e) {
logger.debug("Error looking up or creating cloudsite : {}", cloudSite.getId());
logger.debug("CloudSite Lookup/Creation Error: " + e);
}
}
Aggregations