import static org.junit.Assert.assertTrue;
import static org.onap.so.aaisimulator.utils.Constants.BI_DIRECTIONAL_RELATIONSHIP_LIST_URL;
import static org.onap.so.aaisimulator.utils.Constants.RELATIONSHIP_LIST_RELATIONSHIP_URL;
+import static org.onap.so.aaisimulator.utils.Constants.VSERVER;
import static org.onap.so.aaisimulator.utils.TestConstants.CLOUD_OWNER_NAME;
import static org.onap.so.aaisimulator.utils.TestConstants.CLOUD_REGION_NAME;
import static org.onap.so.aaisimulator.utils.TestConstants.CUSTOMERS_URL;
@Test
public void test_putCloudRegion_successfullyAddedToCache() throws Exception {
- final String url = getUrl(Constants.CLOUD_REGIONS, CLOUD_OWNER_NAME, "/" + CLOUD_REGION_NAME);
+ final String url = getUrl(TestConstants.CLOUD_REGIONS, CLOUD_OWNER_NAME, "/" + CLOUD_REGION_NAME);
invokeCloudRegionHttpPutEndPointAndAssertResponse(url);
@Test
public void test_getCloudRegionWithDepthValue_shouldReturnMatchedCloudRegion() throws Exception {
- final String url = getUrl(Constants.CLOUD_REGIONS, CLOUD_OWNER_NAME, "/" + CLOUD_REGION_NAME);
+ final String url = getUrl(TestConstants.CLOUD_REGIONS, CLOUD_OWNER_NAME, "/" + CLOUD_REGION_NAME);
invokeCloudRegionHttpPutEndPointAndAssertResponse(url);
@Test
public void test_putGenericVnfRelationShipToPlatform_successfullyAddedToCache() throws Exception {
- final String url = getUrl(Constants.CLOUD_REGIONS, CLOUD_OWNER_NAME, "/" + CLOUD_REGION_NAME);
+ final String url = getUrl(TestConstants.CLOUD_REGIONS, CLOUD_OWNER_NAME, "/" + CLOUD_REGION_NAME);
invokeCloudRegionHttpPutEndPointAndAssertResponse(url);
- final String relationShipUrl = getUrl(Constants.CLOUD_REGIONS, CLOUD_OWNER_NAME, "/" + CLOUD_REGION_NAME,
+ final String relationShipUrl = getUrl(TestConstants.CLOUD_REGIONS, CLOUD_OWNER_NAME, "/" + CLOUD_REGION_NAME,
BI_DIRECTIONAL_RELATIONSHIP_LIST_URL);
final ResponseEntity<Relationship> responseEntity = testRestTemplateService.invokeHttpPut(relationShipUrl,
@Test
public void test_putTenant_successfullyAddedToCache() throws Exception {
- final String cloudRegionUrl = getUrl(Constants.CLOUD_REGIONS, CLOUD_OWNER_NAME, "/" + CLOUD_REGION_NAME);
+ final String cloudRegionUrl = getUrl(TestConstants.CLOUD_REGIONS, CLOUD_OWNER_NAME, "/" + CLOUD_REGION_NAME);
invokeCloudRegionHttpPutEndPointAndAssertResponse(cloudRegionUrl);
- final String tenantUrl =
- getUrl(Constants.CLOUD_REGIONS, CLOUD_OWNER_NAME, "/" + CLOUD_REGION_NAME + TENANTS_TENANT + TENANT_ID);
+ final String tenantUrl = getUrl(TestConstants.CLOUD_REGIONS, CLOUD_OWNER_NAME,
+ "/" + CLOUD_REGION_NAME + TENANTS_TENANT + TENANT_ID);
addTenantAndAssertResponse(tenantUrl);
final ResponseEntity<Tenant> response = testRestTemplateService.invokeHttpGet(tenantUrl, Tenant.class);
addCustomerServiceAndGenericVnf();
- final String cloudRegionUrl = getUrl(Constants.CLOUD_REGIONS, CLOUD_OWNER_NAME, "/" + CLOUD_REGION_NAME);
+ final String cloudRegionUrl = getUrl(TestConstants.CLOUD_REGIONS, CLOUD_OWNER_NAME, "/" + CLOUD_REGION_NAME);
invokeCloudRegionHttpPutEndPointAndAssertResponse(cloudRegionUrl);
- final String tenantUrl =
- getUrl(Constants.CLOUD_REGIONS, CLOUD_OWNER_NAME, "/" + CLOUD_REGION_NAME, TENANTS_TENANT + TENANT_ID);
+ final String tenantUrl = getUrl(TestConstants.CLOUD_REGIONS, CLOUD_OWNER_NAME, "/" + CLOUD_REGION_NAME,
+ TENANTS_TENANT + TENANT_ID);
addTenantAndAssertResponse(tenantUrl);
- final String tenantRelationShipUrl = getUrl(Constants.CLOUD_REGIONS, CLOUD_OWNER_NAME, "/" + CLOUD_REGION_NAME,
- TENANTS_TENANT + TENANT_ID, RELATIONSHIP_LIST_RELATIONSHIP_URL);
+ final String tenantRelationShipUrl = getUrl(TestConstants.CLOUD_REGIONS, CLOUD_OWNER_NAME,
+ "/" + CLOUD_REGION_NAME, TENANTS_TENANT + TENANT_ID, RELATIONSHIP_LIST_RELATIONSHIP_URL);
final ResponseEntity<Void> tenantRelationShipResponse = testRestTemplateService
.invokeHttpPut(tenantRelationShipUrl, TestUtils.getGenericVnfRelatedLink(), Void.class);
final Relationship relationship = relationshipList.getRelationship().get(0);
- assertEquals(Constants.COMPOSED_OF, relationship.getRelationshipLabel());
+ assertEquals(Constants.BELONGS_TO, relationship.getRelationshipLabel());
assertFalse(relationship.getRelationshipData().isEmpty());
assertEquals(1, relationship.getRelationshipData().size());
@Test
public void test_putEsrSystemInfo_successfullyAddedToCache() throws Exception {
- final String url = getUrl(Constants.CLOUD_REGIONS, CLOUD_OWNER_NAME, "/" + CLOUD_REGION_NAME);
+ final String url = getUrl(TestConstants.CLOUD_REGIONS, CLOUD_OWNER_NAME, "/" + CLOUD_REGION_NAME);
invokeCloudRegionHttpPutEndPointAndAssertResponse(url);
- final String esrSystemInfoListUrl =
- getUrl(Constants.CLOUD_REGIONS, CLOUD_OWNER_NAME, "/" + CLOUD_REGION_NAME, ESR_SYSTEM_INFO_LIST_URL);
+ final String esrSystemInfoListUrl = getUrl(TestConstants.CLOUD_REGIONS, CLOUD_OWNER_NAME,
+ "/" + CLOUD_REGION_NAME, ESR_SYSTEM_INFO_LIST_URL);
final String esrSystemInfoUrl = esrSystemInfoListUrl + "/esr-system-info/" + ESR_SYSTEM_INFO_ID;
final ResponseEntity<Void> esrSystemInfoResponse =
@Test
public void test_putVServer_successfullyAddedToCache() throws Exception {
- final String url = getUrl(Constants.CLOUD_REGIONS, CLOUD_OWNER_NAME, "/" + CLOUD_REGION_NAME);
+ final String url = getUrl(TestConstants.CLOUD_REGIONS, CLOUD_OWNER_NAME, "/" + CLOUD_REGION_NAME);
invokeCloudRegionHttpPutEndPointAndAssertResponse(url);
+ addCustomerServiceAndGenericVnf();
final String tenantUrl = url + TENANTS_TENANT + TENANT_ID;
addTenantAndAssertResponse(tenantUrl);
assertEquals(VSERVER_NAME, actualVserver.getVserverName());
assertEquals(VSERVER_ID, actualVserver.getVserverId());
assertEquals("active", actualVserver.getProvStatus());
+ assertNotNull(actualVserver.getRelationshipList());
+ assertFalse(actualVserver.getRelationshipList().getRelationship().isEmpty());
+
+ final Optional<GenericVnf> optional = genericVnfCacheServiceProvider.getGenericVnf(VNF_ID);
+ assertTrue(optional.isPresent());
+ final GenericVnf genericVnf = optional.get();
+ assertNotNull(genericVnf.getRelationshipList());
+ assertFalse(genericVnf.getRelationshipList().getRelationship().isEmpty());
+
+ final Relationship expectedRelationShip = genericVnf.getRelationshipList().getRelationship().get(0);
+ assertEquals(VSERVER, expectedRelationShip.getRelatedTo());
+ assertNotNull(expectedRelationShip.getRelationshipData());
+ assertEquals(4, expectedRelationShip.getRelationshipData().size());
+
+ final List<RelationshipData> relationshipDataList = expectedRelationShip.getRelationshipData();
+ final RelationshipData vServerrelationshipData =
+ getRelationshipData(relationshipDataList, Constants.VSERVER_VSERVER_ID);
+ assertNotNull(vServerrelationshipData);
+ assertEquals(VSERVER_ID, vServerrelationshipData.getRelationshipValue());
+
+ final RelationshipData cloudOwnerRelationshipData =
+ getRelationshipData(relationshipDataList, Constants.CLOUD_REGION_CLOUD_OWNER);
+ assertNotNull(cloudOwnerRelationshipData);
+ assertEquals(CLOUD_OWNER_NAME, cloudOwnerRelationshipData.getRelationshipValue());
+
+ final RelationshipData cloudRegionIdRelationshipData =
+ getRelationshipData(relationshipDataList, Constants.CLOUD_REGION_CLOUD_REGION_ID);
+ assertNotNull(cloudRegionIdRelationshipData);
+ assertEquals(CLOUD_REGION_NAME, cloudRegionIdRelationshipData.getRelationshipValue());
+
+ final RelationshipData tenantRelationshipData =
+ getRelationshipData(relationshipDataList, Constants.TENANT_TENANT_ID);
+ assertNotNull(tenantRelationshipData);
+ assertEquals(TENANT_ID, tenantRelationshipData.getRelationshipValue());
+
}
@Test
public void test_deleteVServer_successfullyRemoveFromCache() throws Exception {
- final String url = getUrl(Constants.CLOUD_REGIONS, CLOUD_OWNER_NAME, "/" + CLOUD_REGION_NAME);
+ final String url = getUrl(TestConstants.CLOUD_REGIONS, CLOUD_OWNER_NAME, "/" + CLOUD_REGION_NAME);
invokeCloudRegionHttpPutEndPointAndAssertResponse(url);
+ addCustomerServiceAndGenericVnf();
final String tenantUrl = url + TENANTS_TENANT + TENANT_ID;
addTenantAndAssertResponse(tenantUrl);