diff options
Diffstat (limited to 'vid-app-common/src/test/java/org/onap/vid/config')
-rw-r--r-- | vid-app-common/src/test/java/org/onap/vid/config/DataSourceConfig.java | 7 | ||||
-rw-r--r-- | vid-app-common/src/test/java/org/onap/vid/config/JobCommandsConfigWithMockedMso.java | 207 |
2 files changed, 141 insertions, 73 deletions
diff --git a/vid-app-common/src/test/java/org/onap/vid/config/DataSourceConfig.java b/vid-app-common/src/test/java/org/onap/vid/config/DataSourceConfig.java index eb9239e1..ba8060da 100644 --- a/vid-app-common/src/test/java/org/onap/vid/config/DataSourceConfig.java +++ b/vid-app-common/src/test/java/org/onap/vid/config/DataSourceConfig.java @@ -25,20 +25,19 @@ public class DataSourceConfig { public LocalSessionFactoryBean sessionFactory(DataSource dataSource) { LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean(); sessionFactory.setDataSource(dataSource); - //I used this class org.openecomp.portalsdk.core.conf.HibernateConfiguration to learn how to config the session factory + //I used this class org.onap.portalsdk.core.conf.HibernateConfiguration to learn how to config the session factory // and use the following url for actual h2 properties //https://github.com/levi-putna/Hibernate-H2-Example/blob/master/hibernate-h2-example/src/hibernate.cfg.xml Properties properties = getH2Properties(); - properties.put("hibernate.default_schema", "PUBLIC"); properties.put("connection.pool_size", 10); properties.put("cache.provider_class", "org.hibernate.cache.internal.NoCacheProvider"); properties.put("hibernate.show_sql", false); properties.put("hbm2ddl.auto", "create"); properties.put("hibernate.hbm2ddl.auto", "create"); - sessionFactory.setHibernateProperties(properties); sessionFactory.setPackagesToScan("org.onap"); + sessionFactory.setHibernateProperties(properties); return sessionFactory; } @@ -55,6 +54,7 @@ public class DataSourceConfig { public Properties getH2Properties() { Properties properties = new Properties(); properties.put("dialect", "org.hibernate.dialect.H2Dialect"); + properties.put("hibernate.default_schema", "PUBLIC"); return properties; } @@ -64,6 +64,7 @@ public class DataSourceConfig { properties.put("connection.url", "jdbc:sqlite:memory:myDb"); properties.put("connection.username", "sa"); properties.put("connection.password", "sa"); + properties.put("hibernate.default_schema", "PUBLIC"); properties.put("dialect", "com.enigmabridge.hibernate.dialect.SQLiteDialect"); return properties; } diff --git a/vid-app-common/src/test/java/org/onap/vid/config/JobCommandsConfigWithMockedMso.java b/vid-app-common/src/test/java/org/onap/vid/config/JobCommandsConfigWithMockedMso.java index c1ac6a21..9cb9b33d 100644 --- a/vid-app-common/src/test/java/org/onap/vid/config/JobCommandsConfigWithMockedMso.java +++ b/vid-app-common/src/test/java/org/onap/vid/config/JobCommandsConfigWithMockedMso.java @@ -1,57 +1,27 @@ -/*- - * ============LICENSE_START======================================================= - * VID - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2018 Nokia. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - package org.onap.vid.config; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; import org.hibernate.SessionFactory; import org.mockito.Mockito; import org.onap.portalsdk.core.service.DataAccessService; -import org.onap.vid.aai.AaiOverTLSClient; -import org.onap.vid.aai.AaiOverTLSClientInterface; -import org.onap.vid.aai.AaiOverTLSPropertySupplier; +import org.onap.vid.aai.AaiClientInterface; import org.onap.vid.aai.util.HttpsAuthClient; import org.onap.vid.aai.util.SSLContextProvider; +import org.onap.vid.aai.util.ServletRequestHelper; import org.onap.vid.aai.util.SystemPropertyHelper; -import org.onap.vid.client.SyncRestClient; import org.onap.vid.job.JobAdapter; import org.onap.vid.job.JobsBrokerService; -import org.onap.vid.job.command.InProgressStatusCommand; -import org.onap.vid.job.command.JobCommandFactory; -import org.onap.vid.job.command.ServiceInstantiationCommand; +import org.onap.vid.job.command.*; import org.onap.vid.job.impl.JobAdapterImpl; import org.onap.vid.job.impl.JobWorker; import org.onap.vid.job.impl.JobsBrokerServiceInDatabaseImpl; import org.onap.vid.mso.RestMsoImplementation; -import org.onap.vid.services.AsyncInstantiationBusinessLogic; -import org.onap.vid.services.AsyncInstantiationBusinessLogicImpl; -import org.onap.vid.services.AuditService; -import org.onap.vid.services.AuditServiceImpl; +import org.onap.vid.services.*; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Scope; +import org.togglz.core.manager.FeatureManager; @Configuration public class JobCommandsConfigWithMockedMso { @@ -67,8 +37,23 @@ public class JobCommandsConfigWithMockedMso { } @Bean - public HttpsAuthClient httpsAuthClientFactory(){ - return new HttpsAuthClient("some random path", new SystemPropertyHelper(), new SSLContextProvider()); + public SSLContextProvider sslContextProvider() { + return new SSLContextProvider(); + } + + @Bean + public SystemPropertyHelper systemPropertyHelper() { + return new SystemPropertyHelper(); + } + + @Bean + public ServletRequestHelper servletRequestHelper() { + return new ServletRequestHelper(); + } + + @Bean + public HttpsAuthClient httpsAuthClientFactory(SystemPropertyHelper systemPropertyHelper, SSLContextProvider sslContextProvider, FeatureManager featureManager){ + return new HttpsAuthClient("some random path", systemPropertyHelper, sslContextProvider, featureManager); } @Bean @@ -90,31 +75,8 @@ public class JobCommandsConfigWithMockedMso { } @Bean - public AaiOverTLSClientInterface AaiOverTLSClient(){ - io.joshworks.restclient.http.mapper.ObjectMapper objectMapper = new io.joshworks.restclient.http.mapper.ObjectMapper() { - - ObjectMapper om = new ObjectMapper(); - - @Override - public <T> T readValue(String s, Class<T> aClass) { - try { - return om.readValue(s, aClass); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - @Override - public String writeValue(Object o) { - try { - return om.writeValueAsString(o); - } catch (JsonProcessingException e) { - throw new RuntimeException(e); - } - } - }; - - return new AaiOverTLSClient(new SyncRestClient(objectMapper), new AaiOverTLSPropertySupplier()); + public FeatureManager featureManager() { + return Mockito.mock(FeatureManager.class); } @Bean @@ -122,25 +84,130 @@ public class JobCommandsConfigWithMockedMso { JobAdapter jobAdapter, JobsBrokerService jobsBrokerService, SessionFactory sessionFactory, - AaiOverTLSClientInterface aaiOverTLSClientInterface) { - return new AsyncInstantiationBusinessLogicImpl(dataAccessService, jobAdapter, jobsBrokerService, sessionFactory, aaiOverTLSClientInterface); + AaiClientInterface aaiClient, + FeatureManager featureManager, + CloudOwnerService cloudOwnerService) { + return new AsyncInstantiationBusinessLogicImpl(dataAccessService, jobAdapter, jobsBrokerService, sessionFactory, aaiClient, featureManager, cloudOwnerService); + } + + @Bean + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public MacroServiceInstantiationCommand serviceInstantiationCommand() { + return new MacroServiceInstantiationCommand(); + } + + @Bean + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public ServiceInProgressStatusCommand inProgressStatusCommand() { + return new ServiceInProgressStatusCommand(); + } + + @Bean + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public ALaCarteServiceInstantiationCommand aLaCarteServiceInstantiationCommand() { + return new ALaCarteServiceInstantiationCommand(); + } + + @Bean + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public ALaCarteServiceCommand aLaCarteServiceCommand( + AsyncInstantiationBusinessLogic asyncInstantiationBusinessLogic, + JobsBrokerService jobsBrokerService, + MsoResultHandlerService msoResultHandlerService, + JobAdapter jobAdapter, + InProgressStatusService inProgressStatusService, + WatchChildrenJobsBL watchChildrenJobsBL, + RestMsoImplementation restMso) { + return new ALaCarteServiceCommand(inProgressStatusService, watchChildrenJobsBL, asyncInstantiationBusinessLogic, jobsBrokerService, msoResultHandlerService, jobAdapter, restMso); + } + + @Bean + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public InstanceGroupCommand instanceGroupCommand( + AsyncInstantiationBusinessLogic asyncInstantiationBusinessLogic, + MsoResultHandlerService msoResultHandlerService, InProgressStatusService inProgressStatusService, + WatchChildrenJobsBL watchChildrenJobsBL, + RestMsoImplementation restMso) { + return new InstanceGroupCommand(asyncInstantiationBusinessLogic, restMso, msoResultHandlerService, inProgressStatusService, watchChildrenJobsBL); + } + + @Bean + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public VnfInstantiationCommand vnfInstantiationCommand() { + return new VnfInstantiationCommand(); + } + + @Bean + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public VolumeGroupInstantiationCommand volumeGroupInstantiationCommand() { + return new VolumeGroupInstantiationCommand(); } @Bean @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) - public ServiceInstantiationCommand serviceInstantiationCommand() { - return new ServiceInstantiationCommand(); + public WatchingCommandBaseModule watchingCommandBaseModule() { + return new WatchingCommandBaseModule(); } @Bean @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) - public InProgressStatusCommand inProgressStatusCommand() { - return new InProgressStatusCommand(); + public VolumeGroupInProgressStatusCommand volumeGroupInProgressStatusCommand() { + return new VolumeGroupInProgressStatusCommand(); + } + + @Bean + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public VfmoduleInstantiationCommand vfmoduleInstantiationCommand() { + return new VfmoduleInstantiationCommand(); + } + + @Bean + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public WatchingCommand watchingCommandCommand() { + return new WatchingCommand(); + } + + @Bean + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public ResourceInProgressStatusCommand resourceInProgressStatusCommand() { + return new ResourceInProgressStatusCommand(); + } + + @Bean + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public VnfInProgressStatusCommand vnfInProgressStatusCommand() { + return new VnfInProgressStatusCommand(); + } + + @Bean + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public InstanceGroupInstantiationCommand instanceGroupInstantiationCommand() { + return new InstanceGroupInstantiationCommand(); + } + + @Bean + public AuditService auditService(AsyncInstantiationBusinessLogic asyncInstantiationBL, RestMsoImplementation msoClient) { + return new AuditServiceImpl(asyncInstantiationBL, msoClient); + } + + @Bean + public InProgressStatusService inProgressStatusService(AsyncInstantiationBusinessLogic asyncInstantiationBL, RestMsoImplementation restMso, AuditService auditService) { + return new InProgressStatusService(asyncInstantiationBL, restMso, auditService); + } + + @Bean + public MsoResultHandlerService rootCommandService(AsyncInstantiationBusinessLogic asyncInstantiationBL, AuditService auditService) { + return new MsoResultHandlerService(asyncInstantiationBL, auditService); + } + + @Bean + public CommandUtils commandUtils() { + return Mockito.mock(CommandUtils.class); } @Bean - public AuditService auditService() { - return new AuditServiceImpl(); + public WatchChildrenJobsBL watchChildrenJobsService(DataAccessService dataAccessService) { + return new WatchChildrenJobsBL(dataAccessService); } } |