Merge from ECOMP's repository
[vid.git] / vid-app-common / src / test / java / org / onap / vid / config / JobCommandsConfigWithMockedMso.java
1 package org.onap.vid.config;
2
3 import org.hibernate.SessionFactory;
4 import org.mockito.Mockito;
5 import org.onap.portalsdk.core.service.DataAccessService;
6 import org.onap.vid.aai.AaiClientInterface;
7 import org.onap.vid.aai.util.HttpsAuthClient;
8 import org.onap.vid.aai.util.SSLContextProvider;
9 import org.onap.vid.aai.util.ServletRequestHelper;
10 import org.onap.vid.aai.util.SystemPropertyHelper;
11 import org.onap.vid.job.JobAdapter;
12 import org.onap.vid.job.JobsBrokerService;
13 import org.onap.vid.job.command.*;
14 import org.onap.vid.job.impl.JobAdapterImpl;
15 import org.onap.vid.job.impl.JobWorker;
16 import org.onap.vid.job.impl.JobsBrokerServiceInDatabaseImpl;
17 import org.onap.vid.mso.RestMsoImplementation;
18 import org.onap.vid.services.*;
19 import org.springframework.beans.factory.config.ConfigurableBeanFactory;
20 import org.springframework.context.ApplicationContext;
21 import org.springframework.context.annotation.Bean;
22 import org.springframework.context.annotation.Configuration;
23 import org.springframework.context.annotation.Scope;
24 import org.togglz.core.manager.FeatureManager;
25
26 @Configuration
27 public class JobCommandsConfigWithMockedMso {
28
29     @Bean
30     public RestMsoImplementation restMso() {
31         return Mockito.mock(RestMsoImplementation.class);
32     }
33
34     @Bean
35     public JobsBrokerService jobsBrokerService(DataAccessService dataAccessService, SessionFactory sessionFactory) {
36         return new JobsBrokerServiceInDatabaseImpl(dataAccessService, sessionFactory, 200, 0);
37     }
38
39     @Bean
40     public SSLContextProvider sslContextProvider() {
41         return new SSLContextProvider();
42     }
43
44     @Bean
45     public SystemPropertyHelper systemPropertyHelper() {
46         return new SystemPropertyHelper();
47     }
48
49     @Bean
50     public ServletRequestHelper servletRequestHelper() {
51         return new ServletRequestHelper();
52     }
53
54     @Bean
55     public HttpsAuthClient httpsAuthClientFactory(SystemPropertyHelper systemPropertyHelper, SSLContextProvider sslContextProvider, FeatureManager featureManager){
56         return new HttpsAuthClient("some random path", systemPropertyHelper, sslContextProvider, featureManager);
57     }
58
59     @Bean
60     public JobAdapter jobAdapter() {
61         return new JobAdapterImpl();
62     }
63
64     @Bean
65     public JobCommandFactory jobCommandFactory(ApplicationContext applicationContext) {
66         return new JobCommandFactory(applicationContext);
67     }
68
69     @Bean
70     public JobWorker jobWorker(JobsBrokerService jobsBrokerService, JobCommandFactory jobCommandFactory) {
71         JobWorker jobWorker = new JobWorker();
72         jobWorker.setJobsBrokerService(jobsBrokerService);
73         jobWorker.setJobCommandFactory(jobCommandFactory);
74         return jobWorker;
75     }
76
77     @Bean
78     public FeatureManager featureManager() {
79         return Mockito.mock(FeatureManager.class);
80     }
81
82     @Bean
83     public AsyncInstantiationBusinessLogic asyncInstantiationBusinessLogic(DataAccessService dataAccessService,
84                                                                            JobAdapter jobAdapter,
85                                                                            JobsBrokerService jobsBrokerService,
86                                                                            SessionFactory sessionFactory,
87                                                                            AaiClientInterface aaiClient,
88                                                                            FeatureManager featureManager,
89                                                                            CloudOwnerService cloudOwnerService) {
90         return new AsyncInstantiationBusinessLogicImpl(dataAccessService, jobAdapter, jobsBrokerService, sessionFactory, aaiClient, featureManager, cloudOwnerService);
91     }
92
93     @Bean
94     @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
95     public MacroServiceInstantiationCommand serviceInstantiationCommand() {
96         return new MacroServiceInstantiationCommand();
97     }
98
99     @Bean
100     @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
101     public ServiceInProgressStatusCommand inProgressStatusCommand() {
102         return new ServiceInProgressStatusCommand();
103     }
104
105     @Bean
106     @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
107     public ALaCarteServiceInstantiationCommand aLaCarteServiceInstantiationCommand() {
108         return new ALaCarteServiceInstantiationCommand();
109     }
110
111     @Bean
112     @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
113     public ALaCarteServiceCommand aLaCarteServiceCommand(
114             AsyncInstantiationBusinessLogic asyncInstantiationBusinessLogic,
115             JobsBrokerService jobsBrokerService,
116             MsoResultHandlerService msoResultHandlerService,
117             JobAdapter jobAdapter,
118             InProgressStatusService inProgressStatusService,
119             WatchChildrenJobsBL watchChildrenJobsBL,
120             RestMsoImplementation restMso) {
121         return new ALaCarteServiceCommand(inProgressStatusService, watchChildrenJobsBL, asyncInstantiationBusinessLogic, jobsBrokerService, msoResultHandlerService, jobAdapter, restMso);
122     }
123
124     @Bean
125     @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
126     public InstanceGroupCommand instanceGroupCommand(
127             AsyncInstantiationBusinessLogic asyncInstantiationBusinessLogic,
128             MsoResultHandlerService msoResultHandlerService, InProgressStatusService inProgressStatusService,
129             WatchChildrenJobsBL watchChildrenJobsBL,
130             RestMsoImplementation restMso) {
131         return new InstanceGroupCommand(asyncInstantiationBusinessLogic, restMso, msoResultHandlerService, inProgressStatusService, watchChildrenJobsBL);
132     }
133
134     @Bean
135     @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
136     public VnfInstantiationCommand vnfInstantiationCommand() {
137         return new VnfInstantiationCommand();
138     }
139
140     @Bean
141     @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
142     public VolumeGroupInstantiationCommand volumeGroupInstantiationCommand() {
143         return new VolumeGroupInstantiationCommand();
144     }
145
146     @Bean
147     @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
148     public WatchingCommandBaseModule watchingCommandBaseModule() {
149         return new WatchingCommandBaseModule();
150     }
151
152     @Bean
153     @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
154     public VolumeGroupInProgressStatusCommand volumeGroupInProgressStatusCommand() {
155         return new VolumeGroupInProgressStatusCommand();
156     }
157
158     @Bean
159     @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
160     public VfmoduleInstantiationCommand vfmoduleInstantiationCommand() {
161         return new VfmoduleInstantiationCommand();
162     }
163
164     @Bean
165     @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
166     public WatchingCommand watchingCommandCommand() {
167         return new WatchingCommand();
168     }
169
170     @Bean
171     @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
172     public ResourceInProgressStatusCommand resourceInProgressStatusCommand() {
173         return new ResourceInProgressStatusCommand();
174     }
175
176     @Bean
177     @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
178     public VnfInProgressStatusCommand vnfInProgressStatusCommand() {
179         return new VnfInProgressStatusCommand();
180     }
181
182     @Bean
183     @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
184     public InstanceGroupInstantiationCommand instanceGroupInstantiationCommand() {
185         return new InstanceGroupInstantiationCommand();
186     }
187
188     @Bean
189     public AuditService auditService(AsyncInstantiationBusinessLogic asyncInstantiationBL, RestMsoImplementation msoClient) {
190         return new AuditServiceImpl(asyncInstantiationBL, msoClient);
191     }
192
193     @Bean
194     public InProgressStatusService inProgressStatusService(AsyncInstantiationBusinessLogic asyncInstantiationBL, RestMsoImplementation restMso, AuditService auditService) {
195         return new InProgressStatusService(asyncInstantiationBL, restMso, auditService);
196     }
197
198     @Bean
199     public MsoResultHandlerService rootCommandService(AsyncInstantiationBusinessLogic asyncInstantiationBL, AuditService auditService) {
200         return new MsoResultHandlerService(asyncInstantiationBL, auditService);
201     }
202
203     @Bean
204     public CommandUtils commandUtils() {
205         return Mockito.mock(CommandUtils.class);
206     }
207
208     @Bean
209     public WatchChildrenJobsBL watchChildrenJobsService(DataAccessService dataAccessService) {
210         return new WatchChildrenJobsBL(dataAccessService);
211     }
212
213 }