X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=ecomp-portal-BE-common%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Fportalapp%2Fportal%2Fcontroller%2FWebAnalyticsExtAppControllerTest.java;h=caf3ac420664a47f1c9ba8c861fcb53c321c165b;hb=3f56b9fdb4d2ec891344d6c9048363e1cac587d2;hp=b65c442d19b20937ec8bd52217a17e6e5b0fbb3e;hpb=21a8761f684745bb300e075c7e98ad897ace9eed;p=portal.git diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/WebAnalyticsExtAppControllerTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/WebAnalyticsExtAppControllerTest.java index b65c442d..caf3ac42 100644 --- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/WebAnalyticsExtAppControllerTest.java +++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/WebAnalyticsExtAppControllerTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START========================================== * ONAP Portal * =================================================================== - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. * =================================================================== * * Unless otherwise specified, all software contained herein is licensed @@ -33,7 +33,7 @@ * * ============LICENSE_END============================================ * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * */ package org.onap.portalapp.portal.controller; @@ -87,6 +87,9 @@ public class WebAnalyticsExtAppControllerTest { @Mock AuditService auditService = new AuditServiceImpl(); + @Mock + Analytics analytics; + // @Mock // InputStream analyticsFileStream; @@ -143,5 +146,29 @@ public class WebAnalyticsExtAppControllerTest { assertTrue(expectedPortalAPIResponse.getMessage().equals(actualPortalAPIResponse.getMessage())); assertTrue(expectedPortalAPIResponse.getStatus().equals(actualPortalAPIResponse.getStatus())); } + + @Test + public void storeAnalyticsScriptIfAnalyticsTest() throws Exception + { + PortalAPIResponse expectedPortalAPIResponse = new PortalAPIResponse(true, "ok"); + expectedPortalAPIResponse.setMessage("success"); + EPApp appRecord =new EPApp(); + appRecord.setName("test"); + Mockito.when(mockedRequest.getHeader("uebkey")).thenReturn("test"); + Mockito.when(analytics.getUserid()).thenReturn("test"); + Mockito.when(analytics.getFunction()).thenReturn("test"); + PortalAPIResponse actualPortalAPIResponse = webAnalyticsExtAppController.storeAnalyticsScript(mockedRequest, analytics); + assertTrue(expectedPortalAPIResponse.getMessage().equals(actualPortalAPIResponse.getMessage())); + assertTrue(expectedPortalAPIResponse.getStatus().equals(actualPortalAPIResponse.getStatus())); + } + + + @Test(expected = NullPointerException.class) + public void testGetAnalyticsScript() { + PowerMockito.mockStatic(SystemProperties.class); + Mockito.when(SystemProperties.getProperty("frontend_url")).thenReturn("http://www.ecomp.com/test"); + webAnalyticsExtAppController.getAnalyticsScript(mockedRequest); + + } }