aboutsummaryrefslogtreecommitdiffstats
path: root/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/service/MetricServiceTest.java
diff options
context:
space:
mode:
authorbobbymander <bobby.mander@att.com>2019-11-15 13:59:18 -0500
committerbobbymander <bobby.mander@att.com>2019-11-15 13:59:30 -0500
commit0154925df97446afa15ab60d59c57237dfa7b2e9 (patch)
treecfdd6158de747a7a6b1089aba12d3b679474b397 /ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/service/MetricServiceTest.java
parentb536883546b9fa87bce50c7a6d030f6de3aafdce (diff)
More JUnit additions for PAP-REST
Issue-ID: POLICY-2130 Change-Id: Ia111e5fd6dfba1e03f157ff95f91ef65df293043 Signed-off-by: bobbymander <bobby.mander@att.com>
Diffstat (limited to 'ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/service/MetricServiceTest.java')
-rw-r--r--ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/service/MetricServiceTest.java21
1 files changed, 19 insertions, 2 deletions
diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/service/MetricServiceTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/service/MetricServiceTest.java
index a4ee0ca77..ebd3292aa 100644
--- a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/service/MetricServiceTest.java
+++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/service/MetricServiceTest.java
@@ -21,15 +21,19 @@
package org.onap.policy.pap.xacml.rest.service;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import static org.mockito.Mockito.when;
import com.mockrunner.mock.web.MockHttpServletResponse;
-
+import java.util.ArrayList;
+import java.util.List;
import javax.servlet.http.HttpServletResponse;
-
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.Mockito;
import org.onap.policy.pap.xacml.rest.XACMLPapServlet;
+import org.onap.policy.rest.dao.CommonClassDao;
+import org.onap.policy.rest.jpa.PolicyVersion;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
@@ -47,4 +51,17 @@ public class MetricServiceTest {
MetricService.doGetPolicyMetrics(response);
assertEquals(HttpServletResponse.SC_BAD_REQUEST, response.getStatusCode());
}
+
+ @Test
+ public void testService() {
+ CommonClassDao dao = Mockito.mock(CommonClassDao.class);
+ List<Object> value = new ArrayList<Object>();
+ when(dao.getData(PolicyVersion.class)).thenReturn(value);
+ MetricService service = new MetricService(dao);
+ assertNotNull(service);
+
+ MockHttpServletResponse response = new MockHttpServletResponse();
+ MetricService.doGetPolicyMetrics(response);
+ assertEquals(HttpServletResponse.SC_BAD_REQUEST, response.getStatusCode());
+ }
}