summaryrefslogtreecommitdiffstats
path: root/cps-rest
diff options
context:
space:
mode:
authorLuke Gleeson <luke.gleeson@est.tech>2023-01-31 11:41:54 +0000
committerGerrit Code Review <gerrit@onap.org>2023-01-31 11:41:54 +0000
commit447c872eb3c9bd57631127651bc9744c5c1a8643 (patch)
tree9c2e17873cb6f77001ad5c25b301e00632e45c1c /cps-rest
parentafc6055b34af379ab3dd5895d0ecd1ff63a7c9dd (diff)
parent0fa2fabeec18763bab060d85f5123bceff8ee34c (diff)
Merge "Introduce Instrumentation"
Diffstat (limited to 'cps-rest')
-rwxr-xr-xcps-rest/src/main/java/org/onap/cps/rest/controller/AdminRestController.java5
-rw-r--r--cps-rest/src/test/groovy/org/onap/cps/rest/exceptions/CpsRestExceptionHandlerSpec.groovy14
2 files changed, 16 insertions, 3 deletions
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 b8ba08915c..993c5a3b52 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
@@ -1,6 +1,6 @@
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2020-2022 Nordix Foundation
+ * Copyright (C) 2020-2023 Nordix Foundation
* Modifications Copyright (C) 2020-2021 Bell Canada.
* Modifications Copyright (C) 2021 Pantheon.tech
* Modifications Copyright (C) 2022 TechMahindra Ltd.
@@ -26,6 +26,7 @@ package org.onap.cps.rest.controller;
import static org.onap.cps.rest.utils.MultipartFileUtil.extractYangResourcesMap;
import static org.onap.cps.spi.CascadeDeleteAllowed.CASCADE_DELETE_PROHIBITED;
+import io.micrometer.core.annotation.Timed;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
@@ -116,6 +117,8 @@ public class AdminRestController implements CpsAdminApi {
* @return a {@Link ResponseEntity} of created schema set without any response body & {@link HttpStatus} CREATED
*/
@Override
+ @Timed(value = "cps.rest.admin.controller.schemaset.create",
+ description = "Time taken to create schemaset from controller")
public ResponseEntity<Void> createSchemaSetV2(@NotNull @Valid final String schemaSetName,
final String dataspaceName, @Valid final MultipartFile multipartFile) {
cpsModuleService.createSchemaSet(dataspaceName, schemaSetName, extractYangResourcesMap(multipartFile));
diff --git a/cps-rest/src/test/groovy/org/onap/cps/rest/exceptions/CpsRestExceptionHandlerSpec.groovy b/cps-rest/src/test/groovy/org/onap/cps/rest/exceptions/CpsRestExceptionHandlerSpec.groovy
index 0821b6bebc..535b83df76 100644
--- a/cps-rest/src/test/groovy/org/onap/cps/rest/exceptions/CpsRestExceptionHandlerSpec.groovy
+++ b/cps-rest/src/test/groovy/org/onap/cps/rest/exceptions/CpsRestExceptionHandlerSpec.groovy
@@ -1,7 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2020 Pantheon.tech
- * Modifications Copyright (C) 2021-2022 Nordix Foundation
+ * Modifications Copyright (C) 2021-2023 Nordix Foundation
* Modifications Copyright (C) 2021 Bell Canada.
* Modifications Copyright (C) 2022 TechMahindra Ltd.
* Modifications Copyright (C) 2022 Deutsche Telekom AG
@@ -136,8 +136,18 @@ class CpsRestExceptionHandlerSpec extends Specification {
"Anchor with name ${existingObjectName} already exists for ${dataspaceName}.")
}
+ def 'Request with a schema set in use exception returns HTTP Status Conflict.'() {
+ when: 'Schema set in use exception is thrown by the service'
+ setupTestException(new SchemaSetInUseException(dataspaceName, existingObjectName))
+ def response = performTestRequest()
+ then: 'a HTTP conflict response is returned with correct message an details'
+ assertTestResponse(response, CONFLICT,
+ "Schema Set is being used.",
+ "Schema Set with name ${existingObjectName} in dataspace ${dataspaceName} is having Anchor records associated.")
+ }
+
def 'Get request with a #exceptionThrown.class.simpleName returns HTTP Status Bad Request'() {
- when: 'CPS validation exception is thrown by the service'
+ when: '#exceptionThrown.class.simpleName is thrown by the service'
setupTestException(exceptionThrown)
def response = performTestRequest()
then: 'an HTTP Bad Request response is returned with correct message and details'