33283f1f828efab0e874a2b59021229238579b56
[cps.git] / integration-test / src / test / groovy / org / onap / cps / integration / TestConfig.groovy
1 /*
2  *  ============LICENSE_START=======================================================
3  *  Copyright (C) 2023 Nordix Foundation
4  *  ================================================================================
5  *  Licensed under the Apache License, Version 2.0 (the 'License');
6  *  you may not use this file except in compliance with the License.
7  *  You may obtain a copy of the License at
8  *
9  *        http://www.apache.org/licenses/LICENSE-2.0
10  *
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.integration
22
23 import com.fasterxml.jackson.databind.ObjectMapper
24 import org.onap.cps.notification.NotificationService
25 import org.onap.cps.spi.CpsDataPersistenceService
26 import org.onap.cps.spi.CpsModulePersistenceService
27 import org.onap.cps.spi.impl.CpsAdminPersistenceServiceImpl
28 import org.onap.cps.spi.impl.CpsDataPersistenceServiceImpl
29 import org.onap.cps.spi.impl.CpsModulePersistenceServiceImpl
30 import org.onap.cps.spi.repository.AnchorRepository
31 import org.onap.cps.spi.repository.DataspaceRepository
32 import org.onap.cps.spi.repository.FragmentNativeRepository
33 import org.onap.cps.spi.repository.FragmentRepository
34 import org.onap.cps.spi.repository.ModuleReferenceRepository
35 import org.onap.cps.spi.repository.SchemaSetRepository
36 import org.onap.cps.spi.repository.YangResourceRepository
37 import org.onap.cps.spi.utils.SessionManager
38 import org.onap.cps.utils.JsonObjectMapper
39 import org.springframework.beans.factory.annotation.Autowired
40 import org.springframework.context.annotation.Bean
41 import org.springframework.context.annotation.Configuration
42 import org.springframework.context.annotation.Lazy
43 import spock.lang.Specification
44
45 @Configuration
46 class TestConfig extends Specification{
47     @Autowired
48     @Lazy
49     DataspaceRepository dataspaceRepository
50
51     @Autowired
52     @Lazy
53     AnchorRepository anchorRepository
54
55     @Autowired
56     @Lazy
57     SchemaSetRepository schemaSetRepository
58
59     @Autowired
60     @Lazy
61     YangResourceRepository yangResourceRepository
62
63     @Autowired
64     @Lazy
65     FragmentRepository fragmentRepository
66
67     @Autowired
68     @Lazy
69     ModuleReferenceRepository moduleReferenceRepository
70
71     @Autowired
72     @Lazy
73     FragmentNativeRepository fragmentNativeRepository
74
75     @Autowired
76     @Lazy
77     JsonObjectMapper jsonObjectMapper
78
79     @Autowired
80     @Lazy
81     NotificationService stubbedNotificationService
82
83     @Autowired
84     @Lazy
85     SessionManager stubbedSessionManager
86
87     @Bean
88     CpsAdminPersistenceServiceImpl cpsAdminPersistenceService() {
89         new CpsAdminPersistenceServiceImpl(dataspaceRepository, anchorRepository, schemaSetRepository, yangResourceRepository)
90     }
91
92     @Bean
93     CpsDataPersistenceService cpsDataPersistenceService() {
94         return (CpsDataPersistenceService) new CpsDataPersistenceServiceImpl(dataspaceRepository, anchorRepository, fragmentRepository, jsonObjectMapper, stubbedSessionManager, fragmentNativeRepository)
95     }
96
97     @Bean
98     CpsModulePersistenceService cpsModulePersistenceService() {
99         return (CpsModulePersistenceService) new CpsModulePersistenceServiceImpl(yangResourceRepository, schemaSetRepository, dataspaceRepository, cpsAdminPersistenceService(), moduleReferenceRepository)
100     }
101
102     @Bean
103     JsonObjectMapper jsonObjectMapper() {
104         return new JsonObjectMapper(new ObjectMapper())
105     }
106
107     @Bean
108     NotificationService notificationService() {
109         return Stub(NotificationService)
110     }
111
112     @Bean
113     SessionManager sessionManager() {
114         return Stub(SessionManager)
115     }
116 }