summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosephKeenan <joseph.keenan@est.tech>2021-08-03 18:24:32 +0100
committerRenu Kumari <renu.kumari@bell.ca>2021-08-10 10:44:24 -0400
commitbe21595d53636e2c9b912bfbe8dfdefb81edc70f (patch)
treec40add4ce147e0ab6da7814384dd42d82e316079
parentdce1d58005d90950e00b22078d82559748dcb255 (diff)
Upgrade Swager Codegen-maven-plugin
- Removed swagger annotations dependency as latest plugin generates code using v3 annotations. - updated the method signature as per the new generated code - removed unnecessary mock springbeans from the WebMvcTest Issue-ID: CPS-205 Change-Id: Ie7911d7389dca587bde945d913f458de46027e0f Signed-off-by: JosephKeenan <joseph.keenan@est.tech>
-rwxr-xr-xcps-dependencies/pom.xml6
-rw-r--r--cps-ncmp-rest/pom.xml4
-rwxr-xr-xcps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java13
-rwxr-xr-xcps-parent/pom.xml2
-rwxr-xr-xcps-rest/pom.xml4
-rwxr-xr-xcps-rest/src/main/java/org/onap/cps/rest/controller/AdminRestController.java12
-rwxr-xr-xcps-rest/src/main/java/org/onap/cps/rest/controller/DataRestController.java22
-rwxr-xr-xcps-rest/src/test/groovy/org/onap/cps/rest/controller/AdminRestControllerSpec.groovy8
-rwxr-xr-xcps-rest/src/test/groovy/org/onap/cps/rest/controller/DataRestControllerSpec.groovy14
-rw-r--r--cps-rest/src/test/groovy/org/onap/cps/rest/controller/QueryRestControllerSpec.groovy14
10 files changed, 30 insertions, 69 deletions
diff --git a/cps-dependencies/pom.xml b/cps-dependencies/pom.xml
index 8d147abebe..1cd36f6838 100755
--- a/cps-dependencies/pom.xml
+++ b/cps-dependencies/pom.xml
@@ -87,12 +87,6 @@
<artifactId>swagger-annotations</artifactId>
<version>2.1.4</version>
</dependency>
- <!---To be removed once swagger-codegen-maven-plugin is upgraded-->
- <dependency>
- <groupId>io.swagger</groupId>
- <artifactId>swagger-annotations</artifactId>
- <version>1.6.2</version>
- </dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
diff --git a/cps-ncmp-rest/pom.xml b/cps-ncmp-rest/pom.xml
index e0c4f6fbe1..dbe1af0973 100644
--- a/cps-ncmp-rest/pom.xml
+++ b/cps-ncmp-rest/pom.xml
@@ -68,10 +68,6 @@
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
</dependency>
- <dependency>
- <groupId>io.swagger</groupId>
- <artifactId>swagger-annotations</artifactId>
- </dependency>
<!-- T E S T D E P E N D E N C I E S -->
<dependency>
<groupId>org.codehaus.groovy</groupId>
diff --git a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java
index e9e022345f..3d771b6c51 100755
--- a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java
+++ b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java
@@ -27,6 +27,7 @@ import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import java.util.Collection;
import javax.validation.Valid;
+import javax.validation.constraints.NotNull;
import org.onap.cps.ncmp.api.NetworkCmProxyDataService;
import org.onap.cps.ncmp.api.models.DmiPluginRegistration;
import org.onap.cps.ncmp.rest.api.NetworkCmProxyApi;
@@ -66,8 +67,8 @@ public class NetworkCmProxyController implements NetworkCmProxyApi {
*/
@Override
@Deprecated(forRemoval = false)
- public ResponseEntity<Void> createNode(final String jsonData, final String cmHandle,
- final String parentNodeXpath) {
+ public ResponseEntity<Void> createNode(final String cmHandle, @Valid final String jsonData,
+ @Valid final String parentNodeXpath) {
networkCmProxyDataService.createDataNode(cmHandle, parentNodeXpath, jsonData);
return new ResponseEntity<>(HttpStatus.CREATED);
}
@@ -78,8 +79,8 @@ public class NetworkCmProxyController implements NetworkCmProxyApi {
*/
@Override
@Deprecated(forRemoval = false)
- public ResponseEntity<Void> addListNodeElements(final String jsonData, final String parentNodeXpath,
- final String cmHandle) {
+ public ResponseEntity<Void> addListNodeElements(@NotNull @Valid final String parentNodeXpath,
+ final String cmHandle, @Valid final String jsonData) {
networkCmProxyDataService.addListNodeElements(cmHandle, parentNodeXpath, jsonData);
return new ResponseEntity<>(HttpStatus.CREATED);
}
@@ -132,7 +133,7 @@ public class NetworkCmProxyController implements NetworkCmProxyApi {
*/
@Override
@Deprecated(forRemoval = false)
- public ResponseEntity<Object> replaceNode(@Valid final String jsonData, final String cmHandle,
+ public ResponseEntity<Object> replaceNode(final String cmHandle, @Valid final String jsonData,
@Valid final String parentNodeXpath) {
networkCmProxyDataService.replaceNodeTree(cmHandle, parentNodeXpath, jsonData);
return new ResponseEntity<>(HttpStatus.OK);
@@ -144,7 +145,7 @@ public class NetworkCmProxyController implements NetworkCmProxyApi {
*/
@Override
@Deprecated(forRemoval = false)
- public ResponseEntity<Object> updateNodeLeaves(@Valid final String jsonData, final String cmHandle,
+ public ResponseEntity<Object> updateNodeLeaves(final String cmHandle, @Valid final String jsonData,
@Valid final String parentNodeXpath) {
networkCmProxyDataService.updateNodeLeaves(cmHandle, parentNodeXpath, jsonData);
return new ResponseEntity<>(HttpStatus.OK);
diff --git a/cps-parent/pom.xml b/cps-parent/pom.xml
index 59b42903cc..938e75eb4f 100755
--- a/cps-parent/pom.xml
+++ b/cps-parent/pom.xml
@@ -122,7 +122,7 @@
<plugin>
<groupId>io.swagger.codegen.v3</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
- <version>3.0.18</version>
+ <version>3.0.27</version>
</plugin>
<plugin>
<groupId>com.github.spotbugs</groupId>
diff --git a/cps-rest/pom.xml b/cps-rest/pom.xml
index 9a131176db..9e29074f76 100755
--- a/cps-rest/pom.xml
+++ b/cps-rest/pom.xml
@@ -71,10 +71,6 @@
<artifactId>springfox-boot-starter</artifactId>
</dependency>
<dependency>
- <groupId>io.swagger</groupId>
- <artifactId>swagger-annotations</artifactId>
- </dependency>
- <dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.5.9</version>
diff --git a/cps-rest/src/main/java/org/onap/cps/rest/controller/AdminRestController.java b/cps-rest/src/main/java/org/onap/cps/rest/controller/AdminRestController.java
index 879d5dc6e0..a1287b2bd6 100755
--- a/cps-rest/src/main/java/org/onap/cps/rest/controller/AdminRestController.java
+++ b/cps-rest/src/main/java/org/onap/cps/rest/controller/AdminRestController.java
@@ -28,6 +28,8 @@ import static org.onap.cps.spi.CascadeDeleteAllowed.CASCADE_DELETE_PROHIBITED;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
+import javax.validation.Valid;
+import javax.validation.constraints.NotNull;
import org.modelmapper.ModelMapper;
import org.onap.cps.api.CpsAdminService;
import org.onap.cps.api.CpsModuleService;
@@ -63,7 +65,7 @@ public class AdminRestController implements CpsAdminApi {
* @return a {@Link ResponseEntity} of created dataspace name & {@link HttpStatus} CREATED
*/
@Override
- public ResponseEntity<String> createDataspace(final String dataspaceName) {
+ public ResponseEntity<String> createDataspace(@NotNull @Valid final String dataspaceName) {
cpsAdminService.createDataspace(dataspaceName);
return new ResponseEntity<>(dataspaceName, HttpStatus.CREATED);
}
@@ -88,8 +90,8 @@ public class AdminRestController implements CpsAdminApi {
* @return a {@Link ResponseEntity} of created schemaset name & {@link HttpStatus} CREATED
*/
@Override
- public ResponseEntity<String> createSchemaSet(final MultipartFile multipartFile,
- final String schemaSetName, final String dataspaceName) {
+ public ResponseEntity<String> createSchemaSet(@NotNull @Valid final String schemaSetName,
+ final String dataspaceName, @Valid final MultipartFile multipartFile) {
cpsModuleService.createSchemaSet(dataspaceName, schemaSetName, extractYangResourcesMap(multipartFile));
return new ResponseEntity<>(schemaSetName, HttpStatus.CREATED);
}
@@ -130,8 +132,8 @@ public class AdminRestController implements CpsAdminApi {
* @return a ResponseEntity with the anchor name & {@link HttpStatus} CREATED
*/
@Override
- public ResponseEntity<String> createAnchor(final String dataspaceName, final String schemaSetName,
- final String anchorName) {
+ public ResponseEntity<String> createAnchor(final String dataspaceName, @NotNull @Valid final String schemaSetName,
+ @NotNull @Valid final String anchorName) {
cpsAdminService.createAnchor(dataspaceName, schemaSetName, anchorName);
return new ResponseEntity<>(anchorName, HttpStatus.CREATED);
}
diff --git a/cps-rest/src/main/java/org/onap/cps/rest/controller/DataRestController.java b/cps-rest/src/main/java/org/onap/cps/rest/controller/DataRestController.java
index 64b441829d..bad66dd4e8 100755
--- a/cps-rest/src/main/java/org/onap/cps/rest/controller/DataRestController.java
+++ b/cps-rest/src/main/java/org/onap/cps/rest/controller/DataRestController.java
@@ -21,6 +21,8 @@
package org.onap.cps.rest.controller;
+import javax.validation.Valid;
+import javax.validation.constraints.NotNull;
import org.onap.cps.api.CpsDataService;
import org.onap.cps.rest.api.CpsDataApi;
import org.onap.cps.spi.FetchDescendantsOption;
@@ -41,8 +43,8 @@ public class DataRestController implements CpsDataApi {
private CpsDataService cpsDataService;
@Override
- public ResponseEntity<String> createNode(final String jsonData, final String dataspaceName, final String anchorName,
- final String parentNodeXpath) {
+ public ResponseEntity<String> createNode(final String dataspaceName, final String anchorName,
+ final String jsonData, final String parentNodeXpath) {
if (isRootXpath(parentNodeXpath)) {
cpsDataService.saveData(dataspaceName, anchorName, jsonData);
} else {
@@ -52,8 +54,8 @@ public class DataRestController implements CpsDataApi {
}
@Override
- public ResponseEntity<String> addListNodeElements(final String jsonData, final String parentNodeXpath,
- final String dataspaceName, final String anchorName) {
+ public ResponseEntity<String> addListNodeElements(final String parentNodeXpath,
+ final String dataspaceName, final String anchorName, final String jsonData) {
cpsDataService.saveListNodeData(dataspaceName, anchorName, parentNodeXpath, jsonData);
return new ResponseEntity<>(HttpStatus.CREATED);
}
@@ -74,22 +76,22 @@ public class DataRestController implements CpsDataApi {
}
@Override
- public ResponseEntity<Object> updateNodeLeaves(final String jsonData, final String dataspaceName,
- final String anchorName, final String parentNodeXpath) {
+ public ResponseEntity<Object> updateNodeLeaves(final String dataspaceName,
+ final String anchorName, final String jsonData, final String parentNodeXpath) {
cpsDataService.updateNodeLeaves(dataspaceName, anchorName, parentNodeXpath, jsonData);
return new ResponseEntity<>(HttpStatus.OK);
}
@Override
- public ResponseEntity<Object> replaceNode(final String jsonData, final String dataspaceName,
- final String anchorName, final String parentNodeXpath) {
+ public ResponseEntity<Object> replaceNode(final String dataspaceName,
+ final String anchorName, @Valid final String jsonData, @Valid final String parentNodeXpath) {
cpsDataService.replaceNodeTree(dataspaceName, anchorName, parentNodeXpath, jsonData);
return new ResponseEntity<>(HttpStatus.OK);
}
@Override
- public ResponseEntity<String> replaceListNodeElements(final String jsonData, final String parentNodeXpath,
- final String dataspaceName, final String anchorName) {
+ public ResponseEntity<String> replaceListNodeElements(@NotNull @Valid final String parentNodeXpath,
+ final String dataspaceName, final String anchorName, @Valid final String jsonData) {
cpsDataService.replaceListNodeData(dataspaceName, anchorName, parentNodeXpath, jsonData);
return new ResponseEntity<>(HttpStatus.OK);
}
diff --git a/cps-rest/src/test/groovy/org/onap/cps/rest/controller/AdminRestControllerSpec.groovy b/cps-rest/src/test/groovy/org/onap/cps/rest/controller/AdminRestControllerSpec.groovy
index 2f97a31dc0..84da2db5d7 100755
--- a/cps-rest/src/test/groovy/org/onap/cps/rest/controller/AdminRestControllerSpec.groovy
+++ b/cps-rest/src/test/groovy/org/onap/cps/rest/controller/AdminRestControllerSpec.groovy
@@ -49,7 +49,7 @@ import org.springframework.util.LinkedMultiValueMap
import org.springframework.util.MultiValueMap
import spock.lang.Specification
-@WebMvcTest
+@WebMvcTest(AdminRestController)
class AdminRestControllerSpec extends Specification {
@SpringBean
@@ -59,12 +59,6 @@ class AdminRestControllerSpec extends Specification {
CpsAdminService mockCpsAdminService = Mock()
@SpringBean
- CpsDataService mockCpsDataService = Mock()
-
- @SpringBean
- CpsQueryService mockCpsQueryService = Mock()
-
- @SpringBean
ModelMapper modelMapper = Spy()
@Autowired
diff --git a/cps-rest/src/test/groovy/org/onap/cps/rest/controller/DataRestControllerSpec.groovy b/cps-rest/src/test/groovy/org/onap/cps/rest/controller/DataRestControllerSpec.groovy
index ec31c7fe03..8675f42a51 100755
--- a/cps-rest/src/test/groovy/org/onap/cps/rest/controller/DataRestControllerSpec.groovy
+++ b/cps-rest/src/test/groovy/org/onap/cps/rest/controller/DataRestControllerSpec.groovy
@@ -46,24 +46,12 @@ import org.springframework.test.web.servlet.MockMvc
import spock.lang.Shared
import spock.lang.Specification
-@WebMvcTest
+@WebMvcTest(DataRestController)
class DataRestControllerSpec extends Specification {
@SpringBean
CpsDataService mockCpsDataService = Mock()
- @SpringBean
- CpsModuleService mockCpsModuleService = Mock()
-
- @SpringBean
- CpsAdminService mockCpsAdminService = Mock()
-
- @SpringBean
- CpsQueryService mockCpsQueryService = Mock()
-
- @SpringBean
- ModelMapper modelMapper = Mock()
-
@Autowired
MockMvc mvc
diff --git a/cps-rest/src/test/groovy/org/onap/cps/rest/controller/QueryRestControllerSpec.groovy b/cps-rest/src/test/groovy/org/onap/cps/rest/controller/QueryRestControllerSpec.groovy
index 6b6bdeeeb5..d43e02b316 100644
--- a/cps-rest/src/test/groovy/org/onap/cps/rest/controller/QueryRestControllerSpec.groovy
+++ b/cps-rest/src/test/groovy/org/onap/cps/rest/controller/QueryRestControllerSpec.groovy
@@ -41,24 +41,12 @@ import org.springframework.http.HttpStatus
import org.springframework.test.web.servlet.MockMvc
import spock.lang.Specification
-@WebMvcTest
+@WebMvcTest(QueryRestController)
class QueryRestControllerSpec extends Specification {
@SpringBean
- CpsDataService mockCpsDataService = Mock()
-
- @SpringBean
- CpsModuleService mockCpsModuleService = Mock()
-
- @SpringBean
- CpsAdminService mockCpsAdminService = Mock()
-
- @SpringBean
CpsQueryService mockCpsQueryService = Mock()
- @SpringBean
- ModelMapper modelMapper = Mock()
-
@Autowired
MockMvc mvc