X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=cps-ncmp-service%2Fsrc%2Ftest%2Fgroovy%2Forg%2Fonap%2Fcps%2Fncmp%2Fapi%2Fimpl%2Foperations%2FDmiModelOperationsSpec.groovy;h=2efd6c2b3a1a7505343a5574d7d87b46d228c364;hb=05e7b8a207b1c641468e77d754fe1a5ae9e1a51e;hp=335bc062ccc9e118eedd78ddf8b2f70960708c30;hpb=db1e983f40be1db7bca5acacf5a3369d74a29c95;p=cps.git diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/DmiModelOperationsSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/DmiModelOperationsSpec.groovy index 335bc062c..2efd6c2b3 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/DmiModelOperationsSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/DmiModelOperationsSpec.groovy @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation + * Copyright (C) 2021-2022 Nordix Foundation * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,9 +21,11 @@ package org.onap.cps.ncmp.api.impl.operations import com.fasterxml.jackson.core.JsonProcessingException +import com.fasterxml.jackson.databind.ObjectMapper import org.onap.cps.ncmp.api.impl.config.NcmpConfiguration -import org.onap.cps.ncmp.api.impl.exception.NcmpException import org.onap.cps.spi.model.ModuleReference +import org.onap.cps.utils.JsonObjectMapper +import org.spockframework.spring.SpringBean import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.context.SpringBootTest import org.springframework.http.HttpStatus @@ -41,6 +43,9 @@ class DmiModelOperationsSpec extends DmiOperationsBaseSpec { @Autowired DmiModelOperations objectUnderTest + @SpringBean + JsonObjectMapper spiedJsonObjectMapper = Spy(new JsonObjectMapper(new ObjectMapper())) + def 'Retrieving module references.'() { given: 'a persistence cm handle' mockPersistenceCmHandleRetrieval([]) @@ -158,11 +163,11 @@ class DmiModelOperationsSpec extends DmiOperationsBaseSpec { given: 'a persistence cm handle' mockPersistenceCmHandleRetrieval([]) and: 'a Json processing exception occurs' - spyObjectMapper.writeValueAsString(_) >> {throw (new JsonProcessingException(''))} + spiedJsonObjectMapper.asJsonString(_) >> {throw (new JsonProcessingException('parsing error'))} when: 'a dmi operation is executed' objectUnderTest.getModuleReferences(persistenceCmHandle) then: 'an ncmp exception is thrown' - def exceptionThrown = thrown(NcmpException) + def exceptionThrown = thrown(JsonProcessingException) and: 'the message indicates a parsing error' exceptionThrown.message.toLowerCase().contains('parsing error') }