}
@Override
- public ResponseEntity<Object> updateResourceDataRunningForCmHandle(final String cmHandle,
- final String resourceIdentifier, final String requestBody, final String contentType) {
- return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
+ public ResponseEntity<Object> updateResourceDataRunningForCmHandle(final String resourceIdentifier,
+ final String cmHandle, final String requestBody, final String contentType) {
+ networkCmProxyDataService.updateResourceDataPassThroughRunningForCmHandle(cmHandle,
+ resourceIdentifier, requestBody, contentType);
+ return new ResponseEntity<>(HttpStatus.OK);
}
/**
final List<ConditionProperties> conditionProperties =
conditions.getConditions().stream().collect(Collectors.toList());
final CmHandles cmHandles = new CmHandles();
- final Collection<String> cmHandleIdentifiers = processConditions(conditionProperties);
- cmHandleIdentifiers.forEach(cmHandle -> cmHandles.setCmHandles(toCmHandleProperties(cmHandle)));
+ cmHandles.setCmHandles(toCmHandleProperties(processConditions(conditionProperties)));
return ResponseEntity.ok(cmHandles);
}
return moduleNames;
}
- private CmHandleProperties toCmHandleProperties(final String cmHandleId) {
+ private CmHandleProperties toCmHandleProperties(final Collection<String> cmHandleIdentifiers) {
final CmHandleProperties cmHandleProperties = new CmHandleProperties();
- final CmHandleProperty cmHandleProperty = new CmHandleProperty();
- cmHandleProperty.setCmHandleId(cmHandleId);
- cmHandleProperties.add(cmHandleProperty);
+ for (final String cmHandleIdentifier : cmHandleIdentifiers) {
+ final CmHandleProperty cmHandleProperty = new CmHandleProperty();
+ cmHandleProperty.setCmHandleId(cmHandleIdentifier);
+ cmHandleProperties.add(cmHandleProperty);
+ }
return cmHandleProperties;
}
response.contentAsString.contains('"leaf":"value"')
}
- def 'Get Resource Data from pass-through operational.' () {
+ def 'Get Resource Data from passthrough operational.' () {
given: 'resource data url'
def getUrl = "$ncmpBasePathV1/ch/testCmHandle/data/ds/ncmp-datastore:passthrough-operational" +
"?resourceIdentifier=parent/child&options=(a=1,b=2)"
response.status == HttpStatus.OK.value()
}
- def 'Get Resource Data from pass-through running with #scenario value in resource identifier param.' () {
+ def 'Get Resource Data from passthrough running with #scenario value in resource identifier param.' () {
given: 'resource data url'
def getUrl = "$ncmpBasePathV1/ch/testCmHandle/data/ds/ncmp-datastore:passthrough-running" +
"?resourceIdentifier=" + resourceIdentifier + "&options=(a=1,b=2)"
'? needs to be encoded as %3F' | 'idWith%3F'
}
- def 'Create Resource Data from pass-through running with #scenario.' () {
+ def 'Create Resource Data from passthrough running with #scenario.' () {
given: 'resource data url'
def getUrl = "$ncmpBasePathV1/ch/testCmHandle/data/ds/ncmp-datastore:passthrough-running" +
"?resourceIdentifier=parent/child"
given: 'an endpoint and json data'
def searchesEndpoint = "$ncmpBasePathV1/ch/searches"
String jsonData = TestUtils.getResourceFileContent('cmhandle-search.json')
- and: 'the service method is invoked with module names and returns a cm handle id'
- mockNetworkCmProxyDataService.executeCmHandleHasAllModulesSearch(['module1', 'module2']) >> ['some-cmhandle-id']
+ and: 'the service method is invoked with module names and returns two cm handle ids'
+ mockNetworkCmProxyDataService.executeCmHandleHasAllModulesSearch(['module1', 'module2']) >> ['some-cmhandle-id1', 'some-cmhandle-id2']
when: 'the searches api is invoked'
def response = mvc.perform(post(searchesEndpoint)
.contentType(MediaType.APPLICATION_JSON)
then: 'response status returns OK'
response.status == HttpStatus.OK.value()
and: 'the expected response content is returned'
- response.contentAsString == '{"cmHandles":[{"cmHandleId":"some-cmhandle-id"}]}'
+ response.contentAsString == '{"cmHandles":[{"cmHandleId":"some-cmhandle-id1"},{"cmHandleId":"some-cmhandle-id2"}]}'
}
def 'Call execute cm handle searches with unrecognized condition name.'() {
.contentType(MediaType.APPLICATION_JSON)
.content(jsonData)).andReturn().response
then: 'an empty cm handle identifier is returned'
- response.contentAsString == '{"cmHandles":null}'
+ response.contentAsString == '{"cmHandles":[]}'
}
- def 'Update resource data in passthrough-running datastore.' () {
+ def 'Update resource data from passthrough running.' () {
given: 'update resource data url'
def updateUrl = "$ncmpBasePathV1/ch/testCmHandle/data/ds/ncmp-datastore:passthrough-running" +
"?resourceIdentifier=parent/child"
.contentType(MediaType.APPLICATION_JSON_VALUE)
.accept(MediaType.APPLICATION_JSON_VALUE).content('some-request-body')
).andReturn().response
- then: 'the response status is not implemented'
- response.status == HttpStatus.NOT_IMPLEMENTED.value()
+ then: 'ncmp service method to update resource is called'
+ 1 * mockNetworkCmProxyDataService.updateResourceDataPassThroughRunningForCmHandle('testCmHandle',
+ 'parent/child', 'some-request-body', 'application/json;charset=UTF-8')
+ and: 'the response status is OK'
+ response.status == HttpStatus.OK.value()
}
}