From fa86bb96dd2d8aaba4bd7ecd0d881305eab174e3 Mon Sep 17 00:00:00 2001 From: "puthuparambil.aditya" Date: Mon, 27 Jun 2022 16:11:36 +0100 Subject: cps-ncmp-rest-stub can not be compiled and executed Issue-ID: CPS-1094 Signed-off-by: puthuparambil.aditya Change-Id: I2cd010e0bbe140198db22cf1f62cc8b0b9c80729 --- .../controller/NetworkCmProxyStubController.java | 31 ++++++++++++---------- .../src/main/resources/stubs/cmHandlesSearch.json | 10 +++---- pom.xml | 3 ++- 3 files changed, 23 insertions(+), 21 deletions(-) diff --git a/cps-ncmp-rest-stub/src/main/java/org/onap/cps/ncmp/rest/stub/controller/NetworkCmProxyStubController.java b/cps-ncmp-rest-stub/src/main/java/org/onap/cps/ncmp/rest/stub/controller/NetworkCmProxyStubController.java index 6362cf1e15..45408b0ebf 100644 --- a/cps-ncmp-rest-stub/src/main/java/org/onap/cps/ncmp/rest/stub/controller/NetworkCmProxyStubController.java +++ b/cps-ncmp-rest-stub/src/main/java/org/onap/cps/ncmp/rest/stub/controller/NetworkCmProxyStubController.java @@ -24,6 +24,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import java.io.IOException; import java.io.InputStream; import java.nio.charset.StandardCharsets; +import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -32,9 +33,7 @@ import javax.validation.Valid; import javax.validation.constraints.NotNull; import lombok.extern.slf4j.Slf4j; import org.onap.cps.ncmp.rest.api.NetworkCmProxyApi; -import org.onap.cps.ncmp.rest.model.CmHandleQueryRestParameters; -import org.onap.cps.ncmp.rest.model.CmHandles; -import org.onap.cps.ncmp.rest.model.Conditions; +import org.onap.cps.ncmp.rest.model.CmHandleQueryParameters; import org.onap.cps.ncmp.rest.model.RestModuleReference; import org.onap.cps.ncmp.rest.model.RestOutputCmHandle; import org.onap.cps.ncmp.rest.model.RestOutputCmHandlePublicProperties; @@ -68,18 +67,26 @@ public class NetworkCmProxyStubController implements NetworkCmProxyApi { } @Override - public ResponseEntity executeCmHandleSearch(@Valid final Conditions body) { - final ObjectMapper mapper = new ObjectMapper(); - CmHandles cmHandles = new CmHandles(); + public ResponseEntity> searchCmHandles( + final CmHandleQueryParameters cmHandleQueryParameters) { + List restOutputCmHandles = null; // read JSON file and map/convert to java POJO final ClassPathResource resource = new ClassPathResource(pathToResponseFiles + "cmHandlesSearch.json"); try (InputStream inputStream = resource.getInputStream()) { final String string = new String(inputStream.readAllBytes(), StandardCharsets.UTF_8); - cmHandles = mapper.readValue(string, CmHandles.class); + final ObjectMapper mapper = new ObjectMapper(); + restOutputCmHandles = Arrays.asList(mapper.readValue(string, RestOutputCmHandle[].class)); } catch (final IOException exception) { log.error("Error reading the file.", exception); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build(); } - return ResponseEntity.ok(cmHandles); + return ResponseEntity.ok(restOutputCmHandles); + } + + @Override + public ResponseEntity> searchCmHandleIds( + final CmHandleQueryParameters cmHandleQueryParameters) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @Override @@ -107,16 +114,17 @@ public class NetworkCmProxyStubController implements NetworkCmProxyApi { final String resourceIdentifier, final String optionsParamInQuery, final String topicParamInQuery) { final ResponseEntity> asyncResponse = populateAsyncResponse(topicParamInQuery); final Map asyncResponseData = asyncResponse.getBody(); - final ObjectMapper mapper = new ObjectMapper(); Object responseObject = null; // read JSON file and map/convert to java POJO final ClassPathResource resource = new ClassPathResource(pathToResponseFiles + "passthrough-operational-example.json"); try (InputStream inputStream = resource.getInputStream()) { final String string = new String(inputStream.readAllBytes(), StandardCharsets.UTF_8); + final ObjectMapper mapper = new ObjectMapper(); responseObject = mapper.readValue(string, Object.class); } catch (final IOException exception) { log.error("Error reading the file.", exception); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build(); } if (asyncResponseData == null) { return ResponseEntity.ok(responseObject); @@ -137,11 +145,6 @@ public class NetworkCmProxyStubController implements NetworkCmProxyApi { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } - @Override - public ResponseEntity> queryCmHandles(final CmHandleQueryRestParameters body) { - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - } - @Override public ResponseEntity retrieveCmHandleDetailsById(final String cmHandleId) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); diff --git a/cps-ncmp-rest-stub/src/main/resources/stubs/cmHandlesSearch.json b/cps-ncmp-rest-stub/src/main/resources/stubs/cmHandlesSearch.json index 409d56fa44..9a2e1ed5d1 100644 --- a/cps-ncmp-rest-stub/src/main/resources/stubs/cmHandlesSearch.json +++ b/cps-ncmp-rest-stub/src/main/resources/stubs/cmHandlesSearch.json @@ -1,10 +1,8 @@ -{ - "cmHandles": [ +[ { - "cmHandleId": "stub-cm-handle-id" + "cmHandle": "stub-cm-handle-id" }, { - "cmHandleId": "stub-cm-handle-id2" + "cmHandle": "stub-cm-handle-id2" } - ] -} \ No newline at end of file + ] \ No newline at end of file diff --git a/pom.xml b/pom.xml index 12d8a1f44c..bb3553b15e 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ Copyright (c) 2020 Linux Foundation. Modifications Copyright (C) 2020-2021 Nordix Foundation Modifications Copyright (C) 2020-2021 Pantheon.tech - Modifications Copyright (C) 2021 Bell Canada. + Modifications Copyright (C) 2021-2022 Bell Canada. ================================================================================ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -58,6 +58,7 @@ cps-ncmp-events cps-ncmp-service cps-ncmp-rest + cps-ncmp-rest-stub cps-path-parser cps-ri checkstyle -- cgit 1.2.3-korg