diff options
author | Joanna Jeremicz <joanna.jeremicz@nokia.com> | 2019-06-17 11:06:13 +0200 |
---|---|---|
committer | Joanna Jeremicz <joanna.jeremicz@nokia.com> | 2019-07-03 14:31:26 +0200 |
commit | ac77e0be3acc65b898d6310eaf09b3ee1a0d1725 (patch) | |
tree | 4a8b7c4bbc0d513551c3565e4b0e827efaa48bc5 | |
parent | ce3730c7286f03375f38215a50af1ae6530a4845 (diff) |
Logical links creation bug
Cleanup and test enhancements
Change-Id: I0c5c027ceed13ec9b63b60555e78ef552122aeac
Issue-ID: DCAEGEN2-1611
Signed-off-by: Joanna Jeremicz <joanna.jeremicz@nokia.com>
4 files changed, 10 insertions, 66 deletions
diff --git a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/BbsActionsTaskTest.java b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/BbsActionsTaskTest.java index 5af78afa..1c5c3837 100644 --- a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/BbsActionsTaskTest.java +++ b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/BbsActionsTaskTest.java @@ -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 index 00000000..c73b93e5 --- /dev/null +++ b/prh-app-server/src/test/resources/BbsActionsTaskTestFiles/logicalLinkBody.json @@ -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 index 1abeddf3..00000000 --- a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/bbs/Relationship.java +++ /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 index dcf81c0f..00000000 --- a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/bbs/RelationshipWrapper.java +++ /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(); -} |