+ def 'Get Cm Handle details by Cm Handle id.'() {
+ given: 'an endpoint and a cm handle'
+ def cmHandleDetailsEndpoint = "$ncmpBasePathV1/ch/some-cm-handle"
+ and: 'an existing ncmp service cm handle'
+ def cmHandleId = 'some-cm-handle'
+ def dmiProperties = [ prop:'some DMI property' ]
+ def publicProperties = [ "public prop":'some public property' ]
+ def compositeState = new CompositeState(cmhandleState: CmHandleState.ADVISED,
+ lockReason: LockReason.builder().reason('LOCKED_OTHER').details("lock-misbehaving-details").build(),
+ lastUpdateTime: formattedDateAndTime.toString(),
+ dataSyncEnabled: false,
+ dataStores: dataStores())
+ def ncmpServiceCmHandle = new NcmpServiceCmHandle(cmHandleId: cmHandleId, dmiProperties: dmiProperties, publicProperties: publicProperties, compositeState: compositeState)
+ and: 'the service method is invoked with the cm handle id'
+ 1 * mockNetworkCmProxyDataService.getNcmpServiceCmHandle('some-cm-handle') >> ncmpServiceCmHandle
+ when: 'the cm handle details api is invoked'
+ def response = mvc.perform(get(cmHandleDetailsEndpoint)).andReturn().response
+ then: 'the correct response is returned'
+ response.status == HttpStatus.OK.value()
+ and: 'the response returns public properties and the correct cm handle states'
+ response.contentAsString.contains('publicCmHandleProperties')
+ response.contentAsString.contains('LOCKED_OTHER')
+ response.contentAsString.contains('lock-misbehaving-details')
+ response.contentAsString.contains('ADVISED')
+ response.contentAsString.contains('NONE_REQUESTED')
+ response.contentAsString.contains('2022-12-31T20:30:40.000+0000')
+ and: 'the content does not contain dmi properties'
+ !response.contentAsString.contains("some DMI property")
+ }
+
+ def 'Get Cm Handle public properties by Cm Handle id.' () {
+ given: 'a cm handle properties endpoint'
+ def cmHandlePropertiesEndpoint = "$ncmpBasePathV1/ch/some-cm-handle/properties"
+ and: 'some cm handle public properties'
+ def publicProperties = [ 'public prop':'some public property' ]
+ and: 'the service method is invoked with the cm handle id returning the cm handle public properties'
+ 1 * mockNetworkCmProxyDataService.getCmHandlePublicProperties('some-cm-handle') >> publicProperties
+ when: 'the cm handle properties api is invoked'
+ def response = mvc.perform(get(cmHandlePropertiesEndpoint)).andReturn().response
+ then: 'the correct response is returned'
+ response.status == HttpStatus.OK.value()
+ and: 'the response returns public properties and the correct properties'
+ response.contentAsString.equals('{"publicCmHandleProperties":[{"public prop":"some public property"}]}')
+ }
+