From f51a3e2b128f0b96bc9ed67dfc3081f4b41d1303 Mon Sep 17 00:00:00 2001 From: "Kishore Reddy, Gujja (kg811t)" Date: Fri, 8 Jun 2018 16:40:16 -0400 Subject: Junit Test Cases & Raptors Issue-ID: PORTAL-273. PORTAL-301 Covered JUNITS for sdk modules and RAPTOR reports fixes Change-Id: Ifaf3bf06f0ec123051a791cc8e7f10662f97a525 Signed-off-by: Kishore Reddy, Gujja (kg811t) --- .../analytics/gmap/map/layer/SwingLayerTest.java | 112 +++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/gmap/map/layer/SwingLayerTest.java (limited to 'ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/gmap/map/layer/SwingLayerTest.java') diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/gmap/map/layer/SwingLayerTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/gmap/map/layer/SwingLayerTest.java new file mode 100644 index 00000000..e52d01b6 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/gmap/map/layer/SwingLayerTest.java @@ -0,0 +1,112 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.portalsdk.analytics.gmap.map.layer; + +import java.awt.Color; +import java.awt.Graphics2D; +import java.awt.geom.AffineTransform; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; + +import javax.servlet.http.HttpServletRequest; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mockito; +import org.onap.portalsdk.analytics.gmap.line.Line; +import org.onap.portalsdk.analytics.gmap.map.ColorProperties; +import org.onap.portalsdk.analytics.gmap.map.NovaMap; +import org.onap.portalsdk.analytics.gmap.node.Node; +import org.onap.portalsdk.analytics.xmlobj.MockitoTestSuite; +import org.springframework.test.util.ReflectionTestUtils; + +public class SwingLayerTest { + + SwingLayer swingLayer; + NovaMap novaMap; + MockitoTestSuite mockitoTestSuite = new MockitoTestSuite(); + HttpServletRequest mockedRequest = mockitoTestSuite.getMockedRequest(); + Graphics2D g2d; + Graphics2D g2Legend; + + @Before + public void init() { + novaMap = new NovaMap(); + swingLayer = new SwingLayer(novaMap); + novaMap.setBoundingBox(10, 10); + novaMap.setNode(new Node(novaMap)); + novaMap.setLine(new Line(novaMap)); + novaMap.setColorProperties(new ColorProperties(novaMap)); + novaMap.setZoomLevel(10); + novaMap.addShowList("test-1"); + novaMap.addShowList("test-2", 10); + novaMap.addSwingLayer(swingLayer); + novaMap.setCurrentYearMonth("2018/05"); + novaMap.setDefaultBoundary(new Rectangle2D.Double()); + novaMap.setShowLegend(true); + ReflectionTestUtils.setField(novaMap, "transform", new AffineTransform()); + Node nodeObj = new Node(new NovaMap()); + nodeObj.addNode(13.13d, 10.10d, "nodeType", "nodeID", "type=domestic|year=2016", 13, true, true); + nodeObj.addNode(13.14d, 10.11d, "nodeType", "nodeID", "type=international|year=2017", 13, true, true); + nodeObj.addNode(13.15d, 10.12d, "nodeType", "nodeID", "type=local|year=2018", 13, true, true); + novaMap.setNode(nodeObj); + swingLayer = new SwingLayer(novaMap); + BufferedImage image = new BufferedImage(novaMap.getBoundingBox().width, novaMap.getBoundingBox().height, BufferedImage.TYPE_INT_ARGB); + g2d = image.createGraphics(); + BufferedImage legendImage = new BufferedImage(novaMap.getBoundingBox().width, (int) (20 * novaMap.getShowListSize()) + 20, + BufferedImage.TYPE_INT_ARGB); + g2Legend = legendImage.createGraphics(); + g2Legend.setBackground(Color.WHITE); + } + + @Test + public void teestPaintLayer_WhenID1NotEqualToID2() { + Mockito.when(mockedRequest.getAttribute("server_process_id")).thenReturn("1"); + Mockito.when(mockedRequest.getSession().getAttribute("server_process_id")).thenReturn("2"); + swingLayer.paintLayer(mockedRequest, g2d, novaMap.getBoundingBox(), new Rectangle2D.Double(), g2Legend); + } + + @Test + public void teestPaintLayer_WhenID1EqualToID2() { + Mockito.when(mockedRequest.getAttribute("server_process_id")).thenReturn("1"); + Mockito.when(mockedRequest.getSession().getAttribute("server_process_id")).thenReturn("1"); + Rectangle2D rd = new Rectangle2D.Double(); + rd.setFrame(14064d, 12366d, 10d, 10d); + swingLayer.paintLayer(mockedRequest, g2d, novaMap.getBoundingBox(), rd, g2Legend); + } +} -- cgit 1.2.3-korg