Create tests for AAIRepository 64/141564/2
authorFiete Ostkamp <Fiete.Ostkamp@telekom.de>
Mon, 21 Jul 2025 19:56:37 +0000 (21:56 +0200)
committerFiete Ostkamp <Fiete.Ostkamp@telekom.de>
Tue, 22 Jul 2025 11:25:58 +0000 (13:25 +0200)
- create integration test that asserts http requests
  towards AAI
- bump snapshot version to 1.13.1-SNAPSHOT

Issue-ID: AAI-4191
Change-Id: I104c2ea0ecef64dcebdea5e02c14a37df82c1a21
Signed-off-by: Fiete Ostkamp <Fiete.Ostkamp@telekom.de>
23 files changed:
.gitignore
packages/docker/pom.xml
packages/pom.xml
pom.xml
so-cnf-adapter-application/pom.xml
so-cnf-adapter-application/src/main/java/org/onap/so/adapters/cnf/rest/CnfAdapterRest.java
so-cnf-adapter-application/src/test/java/org/onap/so/adapters/cnf/util/AaiRepositoryTest.java [new file with mode: 0644]
so-cnf-adapter-application/src/test/resources/__files/bulkDeleteRequestBody.json [new file with mode: 0644]
so-cnf-adapter-application/src/test/resources/__files/bulkProcessRequestBody.json [new file with mode: 0644]
so-cnf-adapter-application/src/test/resources/__files/bulkProcessVnfVfModuleRequest.json [new file with mode: 0644]
so-cnf-adapter-application/src/test/resources/__files/genericVnf.json [new file with mode: 0644]
so-cnf-adapter-application/src/test/resources/__files/k8sResource.json [new file with mode: 0644]
so-cnf-adapter-application/src/test/resources/__files/k8sResourceExistsResponse.json [new file with mode: 0644]
so-cnf-adapter-application/src/test/resources/__files/k8sResourceNotFoundResponse.json [new file with mode: 0644]
so-cnf-adapter-application/src/test/resources/__files/vfModule.json [new file with mode: 0644]
so-cnf-adapter-application/src/test/resources/__files/vfModuleWithRelationshipsResponse.json [new file with mode: 0644]
so-cnfm/pom.xml
so-cnfm/so-cnfm-lcm/pom.xml
so-cnfm/so-cnfm-lcm/so-cnfm-lcm-api/pom.xml
so-cnfm/so-cnfm-lcm/so-cnfm-lcm-application/pom.xml
so-cnfm/so-cnfm-lcm/so-cnfm-lcm-bpmn-flows/pom.xml
so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/pom.xml
so-cnfm/so-cnfm-lcm/so-cnfm-lcm-service/pom.xml

index e361410..b2e3a1c 100644 (file)
@@ -24,3 +24,4 @@ target
 **/.sts4-cache
 **/.java-version
 .vscode
+*.http
index b638d93..6c52063 100755 (executable)
@@ -4,10 +4,10 @@
     <parent>
         <groupId>org.onap.so.adapters.so-cnf-adapter</groupId>
         <artifactId>packages</artifactId>
-        <version>1.13.0-SNAPSHOT</version>
+        <version>1.13.1-SNAPSHOT</version>
     </parent>
     <groupId>org.onap.so.adapters.so-cnf-adapter.packages</groupId>
-    <version>1.13.0-SNAPSHOT</version>
+    <version>1.13.1-SNAPSHOT</version>
     <packaging>pom</packaging>
     <artifactId>docker</artifactId>
     <name>Docker Packaging</name>
index 7969a86..02398e4 100644 (file)
@@ -4,11 +4,11 @@
     <parent>
         <groupId>org.onap.so.adapters.so-cnf-adapter</groupId>
         <artifactId>so-cnf-adapter</artifactId>
-        <version>1.13.0-SNAPSHOT</version>
+        <version>1.13.1-SNAPSHOT</version>
     </parent>
     <artifactId>packages</artifactId>
     <packaging>pom</packaging>
-    <version>1.13.0-SNAPSHOT</version>
+    <version>1.13.1-SNAPSHOT</version>
     <name>Packages</name>
 
     <profiles>
diff --git a/pom.xml b/pom.xml
index 519ca1b..15817f2 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -8,7 +8,7 @@
     </parent>
     <groupId>org.onap.so.adapters.so-cnf-adapter</groupId>
     <artifactId>so-cnf-adapter</artifactId>
-    <version>1.13.0-SNAPSHOT</version>
+    <version>1.13.1-SNAPSHOT</version>
     <name>SO CNF Adapter</name>
     <packaging>pom</packaging>
 
index 5783ecb..d0daeb0 100755 (executable)
     <parent>
         <groupId>org.onap.so.adapters.so-cnf-adapter</groupId>
         <artifactId>so-cnf-adapter</artifactId>
-        <version>1.13.0-SNAPSHOT</version>
+        <version>1.13.1-SNAPSHOT</version>
     </parent>
   <artifactId>so-cnf-adapter-application</artifactId>
