aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks/src/test
diff options
context:
space:
mode:
authorLukasz Muszkieta <lukasz.muszkieta@nokia.com>2021-01-15 11:15:58 +0100
committerLukasz Muszkieta <lukasz.muszkieta@nokia.com>2021-01-15 15:00:20 +0100
commit3b330924bcd41af4dbac2fd8cd1a55a62cc89c33 (patch)
tree940fb7e26c9079efcbfc5c2254577bb5caf77d3c /bpmn/so-bpmn-tasks/src/test
parent5e9676e8319a1867976ce2a09c607681c3445887 (diff)
add junit coverage
Issue-ID: SO-3433 Signed-off-by: Lukasz Muszkieta <lukasz.muszkieta@nokia.com> Change-Id: I04e8bcc47b92c20bd9eb2a61c243a808e1e312fd Signed-off-by: Lukasz Muszkieta <lukasz.muszkieta@nokia.com>
Diffstat (limited to 'bpmn/so-bpmn-tasks/src/test')
-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;
}