import org.springframework.http.MediaType
import org.springframework.test.web.servlet.MockMvc
import spock.lang.Specification
-import spock.lang.Unroll
@WebMvcTest
class NetworkCmProxyControllerSpec extends Specification {
def cmHandle = 'some handle'
def xpath = 'some xpath'
- @Unroll
def 'Query data node by cps path for the given cm handle with #scenario.'() {
given: 'service method returns a list containing a data node'
def dataNode = new DataNodeBuilder().withXpath('/xpath').build()
'descendants' | 'true' || INCLUDE_ALL_DESCENDANTS
}
- @Unroll
def 'Create data node: #scenario.'() {
given: 'json data'
def jsonData = 'json data'
'parent node xpath' | '/xpath' || '/xpath'
}
+ def 'Add list-node elements.'() {
+ given: 'json data and parent node xpath'
+ def jsonData = 'json data'
+ def parentNodeXpath = 'parent node xpath'
+ when: 'post request is performed'
+ def response = mvc.perform(
+ post("$dataNodeBaseEndpoint/cm-handles/$cmHandle/list-node")
+ .contentType(MediaType.APPLICATION_JSON)
+ .content(jsonData)
+ .param('xpath', parentNodeXpath)
+ ).andReturn().response
+ then: 'the service method is invoked once with expected parameters'
+ 1 * mockNetworkCmProxyDataService.addListNodeElements(cmHandle, parentNodeXpath, jsonData)
+ and: 'response status indicates success'
+ response.status == HttpStatus.CREATED.value()
+ }
+
def 'Update data node leaves.'() {
given: 'json data'
def jsonData = 'json data'