diff options
author | Vidyashree-Huawei <vidyashree.rama@huawei.com> | 2020-04-17 19:06:56 +0530 |
---|---|---|
committer | Vidyashree-Huawei <vidyashree.rama@huawei.com> | 2020-04-17 19:11:06 +0530 |
commit | bd6abe51f90936ecb4a7de92a3f40978675a2886 (patch) | |
tree | 82ca213761397f31174f2d45b22b33539f6b0fd2 /src/test/java | |
parent | 6e7d04895c9133f772f3d781e84dbfc7b32f2874 (diff) |
Payload attributes are not displayed in operational policy
Handled list type in response
Change-Id: If4b5b45c5f23f377add1be84306a31e78d47c52b
Issue-ID: CLAMP-823
Signed-off-by: Vidyashree-Huawei <vidyashree.rama@huawei.com>
Diffstat (limited to 'src/test/java')
-rw-r--r-- | src/test/java/org/onap/clamp/clds/client/CdsServicesTest.java | 58 | ||||
-rw-r--r-- | src/test/java/org/onap/clamp/policy/operational/OperationalPolicyRepresentationBuilderTest.java | 13 |
2 files changed, 71 insertions, 0 deletions
diff --git a/src/test/java/org/onap/clamp/clds/client/CdsServicesTest.java b/src/test/java/org/onap/clamp/clds/client/CdsServicesTest.java new file mode 100644 index 000000000..ec39fc3db --- /dev/null +++ b/src/test/java/org/onap/clamp/clds/client/CdsServicesTest.java @@ -0,0 +1,58 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP CLAMP + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. + * ================================================================================ + * 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.clamp.clds.client; + +import com.google.gson.JsonObject; + +import java.io.IOException; + +import org.junit.Test; +import org.onap.clamp.clds.util.JsonUtils; +import org.onap.clamp.clds.util.ResourceFileUtil; +import org.skyscreamer.jsonassert.JSONAssert; + +public class CdsServicesTest { + + @Test + public void testParseCdsListTypeProperties() throws IOException { + String cdsResponse = ResourceFileUtil + .getResourceAsString("example/cds-response/vFW-CDS-resource-assignment-workflow.json"); + CdsServices services = new CdsServices(); + JsonObject output = services.parseCdsResponse(cdsResponse); + JSONAssert.assertEquals(ResourceFileUtil + .getResourceAsString("example/cds-response/vFW-CDS-resource-assignment-wf-expected-result.json"), + JsonUtils.GSON.toJson(output), true); + } + + @Test + public void testParseCdsResponse() throws IOException { + String cdsResponse = ResourceFileUtil + .getResourceAsString("example/cds-response/vFW-CDS-modify-config-workflow.json"); + CdsServices services = new CdsServices(); + JsonObject output = services.parseCdsResponse(cdsResponse); + JSONAssert.assertEquals(ResourceFileUtil + .getResourceAsString("example/cds-response/vFW-CDS-modify-config-wf-expected-result.json"), + JsonUtils.GSON.toJson(output), true); + } + +}
\ No newline at end of file diff --git a/src/test/java/org/onap/clamp/policy/operational/OperationalPolicyRepresentationBuilderTest.java b/src/test/java/org/onap/clamp/policy/operational/OperationalPolicyRepresentationBuilderTest.java index 4e9b56206..a6a496821 100644 --- a/src/test/java/org/onap/clamp/policy/operational/OperationalPolicyRepresentationBuilderTest.java +++ b/src/test/java/org/onap/clamp/policy/operational/OperationalPolicyRepresentationBuilderTest.java @@ -50,4 +50,17 @@ public class OperationalPolicyRepresentationBuilderTest { new GsonBuilder().create().toJson(jsonSchema), false); } + @Test + public void testOperationalPolicyPayloadConstructionForCds() throws IOException { + JsonObject jsonModel = new GsonBuilder().create() + .fromJson(ResourceFileUtil.getResourceAsString("tosca/model-properties-cds.json"), JsonObject.class); + Service service = new Service(jsonModel.get("serviceDetails").getAsJsonObject(), + jsonModel.get("resourceDetails").getAsJsonObject(), + "1.0"); + + JsonObject jsonSchema = OperationalPolicyRepresentationBuilder.generateOperationalPolicySchema(service); + assertThat(jsonSchema).isNotNull(); + JSONAssert.assertEquals(ResourceFileUtil.getResourceAsString("tosca/operational-policy-cds-payload-with-list.json"), + new GsonBuilder().create().toJson(jsonSchema), false); + } } |