X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=cps-rest%2Fsrc%2Ftest%2Fgroovy%2Forg%2Fonap%2Fcps%2Frest%2Fcontroller%2FAdminRestControllerSpec.groovy;h=1ccd3ba661f7d6ab163bede83cf5ec3376d4d3c0;hb=674935d2ba1bad2b00f24815a9168b08cbf04933;hp=370ebaa6a4392c21fd95932e4d7401c77f5ce8d9;hpb=b20858b706445a4e10b781070f6620e92587985c;p=cps.git diff --git a/cps-rest/src/test/groovy/org/onap/cps/rest/controller/AdminRestControllerSpec.groovy b/cps-rest/src/test/groovy/org/onap/cps/rest/controller/AdminRestControllerSpec.groovy index 370ebaa6a..1ccd3ba66 100755 --- a/cps-rest/src/test/groovy/org/onap/cps/rest/controller/AdminRestControllerSpec.groovy +++ b/cps-rest/src/test/groovy/org/onap/cps/rest/controller/AdminRestControllerSpec.groovy @@ -153,6 +153,24 @@ class AdminRestControllerSpec extends Specification { 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() + } + @Unroll def 'Create schema set from zip archive having #caseDescriptor.'() { given: 'an endpoint' @@ -311,6 +329,11 @@ class AdminRestControllerSpec extends Specification { getClass().getResource(resourcePath).getBytes()) } + def createMultipartFileFromResource(resourcePath) { + return new MockMultipartFile("file", "test.yang", "application/text", + getClass().getResource(resourcePath).getBytes()) + } + def createMultipartFileForIOException(extension) { def multipartFile = Mock(MockMultipartFile) multipartFile.getOriginalFilename() >> "TEST." + extension