2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2023-2024 Nordix Foundation
4 * Modifications Copyright (C) 2022-2023 TechMahindra Ltd.
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
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an 'AS IS' BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 * SPDX-License-Identifier: Apache-2.0
19 * ============LICENSE_END=========================================================
22 package org.onap.cps.integration.base
24 import java.time.OffsetDateTime
26 abstract class FunctionalSpecBase extends CpsIntegrationSpecBase {
28 def static FUNCTIONAL_TEST_DATASPACE_1 = 'functionalTestDataspace1'
29 def static FUNCTIONAL_TEST_DATASPACE_2 = 'functionalTestDataspace2'
30 def static FUNCTIONAL_TEST_DATASPACE_3 = 'functionalTestDataspace3'
31 def static NUMBER_OF_ANCHORS_PER_DATASPACE_WITH_BOOKSTORE_DATA = 2
32 def static NUMBER_OF_ANCHORS_PER_DATASPACE_WITH_BOOKSTORE_DELTA_DATA = 1
33 def static BOOKSTORE_ANCHOR_1 = 'bookstoreAnchor1'
34 def static BOOKSTORE_ANCHOR_2 = 'bookstoreAnchor2'
35 def static BOOKSTORE_ANCHOR_3 = 'bookstoreSourceAnchor1'
36 def static BOOKSTORE_ANCHOR_4 = 'copyOfSourceAnchor1'
37 def static BOOKSTORE_ANCHOR_5 = 'bookstoreAnchorForDeltaReport1'
39 def static initialized = false
40 def static bookstoreJsonData = readResourceDataFile('bookstore/bookstoreData.json')
41 def static bookstoreJsonDataForDeltaReport = readResourceDataFile('bookstore/bookstoreDataForDeltaReport.json')
45 setupBookstoreInfraStructure()
52 def setupBookstoreInfraStructure() {
53 cpsDataspaceService.createDataspace(FUNCTIONAL_TEST_DATASPACE_1)
54 cpsDataspaceService.createDataspace(FUNCTIONAL_TEST_DATASPACE_2)
55 cpsDataspaceService.createDataspace(FUNCTIONAL_TEST_DATASPACE_3)
56 createStandardBookStoreSchemaSet(FUNCTIONAL_TEST_DATASPACE_1)
57 createStandardBookStoreSchemaSet(FUNCTIONAL_TEST_DATASPACE_2)
58 createStandardBookStoreSchemaSet(FUNCTIONAL_TEST_DATASPACE_3)
61 def addBookstoreData() {
62 addAnchorsWithData(NUMBER_OF_ANCHORS_PER_DATASPACE_WITH_BOOKSTORE_DATA, FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_SCHEMA_SET, 'bookstoreAnchor', bookstoreJsonData)
63 addAnchorsWithData(NUMBER_OF_ANCHORS_PER_DATASPACE_WITH_BOOKSTORE_DATA, FUNCTIONAL_TEST_DATASPACE_2, BOOKSTORE_SCHEMA_SET, 'bookstoreAnchor', bookstoreJsonData)
67 addAnchorsWithData(NUMBER_OF_ANCHORS_PER_DATASPACE_WITH_BOOKSTORE_DELTA_DATA, FUNCTIONAL_TEST_DATASPACE_3, BOOKSTORE_SCHEMA_SET, 'bookstoreSourceAnchor', bookstoreJsonData)
68 addAnchorsWithData(NUMBER_OF_ANCHORS_PER_DATASPACE_WITH_BOOKSTORE_DELTA_DATA, FUNCTIONAL_TEST_DATASPACE_3, BOOKSTORE_SCHEMA_SET, 'copyOfSourceAnchor', bookstoreJsonData)
69 addAnchorsWithData(NUMBER_OF_ANCHORS_PER_DATASPACE_WITH_BOOKSTORE_DELTA_DATA, FUNCTIONAL_TEST_DATASPACE_3, BOOKSTORE_SCHEMA_SET, 'bookstoreAnchorForDeltaReport', bookstoreJsonDataForDeltaReport)
72 def restoreBookstoreDataAnchor(anchorNumber) {
73 def anchorName = 'bookstoreAnchor' + anchorNumber
74 cpsAnchorService.deleteAnchor(FUNCTIONAL_TEST_DATASPACE_1, anchorName)
75 cpsAnchorService.createAnchor(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_SCHEMA_SET, anchorName)
76 cpsDataService.saveData(FUNCTIONAL_TEST_DATASPACE_1, anchorName, bookstoreJsonData.replace('Easons', 'Easons-'+anchorNumber.toString()), OffsetDateTime.now())