X-Git-Url: https://gerrit.onap.org/r/gitweb?p=cps.git;a=blobdiff_plain;f=cps-ncmp-service%2Fsrc%2Ftest%2Fgroovy%2Forg%2Fonap%2Fcps%2Fncmp%2Fapi%2Fimpl%2FNetworkCmProxyDataServiceImplSpec.groovy;h=06b2032b961d3cc355e1ac379cd4a56e3a115426;hp=c21d7e774228bdbd0756e26d65d19459dbd2df54;hb=93afc1eb95f38939ec0c60cce466d76d449e7faf;hpb=512f7ab93af18ed1f2bd93da18879666906521f6 diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplSpec.groovy index c21d7e774..06b2032b9 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplSpec.groovy @@ -22,6 +22,7 @@ package org.onap.cps.ncmp.api.impl +import org.onap.cps.ncmp.api.impl.exception.HttpClientRequestException import org.onap.cps.ncmp.api.impl.exception.InvalidTopicException import org.onap.cps.ncmp.api.impl.operations.YangModelCmHandleRetriever import org.onap.cps.ncmp.api.impl.yangmodels.YangModelCmHandle @@ -40,7 +41,6 @@ import com.fasterxml.jackson.databind.ObjectMapper import org.onap.cps.api.CpsAdminService import org.onap.cps.api.CpsDataService import org.onap.cps.api.CpsModuleService -import org.onap.cps.ncmp.api.impl.exception.ServerNcmpException import org.onap.cps.ncmp.api.impl.operations.DmiDataOperations import org.onap.cps.spi.FetchDescendantsOption import org.onap.cps.spi.model.DataNode @@ -98,9 +98,9 @@ class NetworkCmProxyDataServiceImplSpec extends Specification { 'testResourceId', CREATE, '{some-json}', 'application/json') then: 'exception is thrown' - def exceptionThrown = thrown(ServerNcmpException.class) - and: 'details contains (not found) error code: 404' - exceptionThrown.details.contains('404') + def exceptionThrown = thrown(HttpClientRequestException.class) + and: 'http status (not found) error code: 404' + exceptionThrown.httpStatus == HttpStatus.NOT_FOUND.value() } def 'Get resource data for pass-through operational from DMI.'() { @@ -141,9 +141,10 @@ class NetworkCmProxyDataServiceImplSpec extends Specification { 'testAcceptParam', OPTIONS_PARAM, NO_TOPIC) - then: 'exception is thrown with the expected details' - def exceptionThrown = thrown(ServerNcmpException.class) - exceptionThrown.details == 'DMI status code: 404, DMI response body: NOK-json' + then: 'exception is thrown with the expected response code and details' + def exceptionThrown = thrown(HttpClientRequestException.class) + exceptionThrown.details.contains('NOK-json') + exceptionThrown.httpStatus == HttpStatus.NOT_FOUND.value() } def 'Get resource data for pass-through operational from DMI return NOK response.'() { @@ -166,8 +167,9 @@ class NetworkCmProxyDataServiceImplSpec extends Specification { OPTIONS_PARAM, NO_TOPIC) then: 'exception is thrown' - def exceptionThrown = thrown(ServerNcmpException.class) - and: 'details contains the original response' + def exceptionThrown = thrown(HttpClientRequestException.class) + and: 'details contain the original response' + exceptionThrown.httpStatus == HttpStatus.NOT_FOUND.value() exceptionThrown.details.contains('NOK-json') } @@ -213,9 +215,10 @@ class NetworkCmProxyDataServiceImplSpec extends Specification { OPTIONS_PARAM, NO_TOPIC) then: 'exception is thrown' - def exceptionThrown = thrown(ServerNcmpException.class) - and: 'details contains the original response' + def exceptionThrown = thrown(HttpClientRequestException.class) + and: 'details contain the original response' exceptionThrown.details.contains('NOK-json') + exceptionThrown.httpStatus == HttpStatus.NOT_FOUND.value() } def 'DMI Operational data request with #scenario'() { @@ -340,12 +343,12 @@ class NetworkCmProxyDataServiceImplSpec extends Specification { '{some-json}', 'application/json') then: 'an exception is thrown with the expected error message details with correct operation' - def exceptionThrown = thrown(ServerNcmpException.class) + def exceptionThrown = thrown(HttpClientRequestException.class) exceptionThrown.getMessage().contains(expectedResponseMessage) where: scenario | givenOperation || expectedResponseMessage - 'CREATE' | CREATE || 'Not able to create resource data.' - 'READ' | READ || 'Not able to read resource data.' - 'UPDATE' | UPDATE || 'Not able to update resource data.' + 'CREATE' | CREATE || 'Unable to create resource data.' + 'READ' | READ || 'Unable to read resource data.' + 'UPDATE' | UPDATE || 'Unable to update resource data.' } }