Issue-ID: CPS-158
Change-Id: I1f9ff4429f331ca4204d1acaf73ac896a68994d0
Signed-off-by: Ruslan Kashapov <ruslan.kashapov@pantheon.tech>
- * [Swagger UI](http://localhost:8080/api/cps/swagger-ui/index.html)
- * [Api Documentation](http://localhost:8080/api/cps/v3/api-docs)
+ * [Swagger UI](http://localhost:8080/swagger-ui/index.html)
+ * [Api Documentation](http://localhost:8080/v3/api-docs)
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
@RestController
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
@RestController
+@RequestMapping("${rest.api.base-path}")
public class AdminRestController implements CpsAdminApi {
@Autowired
public class AdminRestController implements CpsAdminApi {
@Autowired
import org.onap.cps.rest.api.CpsDataApi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.onap.cps.rest.api.CpsDataApi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
@RestController
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
@RestController
+@RequestMapping("${rest.api.base-path}")
public class DataRestController implements CpsDataApi {
@Autowired
public class DataRestController implements CpsDataApi {
@Autowired
- servlet:\r
- context-path: /api/cps\r
+\r
+rest:\r
+ api:\r
+ base-path: /cps/api\r
endpoints:\r
web:\r
base-path: /manage\r
endpoints:\r
web:\r
base-path: /manage\r
+ exposure:\r
+ include: health,info,loggers\r
endpoint:\r
health:\r
show-details: always\r
# kubernetes probes: liveness and readiness\r
probes:\r
enabled: true\r
endpoint:\r
health:\r
show-details: always\r
# kubernetes probes: liveness and readiness\r
probes:\r
enabled: true\r
+ looging:\r
+ enabled: true\r
import org.onap.cps.spi.model.SchemaSet
import org.spockframework.spring.SpringBean
import org.springframework.beans.factory.annotation.Autowired
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
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest
import org.springframework.http.HttpStatus
import org.springframework.http.MediaType
+ @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'
def anchorsEndpoint = '/v1/dataspaces/my_dataspace/anchors'
def schemaSetsEndpoint = '/v1/dataspaces/test-dataspace/schema-sets'
def schemaSetEndpoint = schemaSetsEndpoint + '/my_schema_set'
def performCreateDataspaceRequest(String dataspaceName) {
return mvc.perform(
def performCreateDataspaceRequest(String dataspaceName) {
return mvc.perform(
- post('/v1/dataspaces').param('dataspace-name', dataspaceName)
+ post("$basePath/v1/dataspaces").param('dataspace-name', dataspaceName)
def performCreateSchemaSetRequest(multipartFile) {
return mvc.perform(
def performCreateSchemaSetRequest(multipartFile) {
return mvc.perform(
- multipart(schemaSetsEndpoint)
+ multipart("$basePath$schemaSetsEndpoint")
.file(multipartFile)
.param('schema-set-name', 'test-schema-set')
).andReturn().response
}
.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'() {
}
def 'Get existing schema set'() {
mockCpsModuleService.getSchemaSet('test-dataspace', 'my_schema_set') >>
new SchemaSet(name: 'my_schema_set', dataspaceName: 'test-dataspace')
when: 'get schema set API is invoked'
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')
then: 'the correct schema set is returned'
response.status == HttpStatus.OK.value()
response.getContentAsString().contains('my_schema_set')
requestParams.add('schema-set-name', 'my_schema-set')
requestParams.add('anchor-name', 'my_anchor')
when: 'post is invoked'
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')
.params(requestParams as MultiValueMap)).andReturn().response
then: 'Anchor is created successfully'
1 * mockCpsAdminService.createAnchor('my_dataspace', 'my_schema-set', 'my_anchor')
given:
mockCpsAdminService.getAnchors('my_dataspace') >> anchorList
when: 'get all anchors API is invoked'
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')
then: 'the correct anchor is returned'
response.status == HttpStatus.OK.value()
response.getContentAsString().contains('my_anchor')
import org.onap.cps.spi.exceptions.SchemaSetInUseException
import org.spockframework.spring.SpringBean
import org.springframework.beans.factory.annotation.Autowired
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
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest
import org.springframework.test.web.servlet.MockMvc
import spock.lang.Shared
+ @Value('${rest.api.base-path}')
+ def basePath
+
@Shared
def errorMessage = 'some error message'
@Shared
@Shared
def errorMessage = 'some error message'
@Shared
}
def performTestRequest() {
}
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,
}
void assertTestResponse(response, expectedStatus,