diff options
author | 2022-02-18 12:24:10 +0100 | |
---|---|---|
committer | 2022-02-23 15:28:29 +0000 | |
commit | 41df59d03938aca3f24ed5210d572b5017c3b98b (patch) | |
tree | ec0cbe3885968429fb3356f84301523a24f98bc4 | |
parent | a9347ca2183dca1f722efd89eb76808e38f5a645 (diff) |
Fix adapter unit tests
Issue-ID: SO-3845
Signed-off-by: Grzegorz Wielgosinski <g.wielgosins@samsung.com>
Change-Id: Idff45ed6973764b1802718ad8e3d1da0471ea09a
3 files changed, 10 insertions, 9 deletions
diff --git a/so-cnf-adapter-application/src/test/java/org/onap/so/adapters/cnf/service/aai/AaiIdGeneratorServiceTest.java b/so-cnf-adapter-application/src/test/java/org/onap/so/adapters/cnf/service/aai/AaiIdGeneratorServiceTest.java index 948bc0b..2ec3a76 100644 --- a/so-cnf-adapter-application/src/test/java/org/onap/so/adapters/cnf/service/aai/AaiIdGeneratorServiceTest.java +++ b/so-cnf-adapter-application/src/test/java/org/onap/so/adapters/cnf/service/aai/AaiIdGeneratorServiceTest.java @@ -6,10 +6,10 @@ import org.junit.runner.RunWith; import org.onap.so.adapters.cnf.model.instantiation.AaiRequest; import org.onap.so.adapters.cnf.model.statuscheck.K8sRbInstanceGvk; import org.onap.so.adapters.cnf.model.statuscheck.K8sRbInstanceResourceStatus; -import org.onap.so.adapters.cnf.util.IAaiRepository; +import org.onap.so.adapters.cnf.model.statuscheck.K8sStatus; +import org.onap.so.adapters.cnf.model.statuscheck.K8sStatusMetadata; import org.springframework.test.context.junit4.SpringRunner; -import static org.junit.jupiter.api.Assertions.fail; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -30,12 +30,16 @@ public class AaiIdGeneratorServiceTest { String cloudRegion = "cloudRegion"; String tenantId = "tenantId"; K8sRbInstanceResourceStatus resourceStatus = mock(K8sRbInstanceResourceStatus.class); + K8sStatus status = mock(K8sStatus.class); + K8sStatusMetadata metadata = mock(K8sStatusMetadata.class); AaiRequest aaiRequest = mock(AaiRequest.class); K8sRbInstanceGvk gvk = mock(K8sRbInstanceGvk.class); // when when(resourceStatus.getGvk()).thenReturn(gvk); when(resourceStatus.getName()).thenReturn(name); + when(resourceStatus.getStatus()).thenReturn(status); + when(status.getK8sStatusMetadata()).thenReturn(metadata); when(gvk.getKind()).thenReturn(kind); when(gvk.getGroup()).thenReturn(group); when(gvk.getVersion()).thenReturn(version); @@ -46,7 +50,7 @@ public class AaiIdGeneratorServiceTest { // then String actual = tested.generateId(resourceStatus, aaiRequest); - String expected = "a1b2c1f3dd0c76d65c6dbe97b17e0239163bc2c08e8e88e167bb90de9c7b0da1"; + String expected = "335d6ab87744a3140b36e70eee7537e97523b5e09f26d1d0ee887fd5839f87e2"; Assert.assertEquals(expected, actual); } diff --git a/so-cnf-adapter-application/src/test/java/org/onap/so/adapters/cnf/service/aai/AaiResponseParserTest.java b/so-cnf-adapter-application/src/test/java/org/onap/so/adapters/cnf/service/aai/AaiResponseParserTest.java index 8939afe..51b160e 100644 --- a/so-cnf-adapter-application/src/test/java/org/onap/so/adapters/cnf/service/aai/AaiResponseParserTest.java +++ b/so-cnf-adapter-application/src/test/java/org/onap/so/adapters/cnf/service/aai/AaiResponseParserTest.java @@ -94,9 +94,9 @@ public class AaiResponseParserTest { assertEquals(version, actual.getVersion()); assertEquals(kind, actual.getKind()); assertEquals(namespace, actual.getNamespace()); - assertEquals(4, actual.getLabels().size()); - assertEquals(INSTANCE_ID, actual.getLabels().get(0)); - assertEquals(INSTANCE_ID_VALUE, actual.getLabels().get(1)); + assertEquals(2, actual.getLabels().size()); + assertEquals("k8splugin.io/rb-instance-id=rb-instance-id_value", actual.getLabels().get(0)); + assertEquals("key=value", actual.getLabels().get(1)); assertEquals("http://so-cnf-adapter:8090/api/cnf-adapter/v1/instance/id/query?ApiVersion=version&Kind=kind&Name=name&Namespace=namespace", actual.getSelflink()); } } diff --git a/so-cnf-adapter-application/src/test/java/org/onap/so/adapters/cnf/service/aai/AaiServiceTest.java b/so-cnf-adapter-application/src/test/java/org/onap/so/adapters/cnf/service/aai/AaiServiceTest.java index a4e0625..96efbe9 100644 --- a/so-cnf-adapter-application/src/test/java/org/onap/so/adapters/cnf/service/aai/AaiServiceTest.java +++ b/so-cnf-adapter-application/src/test/java/org/onap/so/adapters/cnf/service/aai/AaiServiceTest.java @@ -76,11 +76,8 @@ public class AaiServiceTest { when(aaiRequest.getInstanceId()).thenReturn(instanceId); when(multicloudClient.getInstanceStatus(instanceId)).thenReturn(instanceStatus); when(instanceStatus.getResourcesStatus()).thenReturn(resourcesStatus); - when(responseParser.parse(status, aaiRequest)).thenReturn(parseResult); // then aaiServiceTested.aaiDelete(aaiRequest); - - verify(responseParser, atLeast(1)).parse(status, aaiRequest); } } |