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.get
34 import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post
36 @Import(WebSecurityConfig)
37 @WebMvcTest(DmiDatajobsRestController.class)
39 class DmiDatajobsRestControllerSpec extends Specification{
44 @Value('${rest.api.dmi-base-path}/v1')
47 def 'write request should return 501 HTTP Status' () {
48 given: 'URL to write a data job'
49 def getModuleUrl = "${basePathV1}/writeJob/001"
50 when: 'the request is posted'
51 def response = mvc.perform(
53 .contentType('application/3gpp-json-patch+json')
54 ).andReturn().response
55 then: 'response value is Not Implemented'
56 response.status == HttpStatus.NOT_IMPLEMENTED.value()
59 def 'read request should return 501 HTTP Status' () {
60 given: 'URL to write a data job'
61 def getModuleUrl = "${basePathV1}/readJob/001"
62 when: 'the request is posted'
63 def response = mvc.perform(
65 .contentType('application/3gpp-json-patch+json')
66 ).andReturn().response
67 then: 'response value is Not Implemented'
68 response.status == HttpStatus.NOT_IMPLEMENTED.value()
71 def 'get status request should return 501 HTTP Status' () {
72 given: 'URL to get the status of a data job'
73 def getStatus = "${basePathV1}/dataJob/some-identifier/dataProducerJob/some-producer-job-identifier/status?dataProducerId=some-data-producer-identifier"
74 when: 'the request is performed'
75 def response = mvc.perform(
77 .contentType('application/json')
78 ).andReturn().response
79 then: 'response value is Not Implemented'
80 response.status == HttpStatus.NOT_IMPLEMENTED.value()
83 def 'get result request should return 501 HTTP Status' () {
84 given: 'URL to get the result of a data job'
85 def getStatus = "${basePathV1}/dataJob/some-identifier/dataProducerJob/some-producer-job-identifier/result?dataProducerId=some-data-producer-identifier&destination=some-destination"
86 when: 'the request is performed'
87 def response = mvc.perform(
89 .contentType('application/json')
90 ).andReturn().response
91 then: 'response value is Not Implemented'
92 response.status == HttpStatus.NOT_IMPLEMENTED.value()