c55f53c12158dc5596fd2b10f36c6a3b351ff359
[cps/ncmp-dmi-plugin.git] /
1 /*
2  *  ============LICENSE_START=======================================================
3  *  Copyright (C) 2024 Nordix Foundation
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
8  *
9  *        http://www.apache.org/licenses/LICENSE-2.0
10  *
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.
16  *
17  *  SPDX-License-Identifier: Apache-2.0
18  *  ============LICENSE_END=========================================================
19  */
20
21 package org.onap.cps.ncmp.dmi.datajobs.rest.controller
22
23 import org.onap.cps.ncmp.dmi.config.WebSecurityConfig
24 import org.springframework.beans.factory.annotation.Autowired
25 import org.springframework.beans.factory.annotation.Value
26 import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest
27 import org.springframework.context.annotation.Import
28 import org.springframework.http.HttpStatus
29 import org.springframework.security.test.context.support.WithMockUser
30 import org.springframework.test.web.servlet.MockMvc
31 import spock.lang.Specification
32
33 import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post
34
35 @Import(WebSecurityConfig)
36 @WebMvcTest(DmiDatajobsRestController.class)
37 @WithMockUser
38 class DmiDatajobsRestControllerSpec extends Specification{
39
40     @Autowired
41     private MockMvc mvc
42
43     @Value('${rest.api.dmi-base-path}/v1')
44     def basePathV1
45
46     def 'write request should return 501 HTTP Status' () {
47         given: 'URL to write a data job'
48             def getModuleUrl = "${basePathV1}/writeJob/001"
49         when: 'the request is posted'
50             def response = mvc.perform(
51                 post(getModuleUrl)
52                         .contentType('application/3gpp-json-patch+json')
53         ).andReturn().response
54         then: 'response value is Not Implemented'
55             response.status == HttpStatus.NOT_IMPLEMENTED.value()
56     }
57
58     def 'read request should return 501 HTTP Status' () {
59         given: 'URL to write a data job'
60             def getModuleUrl = "${basePathV1}/readJob/001"
61         when: 'the request is posted'
62             def response = mvc.perform(
63                 post(getModuleUrl)
64                         .contentType('application/3gpp-json-patch+json')
65         ).andReturn().response
66         then: 'response value is Not Implemented'
67         response.status == HttpStatus.NOT_IMPLEMENTED.value()
68     }
69 }