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.impl.datajobs
 
  23 import org.onap.cps.ncmp.impl.dmi.DmiProperties
 
  24 import org.onap.cps.ncmp.impl.dmi.DmiRestClient
 
  25 import org.onap.cps.ncmp.impl.dmi.UrlTemplateParameters
 
  26 import reactor.core.publisher.Mono
 
  27 import spock.lang.Specification
 
  29 class DataJobStatusServiceImplSpec extends Specification {
 
  31     def mockDmiRestClient = Mock(DmiRestClient)
 
  32     def mockDmiProperties = Mock(DmiProperties)
 
  33     def objectUnderTest = new DataJobStatusServiceImpl(mockDmiRestClient, mockDmiProperties)
 
  36         mockDmiProperties.dmiBasePath >> 'dmi'
 
  39     def 'Forward a data job status query to DMI.' () {
 
  40         given: 'the required parameters for querying'
 
  41             def dmiServiceName = 'some-dmi-service'
 
  42             def dataProducerId = 'some-data-producer-id'
 
  43             def dataProducerJobId = 'some-data-producer-job-id'
 
  44             def authorization = 'my authorization header'
 
  45             def urlParams = new UrlTemplateParameters('some-dmi-service/dmi/v1/cmwriteJob/dataProducer/{dataProducerId}/dataProducerJob/{dataProducerJobId}/status', ['dataProducerId':'some-data-producer-id', 'dataProducerJobId':'some-data-producer-job-id'])
 
  46         and: 'the rest client returns a status for the given parameters'
 
  47             mockDmiRestClient.getDataJobStatus(urlParams, authorization) >> Mono.just('some status')
 
  48         when: 'the job status is queried'
 
  49             def status = objectUnderTest.getDataJobStatus(authorization, dmiServiceName, dataProducerId, dataProducerJobId)
 
  50         then: 'the status from the rest client is returned'
 
  51             assert status == 'some status'