2 * ============LICENSE_START=======================================================
3 * Copyright (c) 2021 Bell Canada.
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
21 package org.onap.cps.temporal.controller.rest
23 import org.springframework.beans.factory.annotation.Autowired
24 import org.springframework.beans.factory.annotation.Value
25 import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest
26 import org.springframework.http.HttpStatus
27 import org.springframework.http.MediaType
28 import org.springframework.test.web.servlet.MockMvc
30 import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get
32 import spock.lang.Specification
35 * Specification for Query Controller.
37 @WebMvcTest(QueryController)
38 class QueryControllerSpec extends Specification {
43 @Value('${rest.api.base-path}')
46 def myDataspace = 'my-dataspace'
47 def myAnchor = 'my-anchor'
48 def mySchemaset = 'my-schemaset'
50 def 'Get anchors by name is not implemented.'(){
52 def getAnchorsByNameEndpoint = "${basePath}/v1/dataspaces/{dataspace-name}/anchors/{anchor-name}/history"
54 when: 'get anchors by name endpoint is called'
55 def response = mvc.perform( get(getAnchorsByNameEndpoint, myDataspace, myAnchor)
56 .contentType(MediaType.APPLICATION_JSON))
59 then: 'received unsupported operation response'
60 response.getStatus() == HttpStatus.NOT_IMPLEMENTED.value()
64 def 'Get anchors by dataspace name is not implemented.'(){
66 def getAnchorsByDataspaceEndpoint = "${basePath}/v1/dataspaces/{dataspace-name}/anchors/history"
68 when: 'get anchors by dataspace name endpoint is called'
69 def response = mvc.perform( get(getAnchorsByDataspaceEndpoint, myDataspace).queryParam('schema-set-name', mySchemaset)
70 .contentType(MediaType.APPLICATION_JSON))
73 then: 'received unsupported operation response'
74 response.getStatus() == HttpStatus.NOT_IMPLEMENTED.value()