2 * ============LICENSE_START==========================================
4 * ===================================================================
5 * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6 * ===================================================================
8 * Unless otherwise specified, all software contained herein is licensed
9 * under the Apache License, Version 2.0 (the "License");
10 * you may not use this software except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
21 * Unless otherwise specified, all documentation contained herein is licensed
22 * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
23 * you may not use this documentation except in compliance with the License.
24 * You may obtain a copy of the License at
26 * https://creativecommons.org/licenses/by/4.0/
28 * Unless required by applicable law or agreed to in writing, documentation
29 * distributed under the License is distributed on an "AS IS" BASIS,
30 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31 * See the License for the specific language governing permissions and
32 * limitations under the License.
34 * ============LICENSE_END============================================
36 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
38 package org.onap.portalapp.conf;
40 import static org.hamcrest.CoreMatchers.instanceOf;
41 import static org.hamcrest.CoreMatchers.is;
42 import static org.junit.Assert.assertThat;
44 import java.util.List;
46 import javax.servlet.http.HttpServletRequest;
47 import javax.servlet.http.HttpServletResponse;
48 import org.junit.Assert;
49 import org.junit.Test;
50 import org.onap.portalapp.login.LoginStrategyImpl;
51 import org.onap.portalapp.scheduler.RegistryAdapter;
52 import org.onap.portalsdk.core.auth.LoginStrategy;
53 import org.onap.portalsdk.core.onboarding.exception.PortalAPIException;
54 import org.onap.portalsdk.core.service.DataAccessService;
55 import org.springframework.web.servlet.ModelAndView;
56 import org.springframework.web.servlet.ViewResolver;
58 public class ExternalAppConfigTest {
60 private ExternalAppConfig createTestSubject() {
61 return new ExternalAppConfig();
65 public void testViewResolver() throws Exception {
66 ExternalAppConfig testSubject;
70 testSubject = createTestSubject();
71 result = testSubject.viewResolver();
77 public void testDataAccessService() throws Exception {
78 ExternalAppConfig testSubject;
79 DataAccessService result;
82 testSubject = createTestSubject();
83 result = testSubject.dataAccessService();
87 public void testAddTileDefinitions() throws Exception {
88 ExternalAppConfig testSubject;
92 testSubject = createTestSubject();
93 result = testSubject.addTileDefinitions();
99 public void testCacheManager() throws Exception {
100 ExternalAppConfig testSubject;
101 //AbstractCacheManager result;
104 testSubject = createTestSubject();
105 testSubject.cacheManager();
111 public void testSetSchedulerRegistryAdapter() throws Exception {
112 ExternalAppConfig testSubject;
113 RegistryAdapter schedulerRegistryAdapter = null;
116 testSubject = createTestSubject();
120 public void loginStrategy_givenEmptyString_yieldDefault() throws Exception {
121 assertThat(new ExternalAppConfig().loginStrategy(""),
122 is(instanceOf(LoginStrategyImpl.class)));
126 public void loginStrategy_givenNullString_yieldDefault() throws Exception {
127 assertThat(new ExternalAppConfig().loginStrategy(null),
128 is(instanceOf(LoginStrategyImpl.class)));
131 public static class DummyLoginStrategy extends LoginStrategy {
133 public ModelAndView doLogin(HttpServletRequest request, HttpServletResponse response) {
138 public String getUserId(HttpServletRequest request) {
144 public void loginStrategy_givenClassname_yieldClassInstance() throws Exception {
146 new ExternalAppConfig().loginStrategy("org.onap.portalapp.conf.ExternalAppConfigTest$DummyLoginStrategy"),
147 is(instanceOf(DummyLoginStrategy.class)));
150 @Test(expected = ClassNotFoundException.class)
151 public void loginStrategy_givenMissingClassname_throwsException() throws Exception {
152 new ExternalAppConfig().loginStrategy("no.real.classname");
153 Assert.fail("should throw");