Reformat ONAP-SDK-APP test cases 60/78460/2
authorkaihlavi <l.kaihlavirt@partner.samsung.com>
Thu, 14 Feb 2019 10:08:36 +0000 (12:08 +0200)
committerkaihlavi <l.kaihlavirt@partner.samsung.com>
Thu, 14 Feb 2019 14:04:19 +0000 (16:04 +0200)
Reformat test cases to follow ONAP style
https://wiki.onap.org/display/DW/Java+code+style

Format changes mainly consist of conversions of tabs to 4 spaces

Samsung modifications copyrights added

Issue-ID: POLICY-1506
Change-Id: I71ddf1137f4ab6b84474e85b6c521daf07c9beee
Signed-off-by: kaihlavi <l.kaihlavirt@partner.samsung.com>
ONAP-SDK-APP/src/test/java/org/onap/portalapp/conf/ExternalAppConfigTest.java
ONAP-SDK-APP/src/test/java/org/onap/portalapp/conf/ExternalAppInitializerTest.java
ONAP-SDK-APP/src/test/java/org/onap/portalapp/conf/HibernateMappingLocationsTest.java
ONAP-SDK-APP/src/test/java/org/onap/portalapp/filter/SecurityXssFilterTest.java
ONAP-SDK-APP/src/test/java/org/onap/portalapp/login/LoginStrategyImplTest.java
ONAP-SDK-APP/src/test/java/org/onap/portalapp/scheduler/RegisterTest.java
ONAP-SDK-APP/src/test/java/org/onap/portalapp/scheduler/RegistryAdapterTest.java
ONAP-SDK-APP/src/test/java/org/onap/portalapp/service/AdminAuthExtensionTest.java

