2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.portalapp.conf;
23 import static org.junit.Assert.assertNotNull;
24 import static org.junit.Assert.assertNull;
25 import java.net.MalformedURLException;
26 import java.util.Collections;
27 import org.junit.Test;
28 import org.mockito.Mockito;
29 import org.onap.portalapp.scheduler.RegistryAdapter;
30 import org.onap.portalsdk.core.scheduler.Registerable;
31 import org.onap.portalsdk.workflow.services.WorkflowScheduleService;
32 import org.quartz.Trigger;
33 import org.springframework.context.ApplicationContext;
34 import org.springframework.core.io.UrlResource;
35 import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
36 import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
38 public class ExternalAppConfigTest {
40 public void testConfig() throws MalformedURLException {
42 ApplicationContext ctx = Mockito.mock(ApplicationContext.class);
43 UrlResource value = new UrlResource("http://localhost");
44 Mockito.when(ctx.getResource(Mockito.any())).thenReturn(value);
45 ResourceHandlerRegistry registry = new ResourceHandlerRegistry(ctx, null);
46 InterceptorRegistry interceptor = new InterceptorRegistry();
47 RegistryAdapter schedulerRegistryAdapter = new RegistryAdapter();
48 Registerable reg = Mockito.mock(Registerable.class);
49 Mockito.when(reg.getTriggers()).thenReturn(new Trigger[1]);
50 schedulerRegistryAdapter.setRegistry(reg);
51 WorkflowScheduleService workflowScheduleService = Mockito.mock(WorkflowScheduleService.class);
52 schedulerRegistryAdapter.setWorkflowScheduleService(workflowScheduleService);
53 Mockito.when(workflowScheduleService.triggerWorkflowScheduling())
54 .thenReturn(Collections.emptyList());
57 ExternalAppConfig config = new ExternalAppConfig();
58 assertNotNull(config);
61 config.setApplicationContext(ctx);
62 assertNotNull(config.viewResolver());
63 config.addResourceHandlers(registry);
64 assertNotNull(config.dataAccessService());
65 assertNotNull(config.addTileDefinitions());
66 config.addInterceptors(interceptor);
67 assertNotNull(config.cacheManager());
68 config.setSchedulerRegistryAdapter(schedulerRegistryAdapter);
69 assertNull(config.schedulerFactoryBean());
70 assertNotNull(config.loginStrategy());