diff options
author | Niranjana <niranjana.y60@wipro.com> | 2022-03-10 11:52:19 +0000 |
---|---|---|
committer | Niranjana <niranjana.y60@wipro.com> | 2022-03-14 13:52:55 +0000 |
commit | 26d2e7029f32260246e0bfc21dde0b17006b28bd (patch) | |
tree | 87b93d507a5d8d13c91e45444b77989b8b910a2e /cps-tbdmt-service/src/test | |
parent | a9c4c58fdb558ddb4ef11581c001f44b3954ab4d (diff) |
Remove extra brackets in the result of output transformation
Issue-ID: CPS-920
Signed-off-by: Niranjana <niranjana.y60@wipro.com>
Change-Id: I130f80c687bb2a9ccdf0ed45c387d7cfc167face
Diffstat (limited to 'cps-tbdmt-service/src/test')
-rw-r--r-- | cps-tbdmt-service/src/test/java/org/onap/cps/tbdmt/service/ExecutionBusinessLogicTest.java | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/cps-tbdmt-service/src/test/java/org/onap/cps/tbdmt/service/ExecutionBusinessLogicTest.java b/cps-tbdmt-service/src/test/java/org/onap/cps/tbdmt/service/ExecutionBusinessLogicTest.java index 56c55c0..9cee472 100644 --- a/cps-tbdmt-service/src/test/java/org/onap/cps/tbdmt/service/ExecutionBusinessLogicTest.java +++ b/cps-tbdmt-service/src/test/java/org/onap/cps/tbdmt/service/ExecutionBusinessLogicTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP * ================================================================================ - * Copyright (C) 2021 Wipro Limited. + * Copyright (C) 2021-2022 Wipro Limited. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -196,7 +196,7 @@ public class ExecutionBusinessLogicTest { new Template("get-tree", "ran-network", "/test-tree", "get", true, null, transformParam1); final Template template2 = new Template("get-branch", "ran-network", "/test-tree/branch[@name='{{name}}']/nest", "get", true, "get-tree", transformParam2); - final String transformedResult = "[[\"Big\"], [\"Small\"]]"; + final String transformedResult = "[\"Big\", \"Small\"]"; try { final String result1 = readFromFile("sample_multiple_query_data_1.json"); @@ -254,6 +254,39 @@ public class ExecutionBusinessLogicTest { executionBusinessLogic.executeTemplate("ran-net", "deleteNbr", request); } + @Test + public void testRemoveExtraBracketsIfAny() { + final Map<String, String> input = new HashMap<>(); + input.put("idNearRTRIC", "11"); + final String transformParam1 = "branch, nest, birds"; + final Template template1 = + new Template("get-tree", "ran-network", "/test-tree", "get", true, null, transformParam1); + final String transformParam2 = "GNBDUFunction, NRCellDU, attributes, nRSectorCarrierRef"; + final Template template2 = new Template("get-nrcelldu-data", "ran-network", "/NearRTRIC/[@idNearRTRIC='11']", + "get", true, null, transformParam2); + final String transformedResult1 = "[[\"Owl\",\"Raven\",\"Crow\"],[\"Robin\",\"Sparrow\",\"Finch\"]]"; + final String transformedResult2 = "[\"OU\\u003dSales\",\"OU\\u003dSales\"]"; + + try { + final String result1 = readFromFile("sample_multiple_query_data_1.json"); + Mockito.when(cpsRestClient.fetchNode("ran-network", "/test-tree", "get", true)).thenReturn(result1); + Mockito.when(templateRepository.findById(ArgumentMatchers.any())).thenReturn(Optional.of(template1)); + final String result2 = readFromFile("sample_transform_query_data.json"); + Mockito.when(cpsRestClient.fetchNode("ran-network", "/NearRTRIC/[@idNearRTRIC='11']", "get", true)) + .thenReturn(result2); + final TemplateKey key = new TemplateKey("get-nrcelldu-data"); + Mockito.when(templateRepository.findById(key)).thenReturn(Optional.of(template2)); + assertEquals(transformedResult1, + executionBusinessLogic.executeTemplate("ran-network", "get-tree", request)); + assertEquals(transformedResult2, + executionBusinessLogic.executeTemplate("ran-network", "get-nrcelldu-data", request)); + } catch (final CpsClientException e) { + e.printStackTrace(); + } catch (final Exception e) { + e.printStackTrace(); + } + } + /** * Reads a file from classpath. * |