-  <version>1.13.0-SNAPSHOT</version>
+  <version>1.13.1-SNAPSHOT</version>
   <name>SO CNF Application Jar</name>
   <build>
     <finalName>${project.artifactId}-${project.version}</finalName>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.jacoco</groupId>
+          <artifactId>jacoco-maven-plugin</artifactId>
+          <configuration>
+            <excludes>
+                <exclude>org/onap/so/adapters/cnf/model/**</exclude>
+            </excludes>
+          </configuration>
+        </plugin>
+      </plugins>
+    </pluginManagement>
     <plugins>
       <plugin>
         <groupId>org.springframework.boot</groupId>
index afce775..baa62c1 100644 (file)
@@ -161,7 +161,7 @@ public class CnfAdapterRest {
                 synchronizationService.createSubscriptionIfNotExists(aaiRequest);
                 callbackResponse.setCompletionStatus(AaiCallbackResponse.CompletionStatus.COMPLETED);
             } catch (Exception e) {
-                logger.warn("Failed to create resource in AAI", e);
+                logger.warn("Failed to create resource in AAI {}", e);
                 callbackResponse.setCompletionStatus(AaiCallbackResponse.CompletionStatus.FAILED);
                 callbackResponse.setMessage(e.getMessage());
             }
@@ -187,7 +187,7 @@ public class CnfAdapterRest {
                 aaiService.aaiDelete(aaiRequest);
                 callbackResponse.setCompletionStatus(AaiCallbackResponse.CompletionStatus.COMPLETED);
             } catch (Exception e) {
-                logger.warn("Failed to delete resource from AAI", e);
+                logger.warn("Failed to delete resource from AAI {}", e);
                 callbackResponse.setCompletionStatus(AaiCallbackResponse.CompletionStatus.FAILED);
                 callbackResponse.setMessage(e.getMessage());
             }
@@ -211,7 +211,7 @@ public class CnfAdapterRest {
             try {
                 statusCheckResponse = simpleStatusCheckService.statusCheck(statusCheckRequest);
             } catch (Exception e) {
-                logger.error("END - Status check process failed", e);
+                logger.error("END - Status check process failed {}", e);
                 statusCheckResponse = simpleStatusCheckService.statusCheckError(statusCheckRequest, e);
             }
             callbackClient.sendPostCallback(statusCheckRequest.getCallbackUrl(), statusCheckResponse);
@@ -329,7 +329,7 @@ public class CnfAdapterRest {
 
         try (CloseableHttpClient httpClient = HttpClients.createDefault();
              CloseableHttpResponse response = httpClient.execute(post)) {
-            logger.info("response:" + response.getEntity());
+            logger.info("response: " + response.getEntity());
             return EntityUtils.toString(response.getEntity());
         }
     }
@@ -364,7 +364,7 @@ public class CnfAdapterRest {
         HttpDelete req = new HttpDelete(uri + "/v1/rb/definition/" + rbName + "/" + rbVersion);
 
         try (CloseableHttpResponse response = httpClient.execute(req)) {
-            logger.info("response:" + response.getEntity());
+            logger.info("response: " + response.getEntity());
             return EntityUtils.toString(response.getEntity());
         }
 
@@ -382,7 +382,7 @@ public class CnfAdapterRest {
         HttpGet req = new HttpGet(uri + "/v1/rb/definition/" + rbName);
 
         try (CloseableHttpResponse response = httpClient.execute(req)) {
-            logger.info("response:" + response.getEntity());
+            logger.info("response: " + response.getEntity());
             return EntityUtils.toString(response.getEntity());
         }
 
@@ -475,7 +475,7 @@ public class CnfAdapterRest {
                 uri + "/v1/rb/definition/" + rbName + "/" + rbVersion + "/profile/" + prName);
 
         try (CloseableHttpResponse response = httpClient.execute(req)) {
-            logger.info("response:" + response.getEntity());
+            logger.info("response: " + response.getEntity());
             return EntityUtils.toString(response.getEntity());
         }
     }
@@ -494,7 +494,7 @@ public class CnfAdapterRest {
                 new HttpGet(uri + "/v1/rb/definition/" + rbName + "/" + rbVersion + "/profile");
 
         try (CloseableHttpResponse response = httpClient.execute(req)) {
-            logger.info("response:" + response.getEntity());
+            logger.info("response: " + response.getEntity());
             return EntityUtils.toString(response.getEntity());
         }
     }
@@ -513,7 +513,7 @@ public class CnfAdapterRest {
                 uri + "/v1/rb/definition/" + rbName + "/" + rbVersion + "/profile/" + prName);
 
         try (CloseableHttpResponse response = httpClient.execute(req)) {
-            logger.info("response:" + response.getEntity());
+            logger.info("response: " + response.getEntity());
             return EntityUtils.toString(response.getEntity());
         }
 
@@ -547,7 +547,7 @@ public class CnfAdapterRest {
 
         try (CloseableHttpClient httpClient = HttpClients.createDefault();
              CloseableHttpResponse response = httpClient.execute(post)) {
-            logger.info("response:" + response.getEntity());
+            logger.info("response: " + response.getEntity());
             return EntityUtils.toString(response.getEntity());
         }
     }
@@ -572,7 +572,7 @@ public class CnfAdapterRest {
 
         try (CloseableHttpClient httpClient = HttpClients.createDefault();
              CloseableHttpResponse response = httpClient.execute(post)) {
-            logger.info("response:" + response.getEntity());
+            logger.info("response: " + response.getEntity());
             return EntityUtils.toString(response.getEntity());
         }
     }
@@ -592,7 +592,7 @@ public class CnfAdapterRest {
                 + prName + "/config/" + cfgName);
 
         try (CloseableHttpResponse response = httpClient.execute(req)) {
-            logger.info("response:" + response.getEntity());
+            logger.info("response: " + response.getEntity());
             return EntityUtils.toString(response.getEntity());
         }
     }
@@ -613,7 +613,7 @@ public class CnfAdapterRest {
                 + "/profile/" + prName + "/config/" + cfgName);
 
         try (CloseableHttpResponse response = httpClient.execute(req)) {
-            logger.info("response:" + response.getEntity());
+            logger.info("response: " + response.getEntity());
             return EntityUtils.toString(response.getEntity());
         }
 
@@ -640,7 +640,7 @@ public class CnfAdapterRest {
 
         try (CloseableHttpClient httpClient = HttpClients.createDefault();
              CloseableHttpResponse response = httpClient.execute(post)) {
-            logger.info("response:" + response.getEntity());
+            logger.info("response: " + response.getEntity());
             return EntityUtils.toString(response.getEntity());
         }
     }
@@ -664,7 +664,7 @@ public class CnfAdapterRest {
 
         try (CloseableHttpClient httpClient = HttpClients.createDefault();
              CloseableHttpResponse response = httpClient.execute(post)) {
-            logger.info("response:" + response.getEntity());
+            logger.info("response: " + response.getEntity());
             return EntityUtils.toString(response.getEntity());
         }
     }
@@ -686,7 +686,7 @@ public class CnfAdapterRest {
 
         try (CloseableHttpClient httpClient = HttpClients.createDefault();
              CloseableHttpResponse response = httpClient.execute(post)) {
-            logger.info("response:" + response.getEntity());
+            logger.info("response: " + response.getEntity());
             return EntityUtils.toString(response.getEntity());
         }
     }
@@ -703,7 +703,7 @@ public class CnfAdapterRest {
         HttpGet req = new HttpGet(uri + "/v1/connectivity-info/" + connName);
 
         try (CloseableHttpResponse response = httpClient.execute(req)) {
-            logger.info("response:" + response.getEntity());
+            logger.info("response: " + response.getEntity());
             return EntityUtils.toString(response.getEntity());
         }
     }
@@ -720,7 +720,7 @@ public class CnfAdapterRest {
         HttpDelete req = new HttpDelete(uri + "/v1/connectivity-info/" + connName);
 
         try (CloseableHttpResponse response = httpClient.execute(req)) {
-            logger.info("response:" + response.getEntity());
+            logger.info("response: " + response.getEntity());
             return EntityUtils.toString(response.getEntity());
         }
 
@@ -745,7 +745,7 @@ public class CnfAdapterRest {
 
         try (CloseableHttpClient httpClient = HttpClients.createDefault();
              CloseableHttpResponse response = httpClient.execute(post)) {
-            logger.info("response:" + response.getEntity());
+            logger.info("response: " + response.getEntity());
             return EntityUtils.toString(response.getEntity());
         }
     }
@@ -764,7 +764,7 @@ public class CnfAdapterRest {
                 + "/config-template/" + tName);
 
         try (CloseableHttpResponse response = httpClient.execute(req)) {
-            logger.info("response:" + response.getEntity());
+            logger.info("response: " + response.getEntity());
             return EntityUtils.toString(response.getEntity());
         }
     }
@@ -783,7 +783,7 @@ public class CnfAdapterRest {
                 + "/config-template/" + tName);
 
         try (CloseableHttpResponse response = httpClient.execute(req)) {
-            logger.info("response:" + response.getEntity());
+            logger.info("response: " + response.getEntity());
             return EntityUtils.toString(response.getEntity());
         }
 
@@ -818,7 +818,7 @@ public class CnfAdapterRest {
 
         try (CloseableHttpClient httpClient = HttpClients.createDefault();
              CloseableHttpResponse response = httpClient.execute(post)) {
-            logger.info("response:" + response.getEntity());
+            logger.info("response: " + response.getEntity());
             return EntityUtils.toString(response.getEntity());
         }
     }
@@ -843,7 +843,7 @@ public class CnfAdapterRest {
 
         try (CloseableHttpClient httpClient = HttpClients.createDefault();
              CloseableHttpResponse response = httpClient.execute(post)) {
-            logger.info("response:" + response.getEntity());
+            logger.info("response: " + response.getEntity());
             return EntityUtils.toString(response.getEntity());
         }
     }
diff --git a/so-cnf-adapter-application/src/test/java/org/onap/so/adapters/cnf/util/AaiRepositoryTest.java b/so-cnf-adapter-application/src/test/java/org/onap/so/adapters/cnf/util/AaiRepositoryTest.java
new file mode 100644 (file)
index 0000000..e5a8a9d
--- /dev/null
@@ -0,0 +1,156 @@
+/*
+ * Copyright Â© 2025 Deutsche Telekom
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.so.adapters.cnf.util;
+
+import org.apache.http.entity.ContentType;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.so.adapters.cnf.model.aai.AaiRequest;
+import org.onap.so.adapters.cnf.service.aai.KubernetesResource;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
+import org.springframework.boot.web.server.LocalServerPort;
+import org.springframework.http.HttpStatus;
+import org.springframework.test.context.DynamicPropertyRegistry;
+import org.springframework.test.context.DynamicPropertySource;
+import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.util.SocketUtils;
+import org.springframework.web.client.RestTemplate;
+import org.springframework.web.util.DefaultUriBuilderFactory;
+
+import com.github.tomakehurst.wiremock.client.WireMock;
+import com.github.tomakehurst.wiremock.junit.WireMockRule;
+
+import static com.github.tomakehurst.wiremock.client.WireMock.exactly;
+import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
+
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.List;
+
+import lombok.SneakyThrows;
+
+@SpringBootTest
+@RunWith(SpringRunner.class)
+public class AaiRepositoryTest {
+
+  private static int wireMockPort = SocketUtils.findAvailableTcpPort();
+
+  @Rule
+  public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().port(wireMockPort));
+
+  @DynamicPropertySource
+  static void configureProperties(DynamicPropertyRegistry registry) {
+    registry.add("aai.enabled", () -> "true");
+    registry.add("aai.endpoint", () -> "http://localhost:" + wireMockPort);
+  }
+
+  @Test
+  @SneakyThrows
+  public void thatAAIResourcesCanBeUpdated() {
+    final String K8S_URL = "/aai/v24/cloud-infrastructure/cloud-regions/cloud-region/someOwner/someRegion/tenants/tenant/someTenant/k8s-resources/k8s-resource/someId";
+    WireMock.stubFor(WireMock.get(WireMock.urlEqualTo(K8S_URL))
+        .willReturn(WireMock.aResponse().withStatus(HttpStatus.OK.value()).withBodyFile("k8sResource.json")));
+    final String VFMODULE_URL = "/aai/v24/network/generic-vnfs/generic-vnf/someGenericVnfId/vf-modules/vf-module/someVfModuleId";
+    WireMock.stubFor(WireMock.get(WireMock.urlEqualTo(VFMODULE_URL))
+        .willReturn(WireMock.aResponse().withStatus(HttpStatus.OK.value()).withBodyFile("vfModule.json")));
+    final String GENERIC_VNF_URL = "/aai/v24/network/generic-vnfs/generic-vnf/someGenericVnfId";
+    WireMock.stubFor(WireMock.get(WireMock.urlEqualTo(GENERIC_VNF_URL))
+        .willReturn(WireMock.aResponse().withStatus(HttpStatus.OK.value()).withBodyFile("genericVnf.json")));
+    final String BULK_URL = "/aai/v24/bulkprocess";
+    final String expectedBulkBody = new String(
+        Files.readAllBytes(Paths.get("src/test/resources/__files/bulkProcessRequestBody.json")));
+    WireMock.stubFor(WireMock.put(WireMock.urlEqualTo(BULK_URL)).withRequestBody(WireMock.equalToJson(expectedBulkBody))
+        .willReturn(WireMock.aResponse().withStatus(HttpStatus.CREATED.value()).withBody("{}")));
+    final String expectedVnfVfModuleBulkBody = new String(
+        Files.readAllBytes(Paths.get("src/test/resources/__files/bulkProcessVnfVfModuleRequest.json")));
+    WireMock.stubFor(
+        WireMock.put(WireMock.urlEqualTo(BULK_URL)).withRequestBody(WireMock.equalToJson(expectedVnfVfModuleBulkBody))
+            .willReturn(WireMock.aResponse().withStatus(HttpStatus.CREATED.value()).withBody("{}")));
+
+    KubernetesResource resource = new KubernetesResource();
+    resource.setId("someId");
+    resource.setName("someName");
+    AaiRequest request = new AaiRequest();
+    request.setCloudOwner("someOwner");
+    request.setCloudRegion("someRegion");
+    request.setTenantId("someTenant");
+    request.setGenericVnfId("someGenericVnfId");
+    request.setVfModuleId("someVfModuleId");
+    IAaiRepository aaiRepository = IAaiRepository.instance(true);
+    aaiRepository.update(resource, request);
+    WireMock.verify(exactly(0), WireMock.putRequestedFor(WireMock.urlEqualTo(BULK_URL)));
+    aaiRepository.commit(false);
+    WireMock.verify(WireMock.getRequestedFor(WireMock.urlEqualTo(K8S_URL)));
+    WireMock.verify(WireMock.putRequestedFor(WireMock.urlEqualTo(BULK_URL))
+        .withRequestBody(WireMock.equalToJson(expectedBulkBody)));
+    WireMock.verify(WireMock.putRequestedFor(WireMock.urlEqualTo(BULK_URL))
+        .withRequestBody(WireMock.equalToJson(expectedVnfVfModuleBulkBody)));
+  }
+
+  @Test
+  @SneakyThrows
+  public void thatAAIResourcesCanBeDeleted() {
+    final String K8S_NOT_FOUND_URL = "/aai/v24/cloud-infrastructure/cloud-regions/cloud-region/someCloudOwner/someCloudRegionId/tenants/tenant/someTenantId/k8s-resources/k8s-resource/doesNotExist";
+    WireMock.stubFor(WireMock.get(WireMock.urlEqualTo(K8S_NOT_FOUND_URL))
+        .willReturn(WireMock.aResponse().withStatus(HttpStatus.NOT_FOUND.value())
+            .withBodyFile("k8sResourceNotFoundResponse.json")));
+    final String K8S_URL = "/aai/v24/cloud-infrastructure/cloud-regions/cloud-region/someCloudOwner/someCloudRegionId/tenants/tenant/someTenantId/k8s-resources/k8s-resource/someK8sResource";
+    WireMock.stubFor(WireMock.get(WireMock.urlEqualTo(K8S_URL))
+        .willReturn(WireMock.aResponse().withStatus(HttpStatus.OK.value()).withBodyFile("k8sResource.json")));
+    final String K8S_EXISTS_URL = "/aai/v24/cloud-infrastructure/cloud-regions/cloud-region/someOwner/someRegion/tenants/tenant/someTenant/k8s-resources/k8s-resource/12345";
+    final String K8S_EXISTS_URL_MINIMAL = "/aai/v24/cloud-infrastructure/cloud-regions/cloud-region/someOwner/someRegion/tenants/tenant/someTenant/k8s-resources/k8s-resource/12345?format=count&resultIndex=0&resultSize=1";
+    WireMock.stubFor(WireMock.get(WireMock.urlEqualTo(K8S_EXISTS_URL_MINIMAL))
+        .willReturn(
+            WireMock.aResponse().withStatus(HttpStatus.OK.value()).withBodyFile("k8sResourceExistsResponse.json")));
+    WireMock.stubFor(WireMock.get(WireMock.urlEqualTo(K8S_EXISTS_URL))
+        .willReturn(WireMock.aResponse().withStatus(HttpStatus.OK.value()).withBodyFile("k8sResource.json").withHeader("Content-Type", ContentType.APPLICATION_JSON.toString())));
+    WireMock.stubFor(WireMock.delete(WireMock.urlEqualTo(K8S_EXISTS_URL))
+        .willReturn(WireMock.aResponse().withStatus(HttpStatus.OK.value())));
+    final String VFMODULE_URL = "/aai/v24/network/generic-vnfs/generic-vnf/someGenericVnfId/vf-modules/vf-module/someVfModuleId";
+    WireMock.stubFor(WireMock.get(WireMock.urlEqualTo(VFMODULE_URL))
+        .willReturn(WireMock.aResponse().withStatus(HttpStatus.OK.value())
+            .withBodyFile("vfModuleWithRelationshipsResponse.json")));
+
+    final String BULK_URL = "/aai/v24/bulkprocess";
+    final String expectedBulkBody = new String(
+        Files.readAllBytes(Paths.get("src/test/resources/__files/bulkDeleteRequestBody.json")));
+    WireMock.stubFor(WireMock.put(WireMock.urlEqualTo(BULK_URL)).withRequestBody(WireMock.equalToJson(expectedBulkBody))
+        .willReturn(WireMock.aResponse().withStatus(HttpStatus.CREATED.value()).withBody("{}")));
+
+    KubernetesResource resource = new KubernetesResource();
+    resource.setId("someId");
+    resource.setName("someName");
+    AaiRequest request = new AaiRequest();
+    request.setCloudOwner("someOwner");
+    request.setCloudRegion("someRegion");
+    request.setTenantId("someTenant");
+    request.setGenericVnfId("someGenericVnfId");
+    request.setVfModuleId("someVfModuleId");
+    IAaiRepository aaiRepository = IAaiRepository.instance(true);
+    List<KubernetesResource> resourceList = new ArrayList<>();
+    resourceList.add(resource);
+    aaiRepository.delete(request, resourceList);
+    WireMock.verify(exactly(0),WireMock.deleteRequestedFor(WireMock.urlEqualTo(BULK_URL)));
+    aaiRepository.commit(false);
+    WireMock.verify(WireMock.putRequestedFor(WireMock.urlEqualTo(BULK_URL))
+        .withRequestBody(WireMock.equalToJson(expectedBulkBody)));
+  }
+}
diff --git a/so-cnf-adapter-application/src/test/resources/__files/bulkDeleteRequestBody.json b/so-cnf-adapter-application/src/test/resources/__files/bulkDeleteRequestBody.json
new file mode 100644 (file)
index 0000000..46b419b
--- /dev/null
@@ -0,0 +1,11 @@
+{
+  "transactions": [
+    {
+      "delete": [
+        {
+          "uri": "/cloud-infrastructure/cloud-regions/cloud-region/someOwner/someRegion/tenants/tenant/someTenant/k8s-resources/k8s-resource/12345?resource-version=3.0"
+        }
+      ]
+    }
+  ]
+}
diff --git a/so-cnf-adapter-application/src/test/resources/__files/bulkProcessRequestBody.json b/so-cnf-adapter-application/src/test/resources/__files/bulkProcessRequestBody.json
new file mode 100644 (file)
index 0000000..8a1c3d1
--- /dev/null
@@ -0,0 +1,16 @@
+{
+  "transactions": [
+    {
+      "put": [
+        {
+          "uri": "/cloud-infrastructure/cloud-regions/cloud-region/someOwner/someRegion/tenants/tenant/someTenant/k8s-resources/k8s-resource/someId",
+          "body": {
+            "id": "someId",
+            "name": "someName",
+            "resource-version": "3.0"
+          }
+        }
+      ]
+    }
+  ]
+}
diff --git a/so-cnf-adapter-application/src/test/resources/__files/bulkProcessVnfVfModuleRequest.json b/so-cnf-adapter-application/src/test/resources/__files/bulkProcessVnfVfModuleRequest.json
new file mode 100644 (file)
index 0000000..cb6ed81
--- /dev/null
@@ -0,0 +1,20 @@
+{
+  "transactions": [
+    {
+      "put": [
+        {
+          "uri": "/cloud-infrastructure/cloud-regions/cloud-region/someOwner/someRegion/tenants/tenant/someTenant/k8s-resources/k8s-resource/someId/relationship-list/relationship",
+          "body": {
+            "related-link": "/network/generic-vnfs/generic-vnf/someGenericVnfId/vf-modules/vf-module/someVfModuleId"
+          }
+        },
+        {
+          "uri": "/cloud-infrastructure/cloud-regions/cloud-region/someOwner/someRegion/tenants/tenant/someTenant/k8s-resources/k8s-resource/someId/relationship-list/relationship",
+          "body": {
+            "related-link": "/network/generic-vnfs/generic-vnf/someGenericVnfId"
+          }
+        }
+      ]
+    }
+  ]
+}
diff --git a/so-cnf-adapter-application/src/test/resources/__files/genericVnf.json b/so-cnf-adapter-application/src/test/resources/__files/genericVnf.json
new file mode 100644 (file)
index 0000000..2400a36
--- /dev/null
@@ -0,0 +1,67 @@
+{
+  "vnf-id": "someGenericVnfId",
+  "vnf-instance-id": "instance-id-001",
+  "vnf-name": "exampleVnfName",
+  "vnf-name2": "exampleVnfAlternateName",
+  "vnf-type": "exampleVnfType",
+  "service-id": "service-id-001",
+  "regional-resource-zone": "zone-001",
+  "prov-status": "active",
+  "operational-status": "in-service-path",
+  "license-key": "obsolete-license-key",
+  "equipment-role": "exampleRole",
+  "orchestration-status": "orchestrated",
+  "vnf-package-name": "package-name-001",
+  "vnf-discriptor-name": "descriptor-name-001",
+  "job-id": "job-id-001",
+  "heat-stack-id": "heat-stack-id-001",
+  "mso-catalog-key": "catalog-key-001",
+  "management-option": "managed-customer-id-001",
+  "ipv4-oam-address": "192.168.1.1",
+  "ipv4-loopback0-address": "192.168.1.2",
+  "nm-lan-v6-address": "2001:db8::1",
+  "management-v6-address": "2001:db8::2",
+  "vcpu": 4,
+  "vcpu-units": "cores",
+  "vmemory": 16,
+  "vmemory-units": "GB",
+  "vdisk": 100,
+  "vdisk-units": "GB",
+  "nshd": 1,
+  "nvm": 2,
+  "nnet": 3,
+  "in-maint": false,
+  "is-closed-loop-disabled": false,
+  "summary-status": "operation-summary",
+  "encrypted-access-flag": true,
+  "entitlement-assignment-group-uuid": "obsolete-assignment-group-uuid",
+  "entitlement-resource-uuid": "obsolete-resource-uuid",
+  "license-assignment-group-uuid": "obsolete-license-assignment-group-uuid",
+  "license-key-uuid": "obsolete-license-key-uuid",
+  "model-invariant-id": "model-invariant-id-001",
+  "model-version-id": "model-version-id-001",
+  "persona-model-version": "persona-model-version-001",
+  "model-customization-id": "model-customization-id-001",
+  "widget-model-id": "widget-model-id-001",
+  "widget-model-version": "widget-model-version-001",
+  "as-number": "as-number-001",
+  "regional-resource-subzone": "subzone-001",
+  "nf-type": "network-function-type",
+  "nf-function": "network-function-description",
+  "nf-role": "network-role",
+  "nf-naming-code": "naming-code-001",
+  "selflink": "http://example.com/selflink/genericVnf",
+  "ipv4-oam-gateway-address": "192.168.1.254",
+  "ipv4-oam-gateway-address-prefix-length": 24,
+  "vlan-id-outer": 100,
+  "nm-profile-name": "nm-profile-001",
+  "software-version": "1.0.0",
+  "application-id": "application-id-001",
+  "l-interfaces": {},
+  "lag-interfaces": {},
+  "vf-modules": {},
+  "licenses": {},
+  "bgp-groups": {},
+  "bgp-neighbors": {},
+  "entitlements": {}
+}
diff --git a/so-cnf-adapter-application/src/test/resources/__files/k8sResource.json b/so-cnf-adapter-application/src/test/resources/__files/k8sResource.json
new file mode 100644 (file)
index 0000000..ec3702d
--- /dev/null
@@ -0,0 +1,18 @@
+{
+  "id": "12345",
+  "name": "someName",
+  "group": "someGroup",
+  "version": "1.0",
+  "kind": "someKind",
+  "namespace": "someNamespace",
+  "labels": [
+    "label1",
+    "label2",
+    "label3"
+  ],
+  "selflink": "http://example.com/selflink",
+  "data-owner": "someOwner",
+  "data-source": "someSource",
+  "data-source-version": "2.0",
+  "resource-version": "3.0"
+}
diff --git a/so-cnf-adapter-application/src/test/resources/__files/k8sResourceExistsResponse.json b/so-cnf-adapter-application/src/test/resources/__files/k8sResourceExistsResponse.json
new file mode 100644 (file)
index 0000000..134a2d1
--- /dev/null
@@ -0,0 +1,7 @@
+{
+  "results": [
+    {
+      "k8s-resource": 1
+    }
+  ]
+}
diff --git a/so-cnf-adapter-application/src/test/resources/__files/k8sResourceNotFoundResponse.json b/so-cnf-adapter-application/src/test/resources/__files/k8sResourceNotFoundResponse.json
new file mode 100644 (file)
index 0000000..f58994a
--- /dev/null
@@ -0,0 +1,14 @@
+{
+  "requestError": {
+    "serviceException": {
+      "messageId": "SVC3001",
+      "text": "Resource not found for %1 using id %2 (msg=%3) (ec=%4)",
+      "variables": [
+        "GET",
+        "cloud-infrastructure/cloud-regions/cloud-region/someCloudOwner/someCloudRegionId/tenants/tenant/someTenantId/k8s-resources/k8s-resource/doesNotExist",
+        "Node Not Found:No Node of type k8s-resource found at: cloud-infrastructure/cloud-regions/cloud-region/someCloudOwner/someCloudRegionId/tenants/tenant/someTenantId/k8s-resources/k8s-resource/doesNotExist",
+        "ERR.5.4.6114"
+      ]
+    }
+  }
+}
diff --git a/so-cnf-adapter-application/src/test/resources/__files/vfModule.json b/so-cnf-adapter-application/src/test/resources/__files/vfModule.json
new file mode 100644 (file)
index 0000000..7ed0569
--- /dev/null
@@ -0,0 +1,18 @@
+{
+  "vf-module-id": "someVfModuleId",
+  "vf-module-name": "exampleVfModuleName",
+  "heat-stack-id": "heat-stack-id-456",
+  "orchestration-status": "active",
+  "is-base-vf-module": false,
+  "automated-assignment": true,
+  "model-invariant-id": "model-invariant-id-789",
+  "model-version-id": "model-version-id-101",
+  "persona-model-version": "persona-model-version-202",
+  "model-customization-id": "model-customization-id-303",
+  "widget-model-id": "widget-model-id-404",
+  "widget-model-version": "widget-model-version-505",
+  "contrail-service-instance-fqdn": "service-instance-contrail-id-606",
+  "module-index": 0,
+  "selflink": "http://example.com/selflink/vfModule",
+  "operational-status": "in-service-path"
+}
diff --git a/so-cnf-adapter-application/src/test/resources/__files/vfModuleWithRelationshipsResponse.json b/so-cnf-adapter-application/src/test/resources/__files/vfModuleWithRelationshipsResponse.json
new file mode 100644 (file)
index 0000000..6ca1fa0
--- /dev/null
@@ -0,0 +1,66 @@
+{
+  "vf-module-id": "someVfModuleId",
+  "vf-module-name": "exampleVfModuleName",
+  "heat-stack-id": "heat-stack-id-456",
+  "orchestration-status": "active",
+  "is-base-vf-module": false,
+  "automated-assignment": true,
+  "model-invariant-id": "model-invariant-id-789",
+  "model-version-id": "model-version-id-101",
+  "persona-model-version": "persona-model-version-202",
+  "model-customization-id": "model-customization-id-303",
+  "widget-model-id": "widget-model-id-404",
+  "widget-model-version": "widget-model-version-505",
+  "contrail-service-instance-fqdn": "service-instance-contrail-id-606",
+  "module-index": 0,
+  "selflink": "http://example.com/selflink/vfModule",
+  "operational-status": "in-service-path",
+    "relationship-list": {
+    "relationship": [
+      {
+        "related-to": "pnf",
+        "relationship-label": "org.onap.relationships.inventory.ComposedOf",
+        "related-link": "/aai/v24/network/pnfs/pnf/731534264",
+        "relationship-data": [
+          {
+            "relationship-key": "pnf.pnf-name",
+            "relationship-value": "731534264"
+          }
+        ]
+      },
+      {
+        "related-to": "pserver",
+        "relationship-label": "org.onap.relationships.inventory.ComposedOf",
+        "related-link": "/aai/v24/cloud-infrastructure/pservers/pserver/45673245",
+        "relationship-data": [
+          {
+            "relationship-key": "pserver.hostname",
+            "relationship-value": "45673245"
+          }
+        ]
+      },
+      {
+        "related-to": "k8s-resource",
+        "relationship-label": "org.onap.relationships.inventory.ComposedOf",
+        "related-link": "/aai/v24/cloud-infrastructure/cloud-regions/cloud-region/someCloudOwner/someCloudRegionId/tenants/tenant/someTenantId/k8s-resources/k8s-resource/doesNotExist",
+        "relationship-data": [
+          {
+            "relationship-key": "k8s-resource.id",
+            "relationship-value": "doesNotExist"
+          }
+        ]
+      },
+      {
+        "related-to": "k8s-resource",
+        "relationship-label": "org.onap.relationships.inventory.ComposedOf",
+        "related-link": "/aai/v24/cloud-infrastructure/cloud-regions/cloud-region/someCloudOwner/someCloudRegionId/tenants/tenant/someTenantId/k8s-resources/k8s-resource/someK8sResource",
+        "relationship-data": [
+          {
+            "relationship-key": "k8s-resource.id",
+            "relationship-value": "someK8sResource"
+          }
+        ]
+      }
+    ]
+  }
+}
index 7abfb00..71afd6b 100644 (file)
@@ -4,7 +4,7 @@
     <parent>
         <groupId>org.onap.so.adapters.so-cnf-adapter</groupId>
         <artifactId>so-cnf-adapter</artifactId>
-        <version>1.13.0-SNAPSHOT</version>
+        <version>1.13.1-SNAPSHOT</version>
     </parent>
     <artifactId>so-cnfm</artifactId>
     <packaging>pom</packaging>
index 316b8e3..34a6a95 100644 (file)
@@ -4,7 +4,7 @@
     <parent>
         <groupId>org.onap.so.adapters.so-cnf-adapter</groupId>
         <artifactId>so-cnfm</artifactId>
-        <version>1.13.0-SNAPSHOT</version>
+        <version>1.13.1-SNAPSHOT</version>
     </parent>
 
     <groupId>org.onap.so.adapters.so-cnf-adapter.so-cnfm.lcm</groupId>
index 38147c2..cec5782 100644 (file)
@@ -4,7 +4,7 @@
     <parent>
         <groupId>org.onap.so.adapters.so-cnf-adapter.so-cnfm.lcm</groupId>
         <artifactId>so-cnfm-lcm</artifactId>
-        <version>1.13.0-SNAPSHOT</version>
+        <version>1.13.1-SNAPSHOT</version>
     </parent>
 
     <artifactId>so-cnfm-lcm-api</artifactId>
index 14fed45..953cb10 100644 (file)
@@ -4,7 +4,7 @@
     <parent>
         <groupId>org.onap.so.adapters.so-cnf-adapter.so-cnfm.lcm</groupId>
         <artifactId>so-cnfm-lcm</artifactId>
-        <version>1.13.0-SNAPSHOT</version>
+        <version>1.13.1-SNAPSHOT</version>
     </parent>
 
     <artifactId>so-cnfm-lcm-application</artifactId>
index 8e58cfe..117a323 100644 (file)
@@ -4,7 +4,7 @@
     <parent>
         <groupId>org.onap.so.adapters.so-cnf-adapter.so-cnfm.lcm</groupId>
         <artifactId>so-cnfm-lcm</artifactId>
-        <version>1.13.0-SNAPSHOT</version>
+        <version>1.13.1-SNAPSHOT</version>
     </parent>
 
     <artifactId>so-cnfm-lcm-bpmn-flows</artifactId>
index f5ee660..32f1c1a 100644 (file)
@@ -4,7 +4,7 @@
     <parent>
         <groupId>org.onap.so.adapters.so-cnf-adapter.so-cnfm.lcm</groupId>
         <artifactId>so-cnfm-lcm</artifactId>
-        <version>1.13.0-SNAPSHOT</version>
+        <version>1.13.1-SNAPSHOT</version>
     </parent>
 
     <artifactId>so-cnfm-lcm-database-service</artifactId>
index 7b6cbef..6752876 100644 (file)
@@ -4,7 +4,7 @@
     <parent>
         <groupId>org.onap.so.adapters.so-cnf-adapter.so-cnfm.lcm</groupId>
         <artifactId>so-cnfm-lcm</artifactId>
-        <version>1.13.0-SNAPSHOT</version>
+        <version>1.13.1-SNAPSHOT</version>
     </parent>
 
     <artifactId>so-cnfm-lcm-service</artifactId>