diff options
author | krishnaa96 <krishna.moorthy6@wipro.com> | 2021-07-20 17:44:16 +0530 |
---|---|---|
committer | krishnaa96 <krishna.moorthy6@wipro.com> | 2021-07-22 18:06:56 +0530 |
commit | e1216505db39f033c8460ca835eb352e27737b9f (patch) | |
tree | 9f0e46a17e0eee1c8d2c75d154536a1802f6e39e /cps-tbdmt-service/src/test/java | |
parent | 9c4054fc42ded465b52f6a3577df983aa407b118 (diff) |
Fix issues in CPS integration
- Add include descendants to the template
- Add authentication for CPS rest client
- Update the CPS url
- Add configuration for CPS core and NCMP
Issue-ID: CPS-512
Signed-off-by: krishnaa96 <krishna.moorthy6@wipro.com>
Change-Id: I071e96d9d3c09b2a90f455f8056dea8ced0060d8
Diffstat (limited to 'cps-tbdmt-service/src/test/java')
3 files changed, 15 insertions, 15 deletions
diff --git a/cps-tbdmt-service/src/test/java/org/onap/cps/tbdmt/client/CpsRestClientTest.java b/cps-tbdmt-service/src/test/java/org/onap/cps/tbdmt/client/CpsRestClientTest.java index 9742bb1..46f28cb 100644 --- a/cps-tbdmt-service/src/test/java/org/onap/cps/tbdmt/client/CpsRestClientTest.java +++ b/cps-tbdmt-service/src/test/java/org/onap/cps/tbdmt/client/CpsRestClientTest.java @@ -86,13 +86,13 @@ public class CpsRestClientTest { @Test public void testFetchNode() throws Exception { - final String uri = "http://localhost:8000/anchors/coverage-area-onap/nodes?cpsPath=sample"; + final String uri = "http://localhost:8000/anchors/coverage-area-onap/node?xpath=sample&include-descendants=true"; Mockito.when(restTemplate.exchange(ArgumentMatchers.eq(uri), ArgumentMatchers.any(HttpMethod.class), ArgumentMatchers.any(), ArgumentMatchers.<Class<String>>any())) .thenReturn(response); - assertEquals("sample response", cpsRestClient.fetchNode("coverage-area-onap", "sample", "get")); + assertEquals("sample response", cpsRestClient.fetchNode("coverage-area-onap", "sample", "get", true)); final ResponseEntity<String> errorResponse = new ResponseEntity<>("sample response", responseHeaders, HttpStatus.NOT_FOUND); @@ -103,19 +103,19 @@ public class CpsRestClientTest { .thenReturn(errorResponse); exception.expect(CpsClientException.class); exception.expectMessage("Response code from CPS other than 200: 404"); - cpsRestClient.fetchNode("coverage-area-onap", "sample", "get"); + cpsRestClient.fetchNode("coverage-area-onap", "sample", "get", true); } @Test public void testQueryApi() throws Exception { - final String uri = "http://localhost:8000/anchors/coverage-area-onap/nodes/query?cpsPath=sample"; + final String uri = "http://localhost:8000/anchors/coverage-area-onap/nodes/query?xpath=sample&include-descendants=true"; Mockito.when(restTemplate.exchange(ArgumentMatchers.eq(uri), ArgumentMatchers.any(HttpMethod.class), ArgumentMatchers.any(), ArgumentMatchers.<Class<String>>any())) .thenReturn(response); - assertEquals("sample response", cpsRestClient.fetchNode("coverage-area-onap", "sample", "query")); + assertEquals("sample response", cpsRestClient.fetchNode("coverage-area-onap", "sample", "query", true)); } @Test @@ -127,6 +127,6 @@ public class CpsRestClientTest { .thenThrow(new RestClientException("Connection refused")); exception.expect(CpsClientException.class); exception.expectMessage("Connection refused"); - cpsRestClient.fetchNode("coverage-area-onap", "sample", "get"); + cpsRestClient.fetchNode("coverage-area-onap", "sample", "get", true); } } 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 32dbc27..c3be423 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 @@ -91,8 +91,8 @@ public class ExecutionBusinessLogicTest { request = new ExecutionRequest(input); final String xpathTemplate = "/ran-coverage-area/pLMNIdList[@mcc='310' and @mnc='410']" + "/coverage-area[@coverageArea='{{coverageArea}}']"; - template = new Template("getNbr", "ran-network", xpathTemplate, "get"); - queryTemplate = new Template("getNbr", "ran-network", xpathTemplate, "query"); + template = new Template("getNbr", "ran-network", xpathTemplate, "get", true); + queryTemplate = new Template("getNbr", "ran-network", xpathTemplate, "query", true); } @Test @@ -100,7 +100,7 @@ public class ExecutionBusinessLogicTest { final String resultString = "[{\"key\": \"value\"}]"; Mockito.when(cpsRestClient .fetchNode("ran-network", "/ran-coverage-area/pLMNIdList[@mcc='310' and @mnc='410']" - + "/coverage-area[@coverageArea='Zone 1']", "get")) + + "/coverage-area[@coverageArea='Zone 1']", "get", true)) .thenReturn(resultString); Mockito.when(templateRepository.findById(ArgumentMatchers.any())) .thenReturn(Optional.of(template)); @@ -120,7 +120,7 @@ public class ExecutionBusinessLogicTest { final String exceptionMessage = "Response from CPS other than 200: 404"; Mockito.when(cpsRestClient .fetchNode("ran-network", "/ran-coverage-area/pLMNIdList[@mcc='310' and @mnc='410']" - + "/coverage-area[@coverageArea='Zone 1']", "get")) + + "/coverage-area[@coverageArea='Zone 1']", "get", true)) .thenThrow(new CpsClientException(exceptionMessage)); Mockito.when(templateRepository.findById(ArgumentMatchers.any())) .thenReturn(Optional.of(template)); @@ -128,7 +128,7 @@ public class ExecutionBusinessLogicTest { exception.expectMessage(exceptionMessage); executionBusinessLogic.executeTemplate("ran-network", "getNbr", request); - final Template template1 = new Template("getNbr", "ran-net", "sample", "get"); + final Template template1 = new Template("getNbr", "ran-net", "sample", "get", true); Mockito.when(templateRepository.findById(ArgumentMatchers.any())) .thenReturn(Optional.of(template1)); exception.expect(ExecuteException.class); @@ -139,7 +139,7 @@ public class ExecutionBusinessLogicTest { @Test public void testExecuteTemplateNoAnchor() { - final Template template = new Template("getNbr", "ran-net", "sample", "get"); + final Template template = new Template("getNbr", "ran-net", "sample", "get", true); Mockito.when(templateRepository.findById(ArgumentMatchers.any())) .thenReturn(Optional.of(template)); exception.expect(ExecuteException.class); @@ -152,7 +152,7 @@ public class ExecutionBusinessLogicTest { final String resultString = "[{\"key\": \"value\"}]"; Mockito.when(cpsRestClient .fetchNode("ran-network", "/ran-coverage-area/pLMNIdList[@mcc='310' and @mnc='410']" - + "/coverage-area[@coverageArea='Zone 1']", "query")) + + "/coverage-area[@coverageArea='Zone 1']", "query", true)) .thenReturn(resultString); Mockito.when(templateRepository.findById(ArgumentMatchers.any())) .thenReturn(Optional.of(queryTemplate)); diff --git a/cps-tbdmt-service/src/test/java/org/onap/cps/tbdmt/service/TemplateBusinessLogicTest.java b/cps-tbdmt-service/src/test/java/org/onap/cps/tbdmt/service/TemplateBusinessLogicTest.java index aa7e28a..d0bdf47 100644 --- a/cps-tbdmt-service/src/test/java/org/onap/cps/tbdmt/service/TemplateBusinessLogicTest.java +++ b/cps-tbdmt-service/src/test/java/org/onap/cps/tbdmt/service/TemplateBusinessLogicTest.java @@ -71,13 +71,13 @@ public class TemplateBusinessLogicTest { @Before public void setup() { - template = new Template("getNbr", "ran-network", "sample", "get"); + template = new Template("getNbr", "ran-network", "sample", "get", true); final TemplateKey templateKey = new TemplateKey("getNbr", "ran-network"); } @Test public void testCreateTemplate() throws Exception { - final TemplateRequest templateRequest = new TemplateRequest("getNbr", "ran-network", "sample", "get"); + final TemplateRequest templateRequest = new TemplateRequest("getNbr", "ran-network", "sample", "get", true); Mockito.when(templateRepository.save(ArgumentMatchers.any())).thenReturn(template); assertEquals(template, templateBusinessLogic.createTemplate(templateRequest)); } |