Logical links creation bug 96/89996/3
authorJoanna Jeremicz <joanna.jeremicz@nokia.com>
Mon, 17 Jun 2019 09:06:13 +0000 (11:06 +0200)
committerJoanna Jeremicz <joanna.jeremicz@nokia.com>
Wed, 3 Jul 2019 12:31:26 +0000 (14:31 +0200)
Cleanup and test enhancements

Change-Id: I0c5c027ceed13ec9b63b60555e78ef552122aeac
Issue-ID: DCAEGEN2-1611
Signed-off-by: Joanna Jeremicz <joanna.jeremicz@nokia.com>
prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/BbsActionsTaskTest.java
prh-app-server/src/test/resources/BbsActionsTaskTestFiles/logicalLinkBody.json [new file with mode: 0644]
prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/bbs/Relationship.java [deleted file]
prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/bbs/RelationshipWrapper.java [deleted file]

index 5af78af..1c5c383 100644 (file)
@@ -36,7 +36,9 @@ import static org.onap.dcaegen2.services.sdk.rest.services.adapters.http.HttpMet
 import static org.onap.dcaegen2.services.sdk.rest.services.adapters.http.HttpMethod.PUT;
 
 import com.google.gson.JsonObject;
+import io.netty.buffer.ByteBuf;
 import io.netty.handler.codec.http.HttpResponseStatus;
+import java.nio.charset.StandardCharsets;
 import java.util.List;
 import java.util.Scanner;
 import org.junit.jupiter.api.Test;
@@ -64,6 +66,7 @@ class BbsActionsTaskTest {
     private static final String PNF_WITHOUT_LINK_JSON = "BbsActionsTaskTestFiles/pnfWithoutLinks.json";
     private static final String PNF_WITH_LINK_JSON = "BbsActionsTaskTestFiles/pnfWithLogicalLink.json";
     private static final String LOGICAL_LINK_JSON = "BbsActionsTaskTestFiles/oldLogicalLink.json";
+    private static final String LOGICAL_LINK_BODY = "BbsActionsTaskTestFiles/logicalLinkBody.json";
 
 
     private CbsConfiguration cbsConfiguration = mock(CbsConfiguration.class);
@@ -136,6 +139,7 @@ class BbsActionsTaskTest {
         assertEquals(GET, pnfGet.method());
         assertEquals(AAI_URL + LOGICAL_LINK_URL + "/" + linkName, linkPut.url());
         assertEquals(PUT, linkPut.method());
+        assertEquals(getBodyJson(LOGICAL_LINK_BODY), extractBodyFromRequest(linkPut));
     }
 
     @Test
@@ -179,6 +183,7 @@ class BbsActionsTaskTest {
         assertEquals(GET, linkGet.method());
         assertEquals(AAI_URL + LOGICAL_LINK_URL + "/" + linkName + "?resource-version=1560171816043", linkDelete.url());
         assertEquals(DELETE, linkDelete.method());
+        assertEquals(getBodyJson(LOGICAL_LINK_BODY), extractBodyFromRequest(linkPut));
     }
 
     @Test
@@ -230,6 +235,10 @@ class BbsActionsTaskTest {
             .build();
     }
 
+    private String extractBodyFromRequest(HttpRequest request) {
+        return Mono.from(request.body().contents()).block().toString(StandardCharsets.UTF_8);
+    }
+
     private String getBodyJson(String filename) {
         return new Scanner(loader.getResourceAsStream(filename)).useDelimiter("\\A").next();
     }
diff --git a/prh-app-server/src/test/resources/BbsActionsTaskTestFiles/logicalLinkBody.json b/prh-app-server/src/test/resources/BbsActionsTaskTestFiles/logicalLinkBody.json
new file mode 100644 (file)
index 0000000..c73b93e
--- /dev/null
@@ -0,0 +1 @@
+{"link-name":"some-link","link-type":"attachment-point","relationship-list":{"relationship":[{"related-link":"/network/pnfs/pnf/Nokia123","relationship-data":[]}]}}
\ No newline at end of file
diff --git a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/bbs/Relationship.java b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/bbs/Relationship.java
deleted file mode 100644 (file)
index 1abeddf..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PNF-REGISTRATION-HANDLER
- * ================================================================================
- * Copyright (C) 2019 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.
- * ============LICENSE_END=========================================================
- */
-package org.onap.dcaegen2.services.prh.model.bbs;
-
-import com.google.gson.annotations.SerializedName;
-import org.immutables.gson.Gson;
-import org.immutables.value.Value;
-
-@Value.Immutable
-@Gson.TypeAdapters(fieldNamingStrategy = true)
-@FunctionalInterface
-public interface Relationship {
-
-    @SerializedName(value = "related-link")
-    String getRelatedLink();
-}
diff --git a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/bbs/RelationshipWrapper.java b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/bbs/RelationshipWrapper.java
deleted file mode 100644 (file)
index dcf81c0..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PNF-REGISTRATION-HANDLER
- * ================================================================================
- * Copyright (C) 2019 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.
- * ============LICENSE_END=========================================================
- */
-package org.onap.dcaegen2.services.prh.model.bbs;
-
-import com.google.gson.annotations.SerializedName;
-import org.immutables.gson.Gson;
-import org.immutables.value.Value;
-
-@Value.Immutable
-@Gson.TypeAdapters(fieldNamingStrategy = true)
-@FunctionalInterface
-public interface RelationshipWrapper {
-
-    @SerializedName(value = "relationship")
-    Relationship getRelationship();
-}