aboutsummaryrefslogtreecommitdiffstats
path: root/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/service/MetricServiceTest.java
diff options
context:
space:
mode:
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());
+ }
}