summaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'vid-app-common/src/test')
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/controller/AaiControllerTest.java175
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/job/command/ResourceCommandTest.java17
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBaseTest.java14
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBusinessLogicTest.java2
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/MsoRequestBuilderTest.java3
5 files changed, 134 insertions, 77 deletions
diff --git a/vid-app-common/src/test/java/org/onap/vid/controller/AaiControllerTest.java b/vid-app-common/src/test/java/org/onap/vid/controller/AaiControllerTest.java
index 3e38ba883..83cc61ea4 100644
--- a/vid-app-common/src/test/java/org/onap/vid/controller/AaiControllerTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/controller/AaiControllerTest.java
@@ -39,6 +39,7 @@ import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.Lists;
import com.google.common.collect.Multimap;
+import java.util.List;
import java.util.Map;
import java.util.UUID;
import javax.ws.rs.core.Response;
@@ -295,10 +296,10 @@ public class AaiControllerTest {
given(aaiService.getAaiZones()).willReturn(new AaiResponse(aicZones, "", HttpStatus.OK.value()));
mockMvc.perform(get("/aai_get_aic_zones")
- .contentType(MediaType.APPLICATION_JSON)
- .accept(MediaType.APPLICATION_JSON))
- .andExpect(status().isOk())
- .andExpect(content().json(objectMapper.writeValueAsString(aicZones)));
+ .contentType(MediaType.APPLICATION_JSON)
+ .accept(MediaType.APPLICATION_JSON))
+ .andExpect(status().isOk())
+ .andExpect(content().json(objectMapper.writeValueAsString(aicZones)));
}
@Test
@@ -308,32 +309,32 @@ public class AaiControllerTest {
.willReturn(new AaiResponse(null, expectedErrorMessage, HttpStatus.INTERNAL_SERVER_ERROR.value()));
mockMvc.perform(get("/aai_get_aic_zones")
- .contentType(MediaType.APPLICATION_JSON)
- .accept(MediaType.APPLICATION_JSON))
- .andExpect(status().isInternalServerError())
- .andExpect(content().string(expectedErrorMessage));
+ .contentType(MediaType.APPLICATION_JSON)
+ .accept(MediaType.APPLICATION_JSON))
+ .andExpect(status().isInternalServerError())
+ .andExpect(content().string(expectedErrorMessage));
}
@Test
public void getSpecificPnf_shouldReturnPnfObjectForPnfId() throws Exception {
String pnfId = "MyPnfId";
Pnf pnf = Pnf.builder()
- .withPnfId(pnfId)
- .withPnfName("TestPnf")
- .withPnfName2("pnfName2")
- .withPnfName2Source("pnfNameSource")
- .withEquipModel("model")
- .withEquipType("type")
- .withEquipVendor("vendor")
- .build();
+ .withPnfId(pnfId)
+ .withPnfName("TestPnf")
+ .withPnfName2("pnfName2")
+ .withPnfName2Source("pnfNameSource")
+ .withEquipModel("model")
+ .withEquipType("type")
+ .withEquipVendor("vendor")
+ .build();
AaiResponse<Pnf> aaiResponse = new AaiResponse<>(pnf, "", HttpStatus.OK.value());
given(aaiService.getSpecificPnf(pnfId)).willReturn(aaiResponse);
mockMvc.perform(get("/aai_get_pnfs/pnf/{pnf_id}", pnfId)
- .contentType(MediaType.APPLICATION_JSON)
- .accept(MediaType.APPLICATION_JSON))
- .andExpect(status().isOk())
- .andExpect(content().json(objectMapper.writeValueAsString(pnf)));
+ .contentType(MediaType.APPLICATION_JSON)
+ .accept(MediaType.APPLICATION_JSON))
+ .andExpect(status().isOk())
+ .andExpect(content().json(objectMapper.writeValueAsString(pnf)));
}
@Test
@@ -343,10 +344,10 @@ public class AaiControllerTest {
given(aaiService.getSpecificPnf(pnfId)).willThrow(new RuntimeException(expectedErrorMessage));
mockMvc.perform(get("/aai_get_pnfs/pnf/{pnf_id}", pnfId)
- .contentType(MediaType.APPLICATION_JSON)
- .accept(MediaType.APPLICATION_JSON))
- .andExpect(status().isInternalServerError())
- .andExpect(content().string(expectedErrorMessage));
+ .contentType(MediaType.APPLICATION_JSON)
+ .accept(MediaType.APPLICATION_JSON))
+ .andExpect(status().isInternalServerError())
+ .andExpect(content().string(expectedErrorMessage));
}
public void getPNFInstances_shouldReturnOKResponseFromAAIService() throws Exception {
@@ -366,12 +367,12 @@ public class AaiControllerTest {
equipModel)).willReturn(aaiResponse);
mockMvc.perform(
- get(urlTemplate, globalCustomerId, serviceType, modelVersionId,
- modelInvariantId, cloudRegion, equipVendor, equipModel)
- .contentType(MediaType.APPLICATION_JSON)
- .accept(MediaType.APPLICATION_JSON))
- .andExpect(status().isOk())
- .andExpect(content().string(expectedResponseBody));
+ get(urlTemplate, globalCustomerId, serviceType, modelVersionId,
+ modelInvariantId, cloudRegion, equipVendor, equipModel)
+ .contentType(MediaType.APPLICATION_JSON)
+ .accept(MediaType.APPLICATION_JSON))
+ .andExpect(status().isOk())
+ .andExpect(content().string(expectedResponseBody));
}
@Test
@@ -385,12 +386,12 @@ public class AaiControllerTest {
.getVersionByInvariantId(request.versions)).willReturn(response);
mockMvc.perform(
- post("/aai_get_version_by_invariant_id")
- .content(objectMapper.writeValueAsString(request))
- .contentType(MediaType.APPLICATION_JSON)
- .accept(MediaType.APPLICATION_JSON))
- .andExpect(status().isOk())
- .andExpect(content().string(expectedResponse));
+ post("/aai_get_version_by_invariant_id")
+ .content(objectMapper.writeValueAsString(request))
+ .contentType(MediaType.APPLICATION_JSON)
+ .accept(MediaType.APPLICATION_JSON))
+ .andExpect(status().isOk())
+ .andExpect(content().string(expectedResponse));
}
@Test
@@ -408,12 +409,12 @@ public class AaiControllerTest {
.willReturn(aaiResponse);
mockMvc.perform(
- get("/aai_sub_details/{subscriberId}", subscriberId)
- .param("omitServiceInstances", Boolean.toString(omitServiceInstances))
- .contentType(MediaType.APPLICATION_JSON)
- .accept(MediaType.APPLICATION_JSON))
- .andExpect(status().isOk())
- .andExpect(content().string(objectMapper.writeValueAsString(okResponseBody)));
+ get("/aai_sub_details/{subscriberId}", subscriberId)
+ .param("omitServiceInstances", Boolean.toString(omitServiceInstances))
+ .contentType(MediaType.APPLICATION_JSON)
+ .accept(MediaType.APPLICATION_JSON))
+ .andExpect(status().isOk())
+ .andExpect(content().string(objectMapper.writeValueAsString(okResponseBody)));
}
@Test
@@ -437,50 +438,98 @@ public class AaiControllerTest {
@Test
public void getPortMirroringConfigData_givenThreeIds_ReturnsThreeResults() {
- final AaiResponseTranslator.PortMirroringConfigDataOk toBeReturnedForA = new AaiResponseTranslator.PortMirroringConfigDataOk("foobar");
- final AaiResponseTranslator.PortMirroringConfigDataError toBeReturnedForB = new AaiResponseTranslator.PortMirroringConfigDataError("foo", "{ baz: qux }");
- final AaiResponseTranslator.PortMirroringConfigDataOk toBeReturnedForC = new AaiResponseTranslator.PortMirroringConfigDataOk("corge");
+ final AaiResponseTranslator.PortMirroringConfigDataOk toBeReturnedForA = new AaiResponseTranslator.PortMirroringConfigDataOk(
+ "foobar");
+ final AaiResponseTranslator.PortMirroringConfigDataError toBeReturnedForB = new AaiResponseTranslator.PortMirroringConfigDataError(
+ "foo", "{ baz: qux }");
+ final AaiResponseTranslator.PortMirroringConfigDataOk toBeReturnedForC = new AaiResponseTranslator.PortMirroringConfigDataOk(
+ "corge");
Mockito
- .doReturn(toBeReturnedForA)
- .doReturn(toBeReturnedForB)
- .doReturn(toBeReturnedForC)
- .when(aaiService).getPortMirroringConfigData(Mockito.anyString());
+ .doReturn(toBeReturnedForA)
+ .doReturn(toBeReturnedForB)
+ .doReturn(toBeReturnedForC)
+ .when(aaiService).getPortMirroringConfigData(Mockito.anyString());
- final Map<String, AaiResponseTranslator.PortMirroringConfigData> result = aaiController.getPortMirroringConfigsData(ImmutableList.of("a", "b", "c"));
+ final Map<String, AaiResponseTranslator.PortMirroringConfigData> result = aaiController
+ .getPortMirroringConfigsData(ImmutableList.of("a", "b", "c"));
assertThat(result, is(ImmutableMap.of(
- "a", toBeReturnedForA,
- "b", toBeReturnedForB,
- "c", toBeReturnedForC
+ "a", toBeReturnedForA,
+ "b", toBeReturnedForB,
+ "c", toBeReturnedForC
)));
}
@Test
public void getSubscriberDetails_shouldIncludeServiceInstancesFromSubscriberData_whenFeatureDisabled_andOmitFlagIsFalse()
- throws Exception {
+ throws Exception {
boolean isFeatureActive = false;
boolean omitServiceInstances = false;
getSubscriberDetails_assertServiceInstancesInclusion(isFeatureActive, omitServiceInstances);
}
private void getSubscriberDetails_assertServiceInstancesInclusion(boolean isFeatureActive,
- boolean omitServiceInstances) throws Exception {
+ boolean omitServiceInstances) throws Exception {
String subscriberId = "subscriberId";
String okResponseBody = "OK_RESPONSE";
AaiResponse<String> aaiResponse = new AaiResponse<>(okResponseBody, "", HttpStatus.OK.value());
given(featureManager.isActive(Features.FLAG_1906_AAI_SUB_DETAILS_REDUCE_DEPTH)).willReturn(isFeatureActive);
given(aaiService.getSubscriberData(eq(subscriberId), isA(RoleValidatorByRoles.class),
- eq(isFeatureActive && omitServiceInstances)))
- .willReturn(aaiResponse);
+ eq(isFeatureActive && omitServiceInstances)))
+ .willReturn(aaiResponse);
mockMvc.perform(
- get("/aai_sub_details/{subscriberId}", subscriberId)
- .param("omitServiceInstances", Boolean.toString(omitServiceInstances))
- .contentType(MediaType.APPLICATION_JSON)
- .accept(MediaType.APPLICATION_JSON))
- .andExpect(status().isOk())
- .andExpect(content().string(objectMapper.writeValueAsString(okResponseBody)));
+ get("/aai_sub_details/{subscriberId}", subscriberId)
+ .param("omitServiceInstances", Boolean.toString(omitServiceInstances))
+ .contentType(MediaType.APPLICATION_JSON)
+ .accept(MediaType.APPLICATION_JSON))
+ .andExpect(status().isOk())
+ .andExpect(content().string(objectMapper.writeValueAsString(okResponseBody)));
+ }
+
+ @Test
+ public void getSpecificConfiguration_shouldReturnOkResponse() throws Exception {
+ String configurationId = "testGlobalCustomerId";
+ String expectedResponseBody = "OK_RESPONSE";
+ Response response = mock(Response.class);
+ given(response.readEntity(String.class)).willReturn(expectedResponseBody);
+ given(response.getStatus()).willReturn(HttpStatus.OK.value());
+
+ given(aaiRestInterface.RestGet(
+ eq("VidAaiController"),
+ anyString(),
+ eq(Unchecked.toURI("network/configurations/configuration/" + configurationId)),
+ eq(false)).getResponse()).willReturn(response);
+
+ mockMvc
+ .perform(
+ get("/aai_get_configuration/{configuration_id}", configurationId)
+ .contentType(MediaType.APPLICATION_JSON)
+ .accept(MediaType.APPLICATION_JSON))
+ .andExpect(status().isOk())
+ .andExpect(content().string(expectedResponseBody));
}
+
+ @Test
+ public void getServiceInstanceAssociatedPnfs_shouldReturnPnfs() throws Exception {
+ String globalCustomerId = "testCustomerId";
+ String serviceType = "testServiceType";
+ String serviceInstanceId = "testServiceInstanceId";
+ List<String> expectedPnfs = ImmutableList.of("pnf1", "pnf2", "pnf3");
+
+ given(aaiService.getServiceInstanceAssociatedPnfs(globalCustomerId, serviceType, serviceInstanceId))
+ .willReturn(expectedPnfs);
+
+ mockMvc
+ .perform(
+ get("/aai_get_service_instance_pnfs/{globalCustomerId}/{serviceType}/{serviceInstanceId}",
+ globalCustomerId, serviceType, serviceInstanceId)
+ .contentType(MediaType.APPLICATION_JSON)
+ .accept(MediaType.APPLICATION_JSON))
+ .andExpect(status().isOk())
+ .andExpect(content().json(objectMapper.writeValueAsString(expectedPnfs)));
+ }
+
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/job/command/ResourceCommandTest.java b/vid-app-common/src/test/java/org/onap/vid/job/command/ResourceCommandTest.java
index 2780e1515..9501614b7 100644
--- a/vid-app-common/src/test/java/org/onap/vid/job/command/ResourceCommandTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/job/command/ResourceCommandTest.java
@@ -273,30 +273,35 @@ public class ResourceCommandTest {
}
static InstanceGroup createGroup(List<InstanceGroupMember> groupMembers, Action action) {
- return new InstanceGroup(mock(ModelInfo.class), null, action.name(), false, null, convertToMap(groupMembers), null, null, null);
+ return new InstanceGroup(mock(ModelInfo.class), null, action.name(), false, null, convertToMap(groupMembers), null, null, null,
+ null);
}
static InstanceGroupMember createMember(Action action) {
- return new InstanceGroupMember(null, action.toString(), null, null, null);
+ return new InstanceGroupMember(null, action.toString(), null, null, null, null);
}
static Vnf createVnf(List<VfModule> vfModules, Action action) {
Map<String, Map<String, VfModule>> vfModulesMap = new HashMap<>();
vfModulesMap.put("abc",convertToMap(vfModules));
- return new Vnf(mock(ModelInfo.class), null, null, action.toString(), null, null, null, null, null, null, false, null, vfModulesMap, null, null, null);
+ return new Vnf(mock(ModelInfo.class), null, null, action.toString(), null, null, null, null, null, null, false, null, vfModulesMap, null, null, null,
+ null);
}
static Vnf createVnf(Action action) {
- return new Vnf(mock(ModelInfo.class), null, null, action.toString(), null, null, null, null, null, null, false, null,null, null, null, null);
+ return new Vnf(mock(ModelInfo.class), null, null, action.toString(), null, null, null, null, null, null, false, null,null, null, null, null,
+ null);
}
static VfModule createVfModule(Action action) {
- return new VfModule(mock(ModelInfo.class), null, null, action.toString(), null, null, null, null, null, false, false, null, null, null, null);
+ return new VfModule(mock(ModelInfo.class), null, null, action.toString(), null, null, null, null, null, false, false, null, null, null, null,
+ null);
}
static Network createNetwork(Action action) {
- return new Network(mock(ModelInfo.class), null, null, action.toString(), null, null, null, null, null, null, false, null, null, null, null);
+ return new Network(mock(ModelInfo.class), null, null, action.toString(), null, null, null, null, null, null, false, null, null, null, null,
+ null);
}
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBaseTest.java b/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBaseTest.java
index 9cc97116b..9c0260e85 100644
--- a/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBaseTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBaseTest.java
@@ -171,11 +171,12 @@ public class AsyncInstantiationBaseTest extends AbstractTestNGSpringContextTests
vfModuleInfo.setModelInvariantId("22222222-f63c-463e-ba94-286933b895f9");
vfModuleInfo.setModelVersion("10.0");
return new VfModule(vfModuleInfo, instanceName, volumeGroupInstanceName, Action.Create.name(), "mdt1", null,
- "88a6ca3ee0394ade9403f075db23167e", instanceParams, supplementaryParams, false, true, null, UUID.randomUUID().toString(), null, null);
+ "88a6ca3ee0394ade9403f075db23167e", instanceParams, supplementaryParams, false, true, null, UUID.randomUUID().toString(), null, null,
+ null);
}
return new VfModule(vfModuleInfo, instanceName, volumeGroupInstanceName, Action.Create.name(), null, null, null,
- instanceParams, supplementaryParams, false, false, null, UUID.randomUUID().toString(), null, null);
+ instanceParams, supplementaryParams, false, false, null, UUID.randomUUID().toString(), null, null, null);
}
protected ModelInfo createVfModuleModelInfo(String modelName, String modelVersion, String modelVersionId, String modelInvariantId, String modelCustomizationId, String modelCustomizationName) {
@@ -184,7 +185,7 @@ public class AsyncInstantiationBaseTest extends AbstractTestNGSpringContextTests
protected VfModule createVfModuleForReplace(ModelInfo vfModuleModelInfo, String instanceName, String lcpCloudRegionId, String tenantId) {
return new VfModule( vfModuleModelInfo, instanceName, null, Action.Upgrade.name(), lcpCloudRegionId, null, tenantId,
- null, null, true, null, null, UUID.randomUUID().toString(), null, null);
+ null, null, true, null, null, UUID.randomUUID().toString(), null, null, null);
}
protected ModelInfo createVnfModelInfo(boolean isAlacarte) {
@@ -267,7 +268,7 @@ public class AsyncInstantiationBaseTest extends AbstractTestNGSpringContextTests
Vnf vnf = new Vnf(vnfModelInfo, "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", (isUserProvidedNaming ? VNF_NAME : null), Action.Create.name(),
"platformName", "mdt1", null, "88a6ca3ee0394ade9403f075db23167e", vnfInstanceParams,"lineOfBusinessName" , false, null, vfModules,
- UUID.randomUUID().toString(), null, null);
+ UUID.randomUUID().toString(), null, null, null);
vnfs.put(vnf.getModelInfo().getModelName(), vnf);
return vnfs;
@@ -320,7 +321,7 @@ public class AsyncInstantiationBaseTest extends AbstractTestNGSpringContextTests
details->new Network(createNetworkModelInfo(isALaCarte, details.modelCustomizationId), "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
details.name, Action.Create.name(),
"platformName", "mdt1", null, "88a6ca3ee0394ade9403f075db23167e", instanceParams,"lineOfBusinessName" ,
- false, null, UUID.randomUUID().toString(), null, null));
+ false, null, UUID.randomUUID().toString(), null, null, null));
// I can't tell why compiler don't like the statement if it's only one line...
return networkStream.collect(Collectors.toMap(network -> network.getModelInfo().getModelCustomizationId(), network -> network));
}
@@ -335,7 +336,8 @@ public class AsyncInstantiationBaseTest extends AbstractTestNGSpringContextTests
modelInfo.setModelInvariantId("11111111-f63c-463e-ba94-286933b895f9");
modelInfo.setModelVersion("10.0");
- return new InstanceGroup(modelInfo, (isUserProvidedNaming ? VNF_GROUP_NAME : null), action.name(), false, null, emptyMap(), UUID.randomUUID().toString(), null, null);
+ return new InstanceGroup(modelInfo, (isUserProvidedNaming ? VNF_GROUP_NAME : null), action.name(), false, null, emptyMap(), UUID.randomUUID().toString(), null, null,
+ null);
}
protected ModelInfo createServiceModelInfo() {
diff --git a/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBusinessLogicTest.java b/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBusinessLogicTest.java
index ce0aa42f2..c1a6abc73 100644
--- a/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBusinessLogicTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBusinessLogicTest.java
@@ -1048,7 +1048,7 @@ public class AsyncInstantiationBusinessLogicTest extends AsyncInstantiationBaseT
public void whenLcpRegionNotEmpty_thenCloudRegionIdOfResourceIsLegacy() {
String legacyCloudRegion = "legacyCloudRegion";
Vnf vnf = new Vnf(new ModelInfo(), null, null, Action.Create.name(), null, "anyCloudRegion", legacyCloudRegion,
- null, null, null, false, null, null, UUID.randomUUID().toString(), null, null);
+ null, null, null, false, null, null, UUID.randomUUID().toString(), null, null, null);
assertThat(vnf.getLcpCloudRegionId(), equalTo(legacyCloudRegion));
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/services/MsoRequestBuilderTest.java b/vid-app-common/src/test/java/org/onap/vid/services/MsoRequestBuilderTest.java
index 2c70b3ddc..e28ea304f 100644
--- a/vid-app-common/src/test/java/org/onap/vid/services/MsoRequestBuilderTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/services/MsoRequestBuilderTest.java
@@ -533,7 +533,8 @@ public class MsoRequestBuilderTest extends AsyncInstantiationBaseTest {
" }" +
"}";
Vnf vnfDetails = new Vnf(createVnfModelInfo(true), "productFamily", "instanceName", Action.Delete.name(), "platform", "AAIAIC25", null,
- "092eb9e8e4b7412e8787dd091bc58e86", null, null, false, "VNF_INSTANCE_ID", null, UUID.randomUUID().toString(), null, null);
+ "092eb9e8e4b7412e8787dd091bc58e86", null, null, false, "VNF_INSTANCE_ID", null, UUID.randomUUID().toString(), null, null,
+ null);
RequestDetailsWrapper<VnfInstantiationRequestDetails> result =
msoRequestBuilder.generateDeleteVnfRequest(vnfDetails, "az2018");
MsoOperationalEnvironmentTest.assertThatExpectationIsLikeObject(expected, result);