diff options
author | Toine Siebelink <toine.siebelink@est.tech> | 2021-01-22 15:32:19 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2021-01-22 15:32:19 +0000 |
commit | 5fa9a9ebb6459755a4267066e23f9671b9fac5b9 (patch) | |
tree | 200dce73493b07663d8f330bce5eb2aa48fc3e33 /cps-rest/src/test/groovy | |
parent | d45aacaf71afbd352909f02876b86e62744fcae8 (diff) | |
parent | 708fd6615c97756eade415a6295b1fb663e4d3ef (diff) |
Merge "Enable log level management via actuator, /cps/api path to use for REST controllers only only"
Diffstat (limited to 'cps-rest/src/test/groovy')
-rw-r--r-- | cps-rest/src/test/groovy/org/onap/cps/rest/controller/AdminRestControllerSpec.groovy | 18 | ||||
-rw-r--r-- | cps-rest/src/test/groovy/org/onap/cps/rest/exceptions/CpsRestExceptionHandlerSpec.groovy | 6 |
2 files changed, 16 insertions, 8 deletions
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 60f54bfa7b..540d6224aa 100644 --- 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 @@ -29,6 +29,7 @@ import org.onap.cps.spi.model.Anchor import org.onap.cps.spi.model.SchemaSet import org.spockframework.spring.SpringBean import org.springframework.beans.factory.annotation.Autowired +import org.springframework.beans.factory.annotation.Value import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest import org.springframework.http.HttpStatus import org.springframework.http.MediaType @@ -60,6 +61,9 @@ class AdminRestControllerSpec extends Specification { @Autowired MockMvc mvc + @Value('${rest.api.base-path}') + def basePath + def anchorsEndpoint = '/v1/dataspaces/my_dataspace/anchors' def schemaSetsEndpoint = '/v1/dataspaces/test-dataspace/schema-sets' def schemaSetEndpoint = schemaSetsEndpoint + '/my_schema_set' @@ -168,7 +172,7 @@ class AdminRestControllerSpec extends Specification { def performCreateDataspaceRequest(String dataspaceName) { return mvc.perform( - post('/v1/dataspaces').param('dataspace-name', dataspaceName) + post("$basePath/v1/dataspaces").param('dataspace-name', dataspaceName) ).andReturn().response } @@ -191,14 +195,14 @@ class AdminRestControllerSpec extends Specification { def performCreateSchemaSetRequest(multipartFile) { return mvc.perform( - multipart(schemaSetsEndpoint) + multipart("$basePath$schemaSetsEndpoint") .file(multipartFile) .param('schema-set-name', 'test-schema-set') ).andReturn().response } - def performDeleteRequest(String uri) { - return mvc.perform(delete(uri)).andReturn().response + def performDeleteRequest(String deleteEndpoint) { + return mvc.perform(delete("$basePath$deleteEndpoint")).andReturn().response } def 'Get existing schema set'() { @@ -206,7 +210,7 @@ class AdminRestControllerSpec extends Specification { mockCpsModuleService.getSchemaSet('test-dataspace', 'my_schema_set') >> new SchemaSet(name: 'my_schema_set', dataspaceName: 'test-dataspace') when: 'get schema set API is invoked' - def response = mvc.perform(get(schemaSetEndpoint)).andReturn().response + def response = mvc.perform(get("$basePath$schemaSetEndpoint")).andReturn().response then: 'the correct schema set is returned' response.status == HttpStatus.OK.value() response.getContentAsString().contains('my_schema_set') @@ -218,7 +222,7 @@ class AdminRestControllerSpec extends Specification { requestParams.add('schema-set-name', 'my_schema-set') requestParams.add('anchor-name', 'my_anchor') when: 'post is invoked' - def response = mvc.perform(post(anchorsEndpoint).contentType(MediaType.APPLICATION_JSON) + def response = mvc.perform(post("$basePath$anchorsEndpoint").contentType(MediaType.APPLICATION_JSON) .params(requestParams as MultiValueMap)).andReturn().response then: 'Anchor is created successfully' 1 * mockCpsAdminService.createAnchor('my_dataspace', 'my_schema-set', 'my_anchor') @@ -230,7 +234,7 @@ class AdminRestControllerSpec extends Specification { given: mockCpsAdminService.getAnchors('my_dataspace') >> anchorList when: 'get all anchors API is invoked' - def response = mvc.perform(get(anchorsEndpoint)).andReturn().response + def response = mvc.perform(get("$basePath$anchorsEndpoint")).andReturn().response then: 'the correct anchor is returned' response.status == HttpStatus.OK.value() response.getContentAsString().contains('my_anchor') 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 d372d3c0b7..edc484b14a 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 @@ -33,6 +33,7 @@ import org.onap.cps.spi.exceptions.SchemaSetAlreadyDefinedException import org.onap.cps.spi.exceptions.SchemaSetInUseException import org.spockframework.spring.SpringBean import org.springframework.beans.factory.annotation.Autowired +import org.springframework.beans.factory.annotation.Value import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest import org.springframework.test.web.servlet.MockMvc import spock.lang.Shared @@ -60,6 +61,9 @@ class CpsRestExceptionHandlerSpec extends Specification { @Autowired MockMvc mvc + @Value('${rest.api.base-path}') + def basePath + @Shared def errorMessage = 'some error message' @Shared @@ -161,7 +165,7 @@ class CpsRestExceptionHandlerSpec extends Specification { } def performTestRequest() { - return mvc.perform(get('/v1/dataspaces/dataspace-name/anchors')).andReturn().response + return mvc.perform(get("$basePath/v1/dataspaces/dataspace-name/anchors")).andReturn().response } void assertTestResponse(response, expectedStatus, |