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=e5ee9d92eb64830970dfb4d64abd6e7856a59a4c;hb=aa9b320ff93511280cf51b03d38fb9254af6b530;hp=c59036f514e87864126ac279168bf3ebc8730169;hpb=fe3a67c11b65d7989a6ef648c3f34eee8abe7394;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 c59036f5..e5ee9d92 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 @@ -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 + public void testGetAnalyticsScript()throws Exception { + PowerMockito.mockStatic(SystemProperties.class); + Mockito.when(SystemProperties.getProperty("frontend_url")).thenReturn("http://www.ecomp.com/test"); + webAnalyticsExtAppController.getAnalyticsScript(mockedRequest); + + } }