2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2021-2022 Nordix Foundation
4 * Modifications Copyright (C) 2021 Pantheon.tech
5 * Modifications Copyright (C) 2021 Bell Canada.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the 'License');
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an 'AS IS' BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
19 * SPDX-License-Identifier: Apache-2.0
20 * ============LICENSE_END=========================================================
23 package org.onap.cps.spi.impl
25 import com.fasterxml.jackson.databind.ObjectMapper
26 import com.hazelcast.config.Config
27 import com.hazelcast.instance.impl.HazelcastInstanceFactory
28 import com.hazelcast.map.IMap
29 import org.onap.cps.DatabaseTestContainer
30 import org.onap.cps.spi.cache.AnchorDataCacheEntry
31 import org.onap.cps.spi.repository.AnchorRepository
32 import org.onap.cps.spi.repository.DataspaceRepository
33 import org.onap.cps.spi.repository.FragmentRepository
34 import org.onap.cps.spi.repository.YangResourceRepository
35 import org.onap.cps.utils.JsonObjectMapper
36 import org.spockframework.spring.SpringBean
37 import org.springframework.beans.factory.annotation.Autowired
38 import org.springframework.boot.test.context.SpringBootTest
39 import org.testcontainers.spock.Testcontainers
40 import spock.lang.Shared
41 import spock.lang.Specification
45 class CpsPersistenceSpecBase extends Specification {
48 DatabaseTestContainer databaseTestContainer = DatabaseTestContainer.getInstance()
51 DataspaceRepository dataspaceRepository
54 YangResourceRepository yangResourceRepository
57 AnchorRepository anchorRepository
60 FragmentRepository fragmentRepository
63 JsonObjectMapper jsonObjectMapper = new JsonObjectMapper(new ObjectMapper())
65 // Instantiate Hazelcast with different name for testing purposes!
67 IMap<String, AnchorDataCacheEntry> anchorDataCache = HazelcastInstanceFactory
68 .getOrCreateHazelcastInstance(new Config('hazelcastTestInstance'))
69 .getMap('testAnchorDataCacheMap')
71 static final String CLEAR_DATA = '/data/clear-all.sql'
73 static final String DATASPACE_NAME = 'DATASPACE-001'
74 static final String SCHEMA_SET_NAME1 = 'SCHEMA-SET-001'
75 static final String SCHEMA_SET_NAME2 = 'SCHEMA-SET-002'
76 static final String ANCHOR_NAME1 = 'ANCHOR-001'
77 static final String ANCHOR_NAME2 = 'ANCHOR-002'
78 static final String ANCHOR_NAME3 = 'ANCHOR-003'
79 static final String ANCHOR_FOR_DATA_NODES_WITH_LEAVES = 'ANCHOR-003'
80 static final String ANCHOR_FOR_SHOP_EXAMPLE = 'ANCHOR-004'