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
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.ncmp.dmi.datajobs.rest.controller
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
33 import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post
35 @Import(WebSecurityConfig)
36 @WebMvcTest(DmiDatajobsRestController.class)
38 class DmiDatajobsRestControllerSpec extends Specification{
43 @Value('${rest.api.dmi-base-path}/v1')
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(
52 .contentType('application/3gpp-json-patch+json')
53 ).andReturn().response
54 then: 'response value is Not Implemented'
55 response.status == HttpStatus.NOT_IMPLEMENTED.value()
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(
64 .contentType('application/3gpp-json-patch+json')
65 ).andReturn().response
66 then: 'response value is Not Implemented'
67 response.status == HttpStatus.NOT_IMPLEMENTED.value()