aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks
diff options
context:
space:
mode:
authorSeshu Kumar M <seshu.kumar.m@huawei.com>2021-01-29 09:42:05 +0000
committerGerrit Code Review <gerrit@onap.org>2021-01-29 09:42:05 +0000
commitd6194580f506ace2bf289eab17133c10ef912eed (patch)
treea595874127abd3401ddbb65ef6d2344d00172cd5 /bpmn/so-bpmn-tasks
parent48b66d5f6facafef4478a261a39d87ed525f17fd (diff)
parent3b330924bcd41af4dbac2fd8cd1a55a62cc89c33 (diff)
Merge "add junit coverage"
Diffstat (limited to 'bpmn/so-bpmn-tasks')
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionExtractResourcesAAITest.java83
1 files changed, 78 insertions, 5 deletions
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionExtractResourcesAAITest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionExtractResourcesAAITest.java
index 35a5bfefd7..7ac245d0f4 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionExtractResourcesAAITest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionExtractResourcesAAITest.java
@@ -56,7 +56,8 @@ public class WorkflowActionExtractResourcesAAITest {
public void extractRelationshipsConfigurationSuccess() {
// given
Relationships relationships = mock(Relationships.class);
- when(relationships.getByType(Types.CONFIGURATION)).thenReturn(getConfigurationList());
+ when(relationships.getByType(Types.CONFIGURATION))
+ .thenReturn(getConfigurationList("{\"configuration-id\" : \"" + CONFIGURATION_ID + "\"}"));
// when
Optional<Configuration> resultOpt = testedObject.extractRelationshipsConfiguration(relationships);
// then
@@ -65,7 +66,18 @@ public class WorkflowActionExtractResourcesAAITest {
}
@Test
- public void extractRelationshipsConfiguration_notFound() {
+ public void extractRelationshipsConfiguration_noConfigurationFoundInList() {
+ // given
+ Relationships relationships = mock(Relationships.class);
+ when(relationships.getByType(Types.CONFIGURATION)).thenReturn(getConfigurationList("noJson"));
+ // when
+ Optional<Configuration> resultOpt = testedObject.extractRelationshipsConfiguration(relationships);
+ // then
+ assertThat(resultOpt).isEmpty();
+ }
+
+ @Test
+ public void extractRelationshipsConfiguration_notFound_listEmpty() {
// given
Relationships relationships = mock(Relationships.class);
when(relationships.getByType(Types.CONFIGURATION)).thenReturn(Collections.emptyList());
@@ -92,10 +104,71 @@ public class WorkflowActionExtractResourcesAAITest {
assertThat(resultOpt.get().getVpnId()).isEqualTo(VPN_ID);
}
- private List<AAIResultWrapper> getConfigurationList() {
+ @Test
+ public void extractRelationshipsVpnBinding_noVpnBindingFoundInList() {
+ // given
+ Relationships relationships = mock(Relationships.class);
+ AAIResourceUri aaiResourceUri = mock(AAISimpleUri.class);
+ List<AAIResourceUri> aaiResourceUriList = new ArrayList<>();
+ aaiResourceUriList.add(aaiResourceUri);
+ when(relationships.getRelatedUris(Types.VPN_BINDING)).thenReturn(aaiResourceUriList);
+ AAIResultWrapper aaiResultWrapper = new AAIResultWrapper("noJson");
+ when(bbInputSetupUtils.getAAIResourceDepthOne(aaiResourceUri)).thenReturn(aaiResultWrapper);
+ // when
+ Optional<VpnBinding> resultOpt = testedObject.extractRelationshipsVpnBinding(relationships);
+ // then
+ assertThat(resultOpt).isEmpty();
+ }
+
+ @Test
+ public void extractRelationshipsVpnBinding_notFound_listEmpty() {
+ // given
+ Relationships relationships = mock(Relationships.class);
+ when(relationships.getRelatedUris(Types.VPN_BINDING)).thenReturn(Collections.emptyList());
+ // when
+ Optional<VpnBinding> resultOpt = testedObject.extractRelationshipsVpnBinding(relationships);
+ // then
+ assertThat(resultOpt).isEmpty();
+ }
+
+ @Test
+ public void extractRelationshipsVnfcSuccess() {
+ // given
+ Relationships relationships = mock(Relationships.class);
+ when(relationships.getByType(Types.VNFC)).thenReturn(
+ getConfigurationList("{\"relationship-list\": {\"relationship\": [{\"related-to\": \"tenant\"}]}}"));
+ // when
+ Optional<Relationships> resultOpt = testedObject.extractRelationshipsVnfc(relationships);
+ // then
+ assertThat(resultOpt).isNotEmpty();
+ assertThat(resultOpt.get().getJson()).isEqualTo("{\"relationship\":[{\"related-to\":\"tenant\"}]}");
+ }
+
+ @Test
+ public void extractRelationshipsVnfc_noRelationFoundList() {
+ // given
+ Relationships relationships = mock(Relationships.class);
+ when(relationships.getByType(Types.VNFC)).thenReturn(getConfigurationList("{\"jsonWithNoRelation\": {}}"));
+ // when
+ Optional<Relationships> resultOpt = testedObject.extractRelationshipsVnfc(relationships);
+ // then
+ assertThat(resultOpt).isEmpty();
+ }
+
+ @Test
+ public void extractRelationshipsVnfc_notFound_listEmpty() {
+ // given
+ Relationships relationships = mock(Relationships.class);
+ when(relationships.getByType(Types.VNFC)).thenReturn(Collections.emptyList());
+ // when
+ Optional<Relationships> resultOpt = testedObject.extractRelationshipsVnfc(relationships);
+ // then
+ assertThat(resultOpt).isEmpty();
+ }
+
+ private List<AAIResultWrapper> getConfigurationList(String json) {
List<AAIResultWrapper> configurations = new ArrayList<>();
- AAIResultWrapper aaiResultWrapper =
- new AAIResultWrapper("{\"configuration-id\" : \"" + CONFIGURATION_ID + "\"}");
+ AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(json);
configurations.add(aaiResultWrapper);
return configurations;
}