blob: 8f88b1e8eaa1eddd7633c83e09f76909311e0f6f [file] [log] [blame]
Aharoni, Pavel (pa0916)ca3cb012018-10-22 15:29:57 +03001/*-
2 * ============LICENSE_START=======================================================
3 * OSAM
4 * ================================================================================
5 * Copyright (C) 2018 AT&T
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
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
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.
18 * ============LICENSE_END=========================================================
19 */
20
21
22
23package org.onap.osam.config;
24
25import org.hibernate.SessionFactory;
26import org.mockito.Mockito;
27import org.onap.osam.services.IAsyncInstantiationBusinessLogic;
28import org.onap.portalsdk.core.service.DataAccessService;
29import org.onap.osam.aai.AaiClientInterface;
30import org.onap.osam.aai.util.HttpsAuthClient;
31import org.onap.osam.aai.util.SSLContextProvider;
32import org.onap.osam.aai.util.SystemPropertyHelper;
33import org.onap.osam.job.JobAdapter;
34import org.onap.osam.job.JobsBrokerService;
35import org.onap.osam.job.command.InProgressStatusCommand;
36import org.onap.osam.job.command.JobCommandFactory;
37import org.onap.osam.job.command.ServiceInstantiationCommand;
38import org.onap.osam.job.impl.JobAdapterImpl;
39import org.onap.osam.job.impl.JobWorker;
40import org.onap.osam.job.impl.JobsBrokerServiceInDatabaseImpl;
41import org.onap.osam.mso.RestMsoImplementation;
42import org.onap.osam.services.AsyncInstantiationBusinessLogicImpl;
43import org.onap.osam.services.IAuditService;
44import org.onap.osam.services.AuditServiceImpl;
45import org.springframework.beans.factory.config.ConfigurableBeanFactory;
46import org.springframework.context.ApplicationContext;
47import org.springframework.context.annotation.Bean;
48import org.springframework.context.annotation.Configuration;
49import org.springframework.context.annotation.Scope;
50
51@Configuration
52public class JobCommandsConfigWithMockedMso {
53
54 @Bean
55 public RestMsoImplementation restMso() {
56 return Mockito.mock(RestMsoImplementation.class);
57 }
58
59 @Bean
60 public JobsBrokerService jobsBrokerService(DataAccessService dataAccessService, SessionFactory sessionFactory) {
61 return new JobsBrokerServiceInDatabaseImpl(dataAccessService, sessionFactory, 200, 0);
62 }
63
64 @Bean
65 public HttpsAuthClient httpsAuthClientFactory(){
66 return new HttpsAuthClient("some random path", new SystemPropertyHelper(), new SSLContextProvider());
67 }
68
69 @Bean
70 public JobAdapter jobAdapter() {
71 return new JobAdapterImpl();
72 }
73
74 @Bean
75 public JobCommandFactory jobCommandFactory(ApplicationContext applicationContext) {
76 return new JobCommandFactory(applicationContext);
77 }
78
79 @Bean
80 public JobWorker jobWorker(JobsBrokerService jobsBrokerService, JobCommandFactory jobCommandFactory) {
81 JobWorker jobWorker = new JobWorker();
82 jobWorker.setJobsBrokerService(jobsBrokerService);
83 jobWorker.setJobCommandFactory(jobCommandFactory);
84 return jobWorker;
85 }
86
87 @Bean
88 public IAsyncInstantiationBusinessLogic asyncInstantiationBusinessLogic(DataAccessService dataAccessService,
89 JobAdapter jobAdapter,
90 JobsBrokerService jobsBrokerService,
91 SessionFactory sessionFactory,
92 AaiClientInterface aaiClient) {
93 return new AsyncInstantiationBusinessLogicImpl(dataAccessService, jobAdapter, jobsBrokerService, sessionFactory, aaiClient);
94 }
95
96 @Bean
97 @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
98 public ServiceInstantiationCommand serviceInstantiationCommand() {
99 return new ServiceInstantiationCommand();
100 }
101
102 @Bean
103 @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
104 public InProgressStatusCommand inProgressStatusCommand() {
105 return new InProgressStatusCommand();
106 }
107
108 @Bean
109 public IAuditService auditService() {
110 return new AuditServiceImpl();
111 }
112
113}