### Question:
CloudInfoFromAAI { protected Optional<CloudRegion> getRelatedCloudRegionAndTenant(Relationships relationships) { CloudRegion cloudRegion = new CloudRegion(); List<AAIResultWrapper> cloudRegions = relationships.getByType(Types.CLOUD_REGION); List<AAIResultWrapper> tenants = relationships.getByType(Types.TENANT); if (!cloudRegions.isEmpty()) { AAIResultWrapper cloudRegionWrapper = cloudRegions.get(0); Optional<org.onap.aai.domain.yang.CloudRegion> aaiCloudRegionOp = cloudRegionWrapper.asBean(org.onap.aai.domain.yang.CloudRegion.class); if (aaiCloudRegionOp.isPresent()) { org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = aaiCloudRegionOp.get(); cloudRegion.setCloudOwner(aaiCloudRegion.getCloudOwner()); cloudRegion.setCloudRegionVersion(aaiCloudRegion.getCloudRegionVersion()); cloudRegion.setLcpCloudRegionId(aaiCloudRegion.getCloudRegionId()); cloudRegion.setComplex(aaiCloudRegion.getComplexName()); } } if (!tenants.isEmpty()) { AAIResultWrapper tenantWrapper = tenants.get(0); Optional<org.onap.aai.domain.yang.Tenant> aaiTenantOp = tenantWrapper.asBean(org.onap.aai.domain.yang.Tenant.class); if (aaiTenantOp.isPresent()) { org.onap.aai.domain.yang.Tenant aaiTenant = aaiTenantOp.get(); cloudRegion.setTenantId(aaiTenant.getTenantId()); } } return Optional.of(cloudRegion); }  void setBbInputSetupUtils(BBInputSetupUtils bbInputSetupUtils);  }### Answer:
@Test public void testGetRelatedCloudRegionAndTenant() throws JsonProcessingException { String cloudOwner = "cloudOwner"; String cloudRegionId = "cloudRegionId"; String cloudRegionVersion = "cloudRegionVersion"; String cloudRegionComplexName = "cloudRegionComplexName"; String tenantId = "tenantId"; CloudRegion expected = new CloudRegion(); expected.setCloudOwner(cloudOwner); expected.setCloudRegionVersion(cloudRegionVersion); expected.setComplex(cloudRegionComplexName); expected.setLcpCloudRegionId(cloudRegionId); expected.setTenantId(tenantId); Relationships relationships = Mockito.mock(Relationships.class); List<AAIResultWrapper> cloudRegions = new ArrayList<>(); org.onap.aai.domain.yang.CloudRegion cloudRegion = new org.onap.aai.domain.yang.CloudRegion(); cloudRegion.setCloudOwner(cloudOwner); cloudRegion.setCloudRegionId(cloudRegionId); cloudRegion.setCloudRegionVersion(cloudRegionVersion); cloudRegion.setComplexName(cloudRegionComplexName); AAIResultWrapper cloudRegionWrapper = new AAIResultWrapper(new AAICommonObjectMapperProvider().getMapper().writeValueAsString(cloudRegion)); cloudRegions.add(cloudRegionWrapper); doReturn(cloudRegions).when(relationships).getByType(Types.CLOUD_REGION); List<AAIResultWrapper> tenants = new ArrayList<>(); org.onap.aai.domain.yang.Tenant tenant = new org.onap.aai.domain.yang.Tenant(); tenant.setTenantId(tenantId); AAIResultWrapper tenantWrapper = new AAIResultWrapper(new AAICommonObjectMapperProvider().getMapper().writeValueAsString(tenant)); tenants.add(tenantWrapper); doReturn(tenants).when(relationships).getByType(Types.TENANT); Optional<CloudRegion> actual = SPY_CloudInfoFromAAI.getRelatedCloudRegionAndTenant(relationships); assertThat(actual.get(), sameBeanAs(expected)); }