- then: 'A data validation Exception is thrown'
- thrown(DataValidationException)
- }
-
- def 'Get resource data for pass-through operational from DMI with Json Processing Exception.'() {
- given: 'cps data service returns valid data node'
- mockCpsDataService.getDataNode('NCMP-Admin', 'ncmp-dmi-registry',
- cmHandleXPath, FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS) >> dataNode
- and: 'objectMapper not able to parse object'
- spiedJsonObjectMapper.asJsonString(_) >> { throw new JsonProcessingException('testException') }
- and: 'DMI returns NOK response'
- mockDmiDataOperations.getResourceDataFromDmi(*_)
- >> new ResponseEntity<>('NOK-json', HttpStatus.NOT_FOUND)
- when: 'get resource data is called'
- objectUnderTest.getResourceDataOperationalForCmHandle('testCmHandle',
- 'testResourceId',
- OPTIONS_PARAM,
- NO_TOPIC,
- NO_REQUEST_ID)
- 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.'() {
- given: 'cps data service returns valid data node'
- mockCpsDataService.getDataNode('NCMP-Admin', 'ncmp-dmi-registry',
- cmHandleXPath, FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS) >> dataNode
- and: 'DMI returns NOK response'
- mockDmiDataOperations.getResourceDataFromDmi('testCmHandle',
- 'testResourceId',
- OPTIONS_PARAM,
- PASSTHROUGH_OPERATIONAL,
- NO_REQUEST_ID,
- NO_TOPIC)
- >> new ResponseEntity<>('NOK-json', HttpStatus.NOT_FOUND)
- when: 'get resource data is called'
- objectUnderTest.getResourceDataOperationalForCmHandle('testCmHandle',
- 'testResourceId',
- OPTIONS_PARAM,
- NO_TOPIC,
- NO_REQUEST_ID)
- then: 'exception is thrown'
- def exceptionThrown = thrown(HttpClientRequestException.class)
- and: 'details contain the original response'
- exceptionThrown.httpStatus == HttpStatus.NOT_FOUND.value()
- exceptionThrown.details.contains('NOK-json')