Introduce Instrumentation
[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.onap.cps.utils.TimedYangParser
40 import org.onap.cps.yang.TimedYangTextSchemaSourceSetBuilder
41 import org.springframework.beans.factory.annotation.Autowired
42 import org.springframework.context.annotation.Bean
43 import org.springframework.context.annotation.Configuration
44 import org.springframework.context.annotation.Lazy
45 import spock.lang.Specification
46
47 @Configuration
48 class TestConfig extends Specification{
49     @Autowired
50     @Lazy
51     DataspaceRepository dataspaceRepository
52
53     @Autowired
54     @Lazy
55     AnchorRepository anchorRepository
56
57     @Autowired
58     @Lazy
59     SchemaSetRepository schemaSetRepository
60
61     @Autowired
62     @Lazy
63     YangResourceRepository yangResourceRepository
64
65     @Autowired
66     @Lazy
67     FragmentRepository fragmentRepository
68
69     @Autowired
70     @Lazy
71     ModuleReferenceRepository moduleReferenceRepository
72
73     @Autowired
74     @Lazy
75     FragmentNativeRepository fragmentNativeRepository
76
77     @Autowired
78     @Lazy
79     JsonObjectMapper jsonObjectMapper
80
81     @Autowired
82     @Lazy
83     SessionManager stubbedSessionManager
84
85     @Bean
86     CpsAdminPersistenceServiceImpl cpsAdminPersistenceService() {
87         new CpsAdminPersistenceServiceImpl(dataspaceRepository, anchorRepository, schemaSetRepository, yangResourceRepository)
88     }
89
90     @Bean
91     CpsDataPersistenceService cpsDataPersistenceService() {
92         return (CpsDataPersistenceService) new CpsDataPersistenceServiceImpl(dataspaceRepository, anchorRepository, fragmentRepository, jsonObjectMapper, stubbedSessionManager, fragmentNativeRepository)
93     }
94
95     @Bean
96     CpsModulePersistenceService cpsModulePersistenceService() {
97         return (CpsModulePersistenceService) new CpsModulePersistenceServiceImpl(yangResourceRepository, schemaSetRepository, dataspaceRepository, cpsAdminPersistenceService(), moduleReferenceRepository)
98     }
99
100     @Bean
101     JsonObjectMapper jsonObjectMapper() {
102         return new JsonObjectMapper(new ObjectMapper())
103     }
104
105     @Bean
106     NotificationService notificationService() {
107         return Stub(NotificationService)
108     }
109
110     @Bean
111     SessionManager sessionManager() {
112         return Stub(SessionManager)
113     }
114
115     @Bean
116     TimedYangParser timedYangParser() {
117         return new TimedYangParser()
118     }
119
120     @Bean
121     TimedYangTextSchemaSourceSetBuilder textSchemaSourceSetBuilder() {
122         return new TimedYangTextSchemaSourceSetBuilder()
123     }
124
125 }