Fix upload size to be greater than 1MB
[cps.git] / cps-service / src / test / groovy / org / onap / cps / api / impl / CpsAdminServiceImplSpec.groovy
1 /*
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2020 Nordix Foundation
4  *  Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
5  *  ================================================================================
6  *  Licensed under the Apache License, Version 2.0 (the "License");
7  *  you may not use this file except in compliance with the License.
8  *  You may obtain a copy of the License at
9  *
10  *        http://www.apache.org/licenses/LICENSE-2.0
11  *  Unless required by applicable law or agreed to in writing, software
12  *  distributed under the License is distributed on an "AS IS" BASIS,
13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *  See the License for the specific language governing permissions and
15  *  limitations under the License.
16  *
17  *  SPDX-License-Identifier: Apache-2.0
18  *  ============LICENSE_END=========================================================
19  */
20
21 package org.onap.cps.api.impl
22
23 import org.onap.cps.spi.CpsAdminPersistenceService
24 import org.onap.cps.spi.model.Anchor
25 import spock.lang.Specification
26
27 class CpsAdminServiceImplSpec extends Specification {
28     def mockCpsAdminPersistenceService = Mock(CpsAdminPersistenceService)
29     def objectUnderTest = new CpsAdminServiceImpl()
30
31     def setup() {
32         objectUnderTest.cpsAdminPersistenceService = mockCpsAdminPersistenceService
33     }
34
35     def 'Create dataspace method invokes persistence service.'() {
36         when: 'Create dataspace method is invoked'
37             objectUnderTest.createDataspace('someDataspace')
38         then: 'The persistence service method is invoked with same parameters'
39             1 * mockCpsAdminPersistenceService.createDataspace('someDataspace')
40     }
41
42     def 'Create anchor method invokes persistence service.'() {
43         when: 'Create anchor method is invoked'
44             objectUnderTest.createAnchor('someDataspace', 'someSchemaSet', 'someAnchorName')
45         then: 'The persistence service method is invoked with same parameters'
46             1 * mockCpsAdminPersistenceService.createAnchor('someDataspace', 'someSchemaSet', 'someAnchorName')
47     }
48
49     def 'Retrieve all anchors for dataspace.'() {
50         given: 'that anchor is associated with the dataspace'
51             def anchors = [new Anchor()]
52             mockCpsAdminPersistenceService.getAnchors('someDataspace') >> anchors
53         expect: 'the collection provided by persistence service is returned as result'
54             objectUnderTest.getAnchors('someDataspace') == anchors
55     }
56
57     def 'Retrieve anchor for dataspace and provided anchor name.'() {
58         given: 'that anchor name is associated with the dataspace'
59             Anchor anchor = new Anchor()
60             mockCpsAdminPersistenceService.getAnchor('someDataspace','someAnchor') >>  anchor
61         expect: 'the anchor provided by persistence service is returned as result'
62             objectUnderTest.getAnchor('someDataspace','someAnchor') == anchor
63     }
64 }