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
- @RequestMapping("${rest.api.base-path}")
+ @RequestMapping("${rest.api.cps-base-path}")
public class DataRestController implements CpsDataApi {
@Autowired
@Autowired
MockMvc mvc
- @Value('${rest.api.base-path}')
+ @Value('${rest.api.cps-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 dataspaceName = 'my_dataspace'
def anchor = new Anchor(name: 'my_anchor')
def anchorList = [anchor]
+ def anchorName = 'my_anchor'
+ def schemaSetName = 'my_schema_set'
- def 'Create new dataspace'() {
- when:
- def response = performCreateDataspaceRequest("new-dataspace")
- then: 'Service method is invoked with expected parameters'
- 1 * mockCpsAdminService.createDataspace("new-dataspace")
- and: 'Dataspace is create successfully'
+ def 'Create new dataspace.'() {
+ given: 'an endpoint'
+ def createDataspaceEndpoint = "$basePath/v1/dataspaces";
+ when: 'post is invoked'
+ def response = mvc.perform(
+ post(createDataspaceEndpoint).param('dataspace-name', dataspaceName)).andReturn().response
+ then: 'service method is invoked with expected parameters'
+ 1 * mockCpsAdminService.createDataspace(dataspaceName)
+ and: 'dataspace is create successfully'
response.status == HttpStatus.CREATED.value()
}