index 133d4a8..fb11e24 100644 (file)
@@ -1,15 +1,17 @@
 /*-
  * ============LICENSE_START=======================================================
- * ONAP Policy Engine
+ * ONAP Portal SDK
  * ================================================================================
  * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
+ * Modifications Copyright (C) 2019 Samsung
+ * ================================================================================
  * 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.
@@ -36,37 +38,36 @@ import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
 import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
 
 public class ExternalAppConfigTest {
-  @Test
-  public void testConfig() throws MalformedURLException {
-    // Setup test data
-    ApplicationContext ctx = Mockito.mock(ApplicationContext.class);
-    UrlResource value = new UrlResource("http://localhost");
-    Mockito.when(ctx.getResource(Mockito.any())).thenReturn(value);
-    ResourceHandlerRegistry registry = new ResourceHandlerRegistry(ctx, null);
-    InterceptorRegistry interceptor = new InterceptorRegistry();
-    RegistryAdapter schedulerRegistryAdapter = new RegistryAdapter();
-    Registerable reg = Mockito.mock(Registerable.class);
-    Mockito.when(reg.getTriggers()).thenReturn(new Trigger[1]);
-    schedulerRegistryAdapter.setRegistry(reg);
-    WorkflowScheduleService workflowScheduleService = Mockito.mock(WorkflowScheduleService.class);
-    schedulerRegistryAdapter.setWorkflowScheduleService(workflowScheduleService);
-    Mockito.when(workflowScheduleService.triggerWorkflowScheduling())
-        .thenReturn(Collections.emptyList());
+    @Test
+    public void testConfig() throws MalformedURLException {
+        // Setup test data
+        ApplicationContext ctx = Mockito.mock(ApplicationContext.class);
+        UrlResource value = new UrlResource("http://localhost");
+        Mockito.when(ctx.getResource(Mockito.any())).thenReturn(value);
+        ResourceHandlerRegistry registry = new ResourceHandlerRegistry(ctx, null);
+        InterceptorRegistry interceptor = new InterceptorRegistry();
+        RegistryAdapter schedulerRegistryAdapter = new RegistryAdapter();
+        Registerable reg = Mockito.mock(Registerable.class);
+        Mockito.when(reg.getTriggers()).thenReturn(new Trigger[1]);
+        schedulerRegistryAdapter.setRegistry(reg);
+        WorkflowScheduleService workflowScheduleService = Mockito.mock(WorkflowScheduleService.class);
+        schedulerRegistryAdapter.setWorkflowScheduleService(workflowScheduleService);
+        Mockito.when(workflowScheduleService.triggerWorkflowScheduling()).thenReturn(Collections.emptyList());
 
-    // Test constructor
-    ExternalAppConfig config = new ExternalAppConfig();
-    assertNotNull(config);
+        // Test constructor
+        ExternalAppConfig config = new ExternalAppConfig();
+        assertNotNull(config);
 
-    // Test set and get
-    config.setApplicationContext(ctx);
-    assertNotNull(config.viewResolver());
-    config.addResourceHandlers(registry);
-    assertNotNull(config.dataAccessService());
-    assertNotNull(config.addTileDefinitions());
-    config.addInterceptors(interceptor);
-    assertNotNull(config.cacheManager());
-    config.setSchedulerRegistryAdapter(schedulerRegistryAdapter);
-    assertNull(config.schedulerFactoryBean());
-    assertNotNull(config.loginStrategy());
-  }
+        // Test set and get
+        config.setApplicationContext(ctx);
+        assertNotNull(config.viewResolver());
+        config.addResourceHandlers(registry);
+        assertNotNull(config.dataAccessService());
+        assertNotNull(config.addTileDefinitions());
+        config.addInterceptors(interceptor);
+        assertNotNull(config.cacheManager());
+        config.setSchedulerRegistryAdapter(schedulerRegistryAdapter);
+        assertNull(config.schedulerFactoryBean());
+        assertNotNull(config.loginStrategy());
+    }
 }
index 81bf7e9..7a2ab16 100644 (file)
@@ -4,12 +4,14 @@
  * ================================================================================
  * Copyright (C) 2018 AT&T Intellectual Property
  * ================================================================================
+ * Modifications Copyright (C) 2019 Samsung
+ * ================================================================================
  * 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.
 package org.onap.portalapp.conf;
 
 import static org.junit.Assert.assertTrue;
-
 import org.junit.Test;
 
 public class ExternalAppInitializerTest {
 
-       @Test
-       public void testExternalAppInitializer(){
-               ExternalAppInitializer initializer = new ExternalAppInitializer();
-               assertTrue(initializer.getRootConfigClasses()!=null);
-               assertTrue(initializer.getServletConfigClasses()!=null);
-               assertTrue(initializer.getServletMappings()!=null);
-       }
-       
-       @Test
-       public void testExternalAppConfig(){
-               ExternalAppConfig appConfig = new ExternalAppConfig();
-               assertTrue(appConfig.dataAccessService()!=null);
-               assertTrue(appConfig.addTileDefinitions()!=null);
-               assertTrue(appConfig.cacheManager()!=null);
-               assertTrue(appConfig.loginStrategy()!=null);
-               assertTrue(appConfig.viewResolver()!=null);
-       }
+    @Test
+    public void testExternalAppInitializer() {
+        ExternalAppInitializer initializer = new ExternalAppInitializer();
+        assertTrue(initializer.getRootConfigClasses() != null);
+        assertTrue(initializer.getServletConfigClasses() != null);
+        assertTrue(initializer.getServletMappings() != null);
+    }
+
+    @Test
+    public void testExternalAppConfig() {
+        ExternalAppConfig appConfig = new ExternalAppConfig();
+        assertTrue(appConfig.dataAccessService() != null);
+        assertTrue(appConfig.addTileDefinitions() != null);
+        assertTrue(appConfig.cacheManager() != null);
+        assertTrue(appConfig.loginStrategy() != null);
+        assertTrue(appConfig.viewResolver() != null);
+    }
 }
index 6762e4a..25d878e 100644 (file)
@@ -4,12 +4,14 @@
  * ================================================================================
  * Copyright (C) 2018 AT&T Intellectual Property
  * ================================================================================
+ * Modifications Copyright (C) 2019 Samsung
+ * ================================================================================
  * 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.
 package org.onap.portalapp.conf;
 
 import static org.junit.Assert.assertTrue;
-
 import org.junit.Test;
 
 public class HibernateMappingLocationsTest {
 
-       @Test
-       public void testHibernateMappingLocations(){
-               HibernateMappingLocations locations = new HibernateMappingLocations();
-               assertTrue(locations.getMappingLocations()!=null);
-               assertTrue(locations.getPackagesToScan()!=null);
-       }
+    @Test
+    public void testHibernateMappingLocations() {
+        HibernateMappingLocations locations = new HibernateMappingLocations();
+        assertTrue(locations.getMappingLocations() != null);
+        assertTrue(locations.getPackagesToScan() != null);
+    }
 }
index 210b1d9..65fe123 100644 (file)
@@ -4,12 +4,14 @@
  * ================================================================================
  * Copyright (C) 2018 AT&T Intellectual Property
  * ================================================================================
+ * Modifications Copyright (C) 2019 Samsung
+ * ================================================================================
  * 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.
@@ -32,21 +34,21 @@ import com.mockrunner.mock.web.MockHttpServletRequest;
 import com.mockrunner.mock.web.MockHttpServletResponse;
 
 public class SecurityXssFilterTest {
-       @Test
-       public void testGets() throws ServletException, IOException {
-               SecurityXssFilter filter = new SecurityXssFilter();
-               assertNotNull(filter);
-               
-               MockHttpServletRequest request = new MockHttpServletRequest();
-               request.setMethod("POST");
-               request.setBodyContent("testBody");
-               request.setupAddParameter("testKey", "testVal");
-               request.setAttribute("testKey", "testVal");
-               request.setRequestURI("testVal");
-               request.setRequestURL("testVal");
-               MockHttpServletResponse response = new MockHttpServletResponse();
-               FilterChain filterChain = Mockito.mock(FilterChain.class);
-               filter.doFilterInternal(request, response, filterChain);
-               assertEquals(response.getStatusCode(), HttpServletResponse.SC_OK);
-       }
+    @Test
+    public void testGets() throws ServletException, IOException {
+        SecurityXssFilter filter = new SecurityXssFilter();
+        assertNotNull(filter);
+
+        MockHttpServletRequest request = new MockHttpServletRequest();
+        request.setMethod("POST");
+        request.setBodyContent("testBody");
+        request.setupAddParameter("testKey", "testVal");
+        request.setAttribute("testKey", "testVal");
+        request.setRequestURI("testVal");
+        request.setRequestURL("testVal");
+        MockHttpServletResponse response = new MockHttpServletResponse();
+        FilterChain filterChain = Mockito.mock(FilterChain.class);
+        filter.doFilterInternal(request, response, filterChain);
+        assertEquals(response.getStatusCode(), HttpServletResponse.SC_OK);
+    }
 }
index 25b6779..ac13bdc 100644 (file)
@@ -4,12 +4,14 @@
  * ================================================================================
  * Copyright (C) 2018 AT&T Intellectual Property
  * ================================================================================
+ * Modifications Copyright (C) 2019 Samsung
+ * ================================================================================
  * 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.
@@ -27,13 +29,13 @@ import org.onap.portalsdk.core.onboarding.exception.PortalAPIException;
 import org.springframework.mock.web.MockHttpServletRequest;
 
 public class LoginStrategyImplTest {
-       @Test
-       public void testLoginStrategyImpl() throws PortalAPIException {
-               LoginStrategyImpl impl = new LoginStrategyImpl();
-               MockHttpServletRequest request = new MockHttpServletRequest();
-               Cookie cookie1 = new Cookie("EPService", "serviceName");
-               Cookie cookie2 = new Cookie("UserId", "userName");
-               request.setCookies(cookie1, cookie2);
-               assertNull(impl.getUserId(request));
-       }
+    @Test
+    public void testLoginStrategyImpl() throws PortalAPIException {
+        LoginStrategyImpl impl = new LoginStrategyImpl();
+        MockHttpServletRequest request = new MockHttpServletRequest();
+        Cookie cookie1 = new Cookie("EPService", "serviceName");
+        Cookie cookie2 = new Cookie("UserId", "userName");
+        request.setCookies(cookie1, cookie2);
+        assertNull(impl.getUserId(request));
+    }
 }
index 0f406b1..675a87e 100644 (file)
@@ -4,12 +4,14 @@
  * ================================================================================
  * Copyright (C) 2018 AT&T Intellectual Property
  * ================================================================================
+ * Modifications Copyright (C) 2019 Samsung
+ * ================================================================================
  * 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.
@@ -22,10 +24,8 @@ package org.onap.portalapp.scheduler;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
-
 import java.util.ArrayList;
 import java.util.List;
-
 import org.junit.Test;
 import org.quartz.Trigger;
 import org.quartz.TriggerBuilder;
index b49ad6a..a7386aa 100644 (file)
@@ -4,12 +4,14 @@
  * ================================================================================
  * Copyright (C) 2018 AT&T Intellectual Property
  * ================================================================================
+ * Modifications Copyright (C) 2019 Samsung
+ * ================================================================================
  * 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.
@@ -30,39 +32,39 @@ import org.onap.portalsdk.workflow.services.WorkflowScheduleService;
 import org.springframework.scheduling.quartz.SchedulerFactoryBean;
 
 public class RegistryAdapterTest {
-       @Rule 
-       public final ExpectedException thrown = ExpectedException.none();
+    @Rule
+    public final ExpectedException thrown = ExpectedException.none();
+
+    @Test
+    public void testRegistryAdapter() {
+        RegistryAdapter adapter = new RegistryAdapter();
+        SchedulerFactoryBean schedulerBean = new SchedulerFactoryBean();
+        Registerable registry = null;
+        WorkflowScheduleService workflowScheduleService = null;
+
+        adapter.setSchedulerBean(schedulerBean);
+        assertEquals(adapter.getSchedulerBean(), schedulerBean);
+        adapter.setRegistry(registry);
+        assertEquals(adapter.getRegistry(), registry);
+        adapter.setWorkflowScheduleService(workflowScheduleService);
+        assertEquals(adapter.getWorkflowScheduleService(), workflowScheduleService);
+    }
 
-       @Test
-       public void testRegistryAdapter() {
-               RegistryAdapter adapter = new RegistryAdapter();
-               SchedulerFactoryBean schedulerBean = new SchedulerFactoryBean();
-               Registerable registry = null;
-               WorkflowScheduleService workflowScheduleService = null;
+    @Test
+    public void testRegistryAdapterNegCase1() {
+        thrown.expect(NullPointerException.class);
 
-               adapter.setSchedulerBean(schedulerBean);
-               assertEquals(adapter.getSchedulerBean(), schedulerBean);
-               adapter.setRegistry(registry);
-               assertEquals(adapter.getRegistry(), registry);
-               adapter.setWorkflowScheduleService(workflowScheduleService);
-               assertEquals(adapter.getWorkflowScheduleService(), workflowScheduleService);
-       }
-       
-       @Test
-       public void testRegistryAdapterNegCase1() {
-               thrown.expect(NullPointerException.class);
+        RegistryAdapter adapter = new RegistryAdapter();
+        adapter.getTriggers();
+        fail("Expecting an exception.");
+    }
 
-               RegistryAdapter adapter = new RegistryAdapter();
-               adapter.getTriggers();
-               fail("Expecting an exception.");
-       }
-       
-       @Test
-       public void testRegistryAdapterNegCase2() {
-               thrown.expect(NullPointerException.class);
+    @Test
+    public void testRegistryAdapterNegCase2() {
+        thrown.expect(NullPointerException.class);
 
-               RegistryAdapter adapter = new RegistryAdapter();
-               adapter.addCoreTriggers();
-               fail("Expecting an exception.");
-       }
+        RegistryAdapter adapter = new RegistryAdapter();
+        adapter.addCoreTriggers();
+        fail("Expecting an exception.");
+    }
 }
index 30a38d4..116f705 100644 (file)
@@ -4,12 +4,14 @@
  * ================================================================================
  * Copyright (C) 2018 AT&T Intellectual Property
  * ================================================================================
+ * Modifications Copyright (C) 2019 Samsung
+ * ================================================================================
  * 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.
 package org.onap.portalapp.service;
 
 import static org.junit.Assert.*;
-
 import java.util.SortedSet;
 import java.util.TreeSet;
-
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mockito;
@@ -33,54 +33,54 @@ import org.onap.portalsdk.core.domain.User;
 
 public class AdminAuthExtensionTest {
 
-       private CommonClassDao commonClassDao;
-       private AdminAuthExtension extension;
-       private User user;
+    private CommonClassDao commonClassDao;
+    private AdminAuthExtension extension;
+    private User user;
 
 
-       @Before
-       public void setUp(){
-               extension = new AdminAuthExtension();
-               commonClassDao = Mockito.mock(CommonClassDao.class);
-               Mockito.doNothing().when(commonClassDao).updateQuery("");
-               Mockito.doNothing().when(commonClassDao).save(new Object());
-               extension.setCommonClassDao(commonClassDao);
-               user = new User();
-               user.setFirstName("Test");
-               user.setLoginId("Test");
-       }
+    @Before
+    public void setUp() {
+        extension = new AdminAuthExtension();
+        commonClassDao = Mockito.mock(CommonClassDao.class);
+        Mockito.doNothing().when(commonClassDao).updateQuery("");
+        Mockito.doNothing().when(commonClassDao).save(new Object());
+        extension.setCommonClassDao(commonClassDao);
+        user = new User();
+        user.setFirstName("Test");
+        user.setLoginId("Test");
+    }
 
-       @Test
-       public void testAdminAuthExtension(){
-               try{
-                       callSaveUserFunction("Policy Super Admin");
-                       callSaveUserFunction("Policy Super Editor");
-                       callSaveUserFunction("Policy Super Guest");
-                       callSaveUserFunction("Policy Admin");
-                       callSaveUserFunction("Policy Editor");
-                       callSaveUserFunction("Policy Guest");
-                       extension.editUserExtension(user);
-                       extension.saveUserRoleExtension(null, user);
-               }catch(Exception e){
-                       fail("Not Expecting any exception.");
-               }
-       }
+    @Test
+    public void testAdminAuthExtension() {
+        try {
+            callSaveUserFunction("Policy Super Admin");
+            callSaveUserFunction("Policy Super Editor");
+            callSaveUserFunction("Policy Super Guest");
+            callSaveUserFunction("Policy Admin");
+            callSaveUserFunction("Policy Editor");
+            callSaveUserFunction("Policy Guest");
+            extension.editUserExtension(user);
+            extension.saveUserRoleExtension(null, user);
+        } catch (Exception e) {
+            fail("Not Expecting any exception.");
+        }
+    }
 
-       @Test
-       public void expectException(){
-               try{
-                       extension.saveUserExtension(null);
-               }catch(Exception e){
-                       assertEquals(NullPointerException.class, e.getClass());
-               }
-       }
+    @Test
+    public void expectException() {
+        try {
+            extension.saveUserExtension(null);
+        } catch (Exception e) {
+            assertEquals(NullPointerException.class, e.getClass());
+        }
+    }
 
-       public void callSaveUserFunction(String roleName){
-               SortedSet<Role> roles = new TreeSet<>();
-               Role role = new Role();
-               role.setName(roleName);
-               roles.add(role);
-               user.setRoles(roles);
-               extension.saveUserExtension(user);
-       }
+    public void callSaveUserFunction(String roleName) {
+        SortedSet<Role> roles = new TreeSet<>();
+        Role role = new Role();
+        role.setName(roleName);
+        roles.add(role);
+        user.setRoles(roles);
+        extension.saveUserExtension(user);
+    }
 }