Aharoni, Pavel (pa0916) | ca3cb01 | 2018-10-22 15:29:57 +0300 | [diff] [blame] | 1 | /*-
|
| 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 |
|
| 23 | package org.onap.osam.config;
|
| 24 |
|
| 25 | import org.hibernate.SessionFactory;
|
| 26 | import org.mockito.Mockito;
|
| 27 | import org.onap.osam.services.IAsyncInstantiationBusinessLogic;
|
| 28 | import org.onap.portalsdk.core.service.DataAccessService;
|
| 29 | import org.onap.osam.aai.AaiClientInterface;
|
| 30 | import org.onap.osam.aai.util.HttpsAuthClient;
|
| 31 | import org.onap.osam.aai.util.SSLContextProvider;
|
| 32 | import org.onap.osam.aai.util.SystemPropertyHelper;
|
| 33 | import org.onap.osam.job.JobAdapter;
|
| 34 | import org.onap.osam.job.JobsBrokerService;
|
| 35 | import org.onap.osam.job.command.InProgressStatusCommand;
|
| 36 | import org.onap.osam.job.command.JobCommandFactory;
|
| 37 | import org.onap.osam.job.command.ServiceInstantiationCommand;
|
| 38 | import org.onap.osam.job.impl.JobAdapterImpl;
|
| 39 | import org.onap.osam.job.impl.JobWorker;
|
| 40 | import org.onap.osam.job.impl.JobsBrokerServiceInDatabaseImpl;
|
| 41 | import org.onap.osam.mso.RestMsoImplementation;
|
| 42 | import org.onap.osam.services.AsyncInstantiationBusinessLogicImpl;
|
| 43 | import org.onap.osam.services.IAuditService;
|
| 44 | import org.onap.osam.services.AuditServiceImpl;
|
| 45 | import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
| 46 | import org.springframework.context.ApplicationContext;
|
| 47 | import org.springframework.context.annotation.Bean;
|
| 48 | import org.springframework.context.annotation.Configuration;
|
| 49 | import org.springframework.context.annotation.Scope;
|
| 50 |
|
| 51 | @Configuration
|
| 52 | public 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 | }
|