X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=cps-rest%2Fsrc%2Ftest%2Fgroovy%2Forg%2Fonap%2Fcps%2Frest%2Fcontroller%2FQueryRestControllerSpec.groovy;h=d43e02b31670b50edf2bfa05f7088b35b24b94cc;hb=be21595d53636e2c9b912bfbe8dfdefb81edc70f;hp=907528a5592611f3d275ebe017df4e6b6b94237d;hpb=f05a5032d369a9cf9052bf82ed62bad5cc4ee68b;p=cps.git diff --git a/cps-rest/src/test/groovy/org/onap/cps/rest/controller/QueryRestControllerSpec.groovy b/cps-rest/src/test/groovy/org/onap/cps/rest/controller/QueryRestControllerSpec.groovy index 907528a55..d43e02b31 100644 --- a/cps-rest/src/test/groovy/org/onap/cps/rest/controller/QueryRestControllerSpec.groovy +++ b/cps-rest/src/test/groovy/org/onap/cps/rest/controller/QueryRestControllerSpec.groovy @@ -2,12 +2,14 @@ * ============LICENSE_START======================================================= * Copyright (C) 2021 Nordix Foundation * Modifications Copyright (C) 2021 Bell Canada. + * Modifications Copyright (C) 2021 Pantheon.tech * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,6 +22,10 @@ package org.onap.cps.rest.controller +import static org.onap.cps.spi.FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS +import static org.onap.cps.spi.FetchDescendantsOption.OMIT_DESCENDANTS +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get + import com.google.gson.Gson import org.modelmapper.ModelMapper import org.onap.cps.api.CpsAdminService @@ -33,37 +39,20 @@ import org.springframework.beans.factory.annotation.Value import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest import org.springframework.http.HttpStatus import org.springframework.test.web.servlet.MockMvc -import spock.lang.Unroll - -import static org.onap.cps.spi.FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS -import static org.onap.cps.spi.FetchDescendantsOption.OMIT_DESCENDANTS -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get +import spock.lang.Specification -@WebMvcTest -class QueryRestControllerSpec extends RestControllerSpecification { - - @SpringBean - CpsDataService mockCpsDataService = Mock() - - @SpringBean - CpsModuleService mockCpsModuleService = Mock() - - @SpringBean - CpsAdminService mockCpsAdminService = Mock() +@WebMvcTest(QueryRestController) +class QueryRestControllerSpec extends Specification { @SpringBean CpsQueryService mockCpsQueryService = Mock() - @SpringBean - ModelMapper modelMapper = Mock() - @Autowired MockMvc mvc @Value('${rest.api.cps-base-path}') def basePath - @Unroll def 'Query data node by cps path for the given dataspace and anchor with #scenario.'() { given: 'service method returns a list containing a data node' def dataNode = new DataNodeBuilder().withXpath('/xpath').build() @@ -77,7 +66,6 @@ class QueryRestControllerSpec extends RestControllerSpecification { def response = mvc.perform( get(dataNodeEndpoint) - .header("Authorization", getAuthorizationHeader()) .param('cps-path', cpsPath) .param('include-descendants', includeDescendantsOption)) .andReturn().response @@ -90,4 +78,4 @@ class QueryRestControllerSpec extends RestControllerSpecification { 'no descendant explicitly' | 'false' || OMIT_DESCENDANTS 'descendants' | 'true' || INCLUDE_ALL_DESCENDANTS } -} \ No newline at end of file +}