+ def 'Create schema set from zip archive.'() {
+ def yangResourceMapCapture
+ given: 'zip archive with multiple .yang files inside'
+ def multipartFile = createZipMultipartFileFromResource("/yang-files-set.zip")
+ and: 'an endpoint'
+ def schemaSetEndpoint = "$basePath/v1/dataspaces/$dataspaceName/schema-sets"
+ when: 'file uploaded with schema set create request'
+ def response =
+ mvc.perform(
+ multipart(schemaSetEndpoint)
+ .file(multipartFile)
+ .param('schema-set-name', schemaSetName))
+ .andReturn().response
+ then: 'associated service method is invoked with expected parameters'
+ 1 * mockCpsModuleService.createSchemaSet(dataspaceName, schemaSetName, _) >>
+ { args -> yangResourceMapCapture = args[2] }
+ yangResourceMapCapture['assembly.yang'] == "fake assembly content 1\n"
+ yangResourceMapCapture['component.yang'] == "fake component content 1\n"
+ and: 'response code indicates success'
+ response.status == HttpStatus.CREATED.value()
+ }
+
+ def 'Create a schema set from a yang file that is greater than 1MB.'() {
+ given: 'a yang file greater than 1MB'
+ def multipartFile = createMultipartFileFromResource("/model-over-1mb.yang")
+ and: 'an endpoint'
+ def schemaSetEndpoint = "$basePath/v1/dataspaces/$dataspaceName/schema-sets"
+ when: 'a file is uploaded to the create schema set endpoint'
+ def response =
+ mvc.perform(
+ multipart(schemaSetEndpoint)
+ .file(multipartFile)
+ .param('schema-set-name', schemaSetName))
+ .andReturn().response
+ then: 'the associated service method is invoked'
+ 1 * mockCpsModuleService.createSchemaSet(dataspaceName, schemaSetName, _)
+ and: 'the response code indicates success'
+ response.status == HttpStatus.CREATED.value()
+ }
+
+ def 'Create schema set from zip archive having #caseDescriptor.'() {
+ given: 'an endpoint'
+ def schemaSetEndpoint = "$basePath/v1/dataspaces/$dataspaceName/schema-sets"
+ when: 'zip archive having #caseDescriptor is uploaded with create schema set request'
+ def response =
+ mvc.perform(
+ multipart(schemaSetEndpoint)
+ .file(multipartFile)
+ .param('schema-set-name', schemaSetName))
+ .andReturn().response
+ then: 'create schema set rejected'
+ response.status == HttpStatus.BAD_REQUEST.value()
+ where: 'following cases are tested'
+ caseDescriptor | multipartFile
+ 'no .yang files inside' | createZipMultipartFileFromResource("/no-yang-files.zip")
+ 'multiple .yang files with same name' | createZipMultipartFileFromResource("/yang-files-multiple-sets.zip")
+ }
+
+ def 'Create schema set from file with unsupported filename extension.'() {
+ given: 'file with unsupported filename extension (.doc)'