Reformat PolicyEngineAPI test cases
[policy/engine.git] / PolicyEngineAPI / src / test / java / org / onap / policy / test / PolicyEngineInterfaceTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * PolicyEngineAPI
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Modifications Copyright (C) 2019 Samsung
8  * ================================================================================
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  * ============LICENSE_END=========================================================
21  */
22
23 package org.onap.policy.test;
24
25 import java.io.StringReader;
26 import java.net.HttpURLConnection;
27 import java.util.Collection;
28 import java.util.HashMap;
29 import java.util.Map;
30 import java.util.UUID;
31 import javax.json.Json;
32 import javax.json.JsonObject;
33 import javax.json.JsonReader;
34 import org.mockito.Mockito;
35 import org.onap.policy.api.AttributeType;
36 import org.onap.policy.api.ConfigRequestParameters;
37 import org.onap.policy.api.DecisionRequestParameters;
38 import org.onap.policy.api.DecisionResponse;
39 import org.onap.policy.api.DeletePolicyCondition;
40 import org.onap.policy.api.DeletePolicyParameters;
41 import org.onap.policy.api.EventRequestParameters;
42 import org.onap.policy.api.ImportParameters;
43 import org.onap.policy.api.ImportParameters.IMPORT_TYPE;
44 import org.onap.policy.api.NotificationHandler;
45 import org.onap.policy.api.NotificationScheme;
46 import org.onap.policy.api.PDPNotification;
47 import org.onap.policy.api.PolicyChangeResponse;
48 import org.onap.policy.api.PolicyClass;
49 import org.onap.policy.api.PolicyConfig;
50 import org.onap.policy.api.PolicyConfigException;
51 import org.onap.policy.api.PolicyDecisionException;
52 import org.onap.policy.api.PolicyEngine;
53 import org.onap.policy.api.PolicyEngineException;
54 import org.onap.policy.api.PolicyEventException;
55 import org.onap.policy.api.PolicyParameters;
56 import org.onap.policy.api.PolicyResponse;
57 import org.onap.policy.api.PushPolicyParameters;
58 import org.onap.policy.common.logging.flexlogger.FlexLogger;
59 import org.onap.policy.common.logging.flexlogger.Logger;
60 import org.onap.policy.std.StdPDPNotification;
61 import org.onap.policy.std.StdPolicyChangeResponse;
62 import org.onap.policy.std.StdPolicyResponse;
63 import junit.framework.TestCase;
64
65 /**
66  * The class <code>PolicyEngineInterfaceTest</code> contains tests for the class
67  * {@link <code>PolicyEngine</code>}
68  *
69  * @pattern JUnit Test Case
70  *
71  * @generatedBy CodePro at 5/27/16 10:33 AM
72  *
73  *
74  * @version $Revision$
75  */
76 public class PolicyEngineInterfaceTest extends TestCase {
77
78     private static final Logger logger = FlexLogger.getLogger(PolicyEngineInterfaceTest.class);
79
80     private PolicyEngine policyEngine = null;
81     private PolicyEngine mockPolicyEngine = null;
82     private Collection<PolicyConfig> policyConfig = null;
83     private UUID requestID = UUID.randomUUID();
84
85
86     PolicyChangeResponse result = null;
87     StdPolicyChangeResponse response = new StdPolicyChangeResponse();
88
89
90     /**
91      * Construct new test instance
92      *
93      * @param name the test name
94      */
95     public PolicyEngineInterfaceTest(String name) {
96         super(name);
97     }
98
99     /**
100      * Perform pre-test initialization
101      *
102      * @throws Exception
103      *
104      * @see TestCase#setUp()
105      */
106     public void setUp() throws Exception {
107         try {
108             policyEngine = new PolicyEngine("Test/config_pass.properties");
109         } catch (PolicyEngineException e) {
110             logger.error(e.getMessage());
111             fail("PolicyEngine Instantiation Error" + e);
112         }
113         logger.info("Loaded.. PolicyEngine");
114
115         mockPolicyEngine = Mockito.mock(PolicyEngine.class);
116         HttpURLConnection conn = Mockito.mock(HttpURLConnection.class);
117         Mockito.when(conn.getResponseCode()).thenReturn(HttpURLConnection.HTTP_OK);
118
119     }
120
121     /**
122      * Perform post-test clean up
123      *
124      * @throws Exception
125      *
126      * @see TestCase#tearDown()
127      */
128     public void tearDown() throws Exception {
129         super.tearDown();
130         // Add additional tear down code here
131     }
132
133     /**
134      * Run the Collection<PolicyConfig> getConfigByPolicyName(String) method test
135      */
136     @SuppressWarnings("deprecation")
137     public void testGetConfigByPolicyName() {
138         String policyName = null;
139         try {
140             policyConfig = policyEngine.getConfigByPolicyName(policyName);
141         } catch (PolicyConfigException e) {
142             logger.warn(e.getMessage());
143         }
144         assertNull(policyConfig);
145     }
146
147     @SuppressWarnings("deprecation")
148     public void testGetConfigByPolicyName2() {
149         String policyName = null;
150
151         try {
152             policyConfig = policyEngine.getConfigByPolicyName(policyName, requestID);
153         } catch (PolicyConfigException e) {
154             logger.warn(e.getMessage());
155         }
156         assertNull(policyConfig);
157     }
158
159     /**
160      * Run the Collection<PolicyConfig> getConfig(String) method test
161      */
162     @SuppressWarnings("deprecation")
163     public void testGetConfig() {
164         String onapName = null;
165
166         try {
167             policyConfig = policyEngine.getConfig(onapName);
168         } catch (PolicyConfigException e) {
169             logger.warn(e.getMessage());
170         }
171         assertNull(policyConfig);
172     }
173
174     @SuppressWarnings("deprecation")
175     public void testGetConfig2() {
176         String onapName = null;
177
178         try {
179             policyConfig = policyEngine.getConfig(onapName, requestID);
180         } catch (PolicyConfigException e) {
181             logger.warn(e.getMessage());
182         }
183         assertNull(policyConfig);
184     }
185
186
187     @SuppressWarnings("deprecation")
188     public void testGetConfig3() {
189         String onapName = null;
190         String configName = null;
191
192         try {
193             policyConfig = policyEngine.getConfig(onapName, configName, requestID);
194         } catch (PolicyConfigException e) {
195             logger.warn(e.getMessage());
196         }
197         assertNull(policyConfig);
198     }
199
200     @SuppressWarnings("deprecation")
201     public void testGetConfig4() {
202         String onapName = null;
203         String configName = null;
204         Map<String, String> configAttributes = null;
205
206         try {
207             policyConfig = policyEngine.getConfig(onapName, configName, configAttributes);
208         } catch (PolicyConfigException e) {
209             logger.warn(e.getMessage());
210         }
211         assertNull(policyConfig);
212     }
213
214     @SuppressWarnings("deprecation")
215     public void testGetConfig5() {
216         String onapName = null;
217         String configName = null;
218         Map<String, String> configAttributes = null;
219
220         try {
221             policyConfig =
222                     policyEngine.getConfig(onapName, configName, configAttributes, requestID);
223         } catch (PolicyConfigException e) {
224             logger.warn(e.getMessage());
225         }
226         assertNull(policyConfig);
227     }
228
229     public void testGetConfig6() {
230         ConfigRequestParameters parameters = new ConfigRequestParameters();
231
232         try {
233             policyConfig = policyEngine.getConfig(parameters);
234         } catch (PolicyConfigException e) {
235             logger.warn(e.getMessage());
236         }
237         assertNull(policyConfig);
238     }
239
240
241     /**
242      * Run the Collection<PolicyResponse> sendEvent(Map<String,String>) method test
243      */
244     @SuppressWarnings("deprecation")
245     public void testSendEvent() {
246         Collection<PolicyResponse> result = null;
247         Collection<StdPolicyResponse> response = null;
248         Map<String, String> eventAttributes = null;
249
250         try {
251             Mockito.when(mockPolicyEngine.sendEvent(eventAttributes)).thenReturn(result);
252             result = mockPolicyEngine.sendEvent(eventAttributes);
253         } catch (PolicyEventException e) {
254             logger.error("Exception Occured" + e);
255         }
256
257
258         assertEquals(result, response);
259
260     }
261
262     @SuppressWarnings("deprecation")
263     public void testSendEvent2() {
264         Collection<PolicyResponse> result = null;
265         Collection<StdPolicyResponse> response = null;
266         Map<String, String> eventAttributes = null;
267
268         try {
269             Mockito.when(mockPolicyEngine.sendEvent(eventAttributes, requestID)).thenReturn(result);
270             result = mockPolicyEngine.sendEvent(eventAttributes, requestID);
271         } catch (PolicyEventException e) {
272             logger.error("Exception Occured" + e);
273         }
274
275
276         assertEquals(result, response);
277
278     }
279
280     public void testSendEvent3() {
281         Collection<PolicyResponse> result = null;
282         Collection<StdPolicyResponse> response = null;
283         EventRequestParameters parameters = new EventRequestParameters();
284
285         try {
286             Mockito.when(mockPolicyEngine.sendEvent(parameters)).thenReturn(result);
287             result = mockPolicyEngine.sendEvent(parameters);
288         } catch (PolicyEventException e) {
289             logger.error("Exception Occured" + e);
290         }
291
292         assertEquals(result, response);
293
294     }
295
296
297
298     /**
299      * Run the PolicyDecision getDecision(String, Map<String,String>) method test
300      */
301     @SuppressWarnings("deprecation")
302     public void testGetDecision() {
303         String onapComponentName = null;
304         Map<String, String> decisionAttributes = null;
305
306         DecisionResponse result = null;
307
308         try {
309             Mockito.when(mockPolicyEngine.getDecision(onapComponentName, decisionAttributes))
310                     .thenReturn(null);
311             result = mockPolicyEngine.getDecision(onapComponentName, decisionAttributes);
312         } catch (PolicyDecisionException e) {
313             logger.error("Exception Occured" + e);
314         }
315
316         assertEquals(result, null);
317     }
318
319     @SuppressWarnings("deprecation")
320     public void testGetDecision2() {
321         String onapComponentName = null;
322         Map<String, String> decisionAttributes = null;
323
324         DecisionResponse result = null;
325
326         try {
327             Mockito.when(
328                     mockPolicyEngine.getDecision(onapComponentName, decisionAttributes, requestID))
329                     .thenReturn(null);
330             result = mockPolicyEngine.getDecision(onapComponentName, decisionAttributes);
331         } catch (PolicyDecisionException e) {
332             logger.error("Exception Occured" + e);
333         }
334
335         assertEquals(result, null);
336     }
337
338     public void testGetDecision3() {
339         DecisionRequestParameters parameters = new DecisionRequestParameters();
340         DecisionResponse result = null;
341
342         try {
343             Mockito.when(mockPolicyEngine.getDecision(parameters)).thenReturn(null);
344             result = mockPolicyEngine.getDecision(parameters);
345         } catch (PolicyDecisionException e) {
346             logger.error("Exception Occured" + e);
347         }
348
349         assertEquals(result, null);
350     }
351
352     /**
353      * Run the void setNotification(NotificationScheme, NotificationHandler) method test
354      */
355     public void testSetNotification() {
356         // add test code here
357
358         NotificationScheme scheme = null;
359         NotificationHandler handler = null;
360
361         Mockito.doNothing().when(mockPolicyEngine).setNotification(scheme, handler);
362         mockPolicyEngine.setNotification(scheme, handler);
363         // assertTrue(true);
364     }
365
366     /**
367      * Run the void clearNotification() method test
368      */
369     public void testClearNotification() {
370         // add test code here
371
372         Mockito.doNothing().when(mockPolicyEngine).clearNotification();
373         mockPolicyEngine.clearNotification();
374         // assertTrue(true);
375     }
376
377     /**
378      * Run the void setScheme(NotificationScheme) method test
379      */
380     public void testSetScheme() {
381         NotificationScheme scheme = null;
382
383         Mockito.doNothing().when(mockPolicyEngine).setScheme(scheme);
384         mockPolicyEngine.setScheme(scheme);
385         // assertTrue(true);
386     }
387
388     /**
389      * Run the PDPNotification getNotification() method test
390      */
391     public void testGetNotification() {
392         PDPNotification result = null;
393         StdPDPNotification response = null;
394         Mockito.when(mockPolicyEngine.getNotification()).thenReturn(response);
395         result = mockPolicyEngine.getNotification();
396
397         assertEquals(result, response);
398     }
399
400     /**
401      * Run the String createConfigPolicy(String, String, String, String, Map<String,String>, String,
402      * String, String, UUID) method test
403      */
404     @SuppressWarnings("deprecation")
405     public void testCreateConfigPolicy() {
406         String response = "success";
407         String result = null;
408         try {
409
410             Mockito.when(mockPolicyEngine.createConfigPolicy("testPolicy", "test", "test",
411                     "testConfig", null, "OTHER", "test", "test", null, null, null, null, null))
412                     .thenReturn(response);
413             result = mockPolicyEngine.createConfigPolicy("testPolicy", "test", "test", "testConfig",
414                     null, "OTHER", "test", "test", null, null, null, null, null);
415
416         } catch (Exception e) {
417             logger.warn(e.getMessage());
418         }
419         assertEquals(result, response);
420     }
421
422     /**
423      * Run the String updateConfigPolicy(String, String, String, String, Map<String,String>, String,
424      * String, String, UUID) method test
425      */
426     @SuppressWarnings("deprecation")
427     public void testUpdateConfigPolicy() {
428         String response = "success";
429         String result = null;
430         try {
431
432             Mockito.when(mockPolicyEngine.updateConfigPolicy("testPolicy", "test", "test",
433                     "testConfig", null, "OTHER", "test", "test", null, null, null, null, null))
434                     .thenReturn(response);
435             result = mockPolicyEngine.updateConfigPolicy("testPolicy", "test", "test", "testConfig",
436                     null, "OTHER", "test", "test", null, null, null, null, null);
437
438         } catch (Exception e) {
439             logger.warn(e.getMessage());
440         }
441         assertEquals(result, response);
442     }
443
444     /**
445      * Run the String createConfigFirewallPolicy(String, JsonObject, String, UUID) method test
446      */
447     @SuppressWarnings("deprecation")
448     public void testCreateConfigFirewallPolicy() {
449         String response = "success";
450         String result = null;
451         String json =
452                 "{\"serviceTypeId\":\"/v0/firewall/pan\",\"configName\":\"rule1607\",\"deploymentOption\":"
453                         + "{\"deployNow\":false},\"securityZoneId\":\"/v0/firewall/pan\",\"serviceGroups\":"
454                         + "[{\"name\":\"1607Group\",\"description\":null,\"members\":[{\"type\":\"REFERENCE\","
455                         + "\"name\":\"SList\"},{\"type\":\"REFERENCE\",\"name\":\"Syslog\"}]},{\"name\":\"Syslog\","
456                         + "\"description\":\"NA\",\"type\":\"SERVICE\",\"transportProtocol\":\"udp\","
457                         + "\"appProtocol\":null,\"ports\":\"514\"},{\"name\":\"SList\","
458                         + "\"description\":\"Service List\",\"type\":\"SERVICE\",\"transportProtocol\":\"tcp\","
459                         + "\"appProtocol\":null,\"ports\":\"8080\"}],\"addressGroups\":[{\"name\":\"1607Group\","
460                         + "\"description\":null,\"members\":[{\"type\":\"SUBNET\",\"value\":\"10.11.12.13/14\"},"
461                         + "{\"type\":\"SUBNET\",\"value\":\"10.11.12.13/14\"}]},{\"name\":\"PL_CCE3\","
462                         + "\"description\":\"CCE Routers\",\"members\":[{\"type\":\"SUBNET\","
463                         + "\"value\":\"10.11.12.13/14\"}]}],\"firewallRuleList\":[{\"position\":\"1\","
464                         + "\"ruleName\":\"1607Rule\",\"fromZones\":[\"Trusted\"],\"toZones\":[\"Untrusted\"],"
465                         + "\"negateSource\":false,\"negateDestination\":false,\"sourceList\":[{\"type\":\"REFERENCE\","
466                         + "\"value\":\"PL_CCE3\"},{\"type\":\"REFERENCE\",\"value\":\"1607Group\"}],"
467                         + "\"destinationList\":[{\"type\":\"REFERENCE\",\"value\":\"1607Group\"}],"
468                         + "\"sourceServices\":[],\"destServices\":[{\"type\":\"REFERENCE\",\"name\":\"1607Group\"}],"
469                         + "\"action\":\"accept\",\"description\":\"Rule for 1607 templates\",\"enabled\":true,"
470                         + "\"log\":true}]}";
471         JsonObject jsonObj = buildJSON(json);
472         try {
473
474             Mockito.when(mockPolicyEngine.createConfigFirewallPolicy("testPolicy", jsonObj, "test",
475                     null, null, null, null, null)).thenReturn(response);
476             result = mockPolicyEngine.createConfigFirewallPolicy("testPolicy", jsonObj, "test",
477                     null, null, null, null, null);
478
479         } catch (Exception e) {
480             logger.warn(e.getMessage());
481         }
482         assertEquals(result, response);
483     }
484
485     /**
486      * Run the String updateConfigFirewallPolicy(String, JsonObject, String, UUID) method test
487      */
488     @SuppressWarnings("deprecation")
489     public void testUpdateConfigFirewallPolicy() {
490         String response = "success";
491         String result = null;
492         String json =
493                 "{\"serviceTypeId\":\"/v0/firewall/pan\",\"configName\":\"rule1607\",\"deploymentOption\":"
494                         + "{\"deployNow\":false},\"securityZoneId\":\"/v0/firewall/pan\",\"serviceGroups\":"
495                         + "[{\"name\":\"1607Group\",\"description\":null,\"members\":[{\"type\":\"REFERENCE\","
496                         + "\"name\":\"SList\"},{\"type\":\"REFERENCE\",\"name\":\"Syslog\"}]},{\"name\":\"Syslog\","
497                         + "\"description\":\"NA\",\"type\":\"SERVICE\",\"transportProtocol\":\"udp\","
498                         + "\"appProtocol\":null,\"ports\":\"514\"},{\"name\":\"SList\","
499                         + "\"description\":\"Service List\",\"type\":\"SERVICE\",\"transportProtocol\":\"tcp\","
500                         + "\"appProtocol\":null,\"ports\":\"8080\"}],\"addressGroups\":[{\"name\":\"1607Group\","
501                         + "\"description\":null,\"members\":[{\"type\":\"SUBNET\",\"value\":\"10.11.12.13/14\"},"
502                         + "{\"type\":\"SUBNET\",\"value\":\"10.11.12.13/14\"}]},{\"name\":\"PL_CCE3\","
503                         + "\"description\":\"CCE Routers\",\"members\":[{\"type\":\"SUBNET\","
504                         + "\"value\":\"10.11.12.13/14\"}]}],\"firewallRuleList\":[{\"position\":\"1\","
505                         + "\"ruleName\":\"1607Rule\",\"fromZones\":[\"Trusted\"],\"toZones\":[\"Untrusted\"],"
506                         + "\"negateSource\":false,\"negateDestination\":false,\"sourceList\":[{\"type\":\"REFERENCE\","
507                         + "\"value\":\"PL_CCE3\"},{\"type\":\"REFERENCE\",\"value\":\"1607Group\"}],"
508                         + "\"destinationList\":[{\"type\":\"REFERENCE\",\"value\":\"1607Group\"}],"
509                         + "\"sourceServices\":[],\"destServices\":[{\"type\":\"REFERENCE\",\"name\":\"1607Group\"}],"
510                         + "\"action\":\"accept\",\"description\":\"Rule for 1607 templates\",\"enabled\":true,"
511                         + "\"log\":true}]}";
512         JsonObject jsonObj = buildJSON(json);
513         try {
514
515             Mockito.when(mockPolicyEngine.updateConfigFirewallPolicy("testPolicy", jsonObj, "test",
516                     null, null, null, null, null)).thenReturn(response);
517             result = mockPolicyEngine.updateConfigFirewallPolicy("testPolicy", jsonObj, "test",
518                     null, null, null, null, null);
519
520         } catch (Exception e) {
521             logger.warn(e.getMessage());
522         }
523         assertEquals(result, response);
524     }
525
526     /**
527      * Run the PolicyChangeResponse createPolicy(PolicyParameters) method test
528      */
529     public void testCreatePolicy() {
530         response.setResponseMessage("success");
531         PolicyChangeResponse result = null;
532         PolicyParameters policyParameters = new PolicyParameters();
533
534         policyParameters.setPolicyClass(PolicyClass.Action); // required
535         policyParameters.setPolicyName("test.junitTest"); // required
536         policyParameters.setPolicyDescription("testing"); // optional
537
538         // Set the Component Attributes... These are Optional
539         Map<String, String> configAttributes = new HashMap<String, String>();
540         configAttributes.put("test", "testing");
541
542         Map<AttributeType, Map<String, String>> attributes =
543                 new HashMap<AttributeType, Map<String, String>>();
544         attributes.put(AttributeType.MATCHING, configAttributes);
545         policyParameters.setAttributes(attributes);
546
547         policyParameters.setActionPerformer("PEP");
548         policyParameters.setActionAttribute("testing");
549         policyParameters.setRequestID(UUID.randomUUID());
550
551         try {
552
553             // stdPolicyEngine = Mockito.mock(StdPolicyEngine.class);
554             // Mockito.when(stdPolicyEngine.callPAP(newPAPPolicy, new String[] {"operation=create",
555             // "apiflag=api", "policyType=Action"}, null, "Action")).thenReturn(callPapResponse);
556             Mockito.when(mockPolicyEngine.createPolicy(policyParameters)).thenReturn(response);
557             result = mockPolicyEngine.createPolicy(policyParameters);
558
559         } catch (Exception e) {
560             logger.warn(e.getMessage());
561             logger.error("Exception Occured" + e);
562         }
563         assertEquals(result, response);
564     }
565
566     /**
567      * Run the PolicyChangeResponse updatePolicy(PolicyParameters) method test
568      */
569     public void testUpdatePolicy() {
570         response.setResponseMessage("success");
571         PolicyChangeResponse result = null;
572         PolicyParameters policyParameters = new PolicyParameters();
573
574         policyParameters.setPolicyClass(PolicyClass.Action); // required
575         policyParameters.setPolicyName("test.junitTest"); // required
576         policyParameters.setPolicyDescription("testing"); // optional
577
578         // Set the Component Attributes... These are Optional
579         Map<String, String> configAttributes = new HashMap<String, String>();
580         configAttributes.put("test", "testing");
581
582         Map<AttributeType, Map<String, String>> attributes =
583                 new HashMap<AttributeType, Map<String, String>>();
584         attributes.put(AttributeType.MATCHING, configAttributes);
585         policyParameters.setAttributes(attributes);
586
587         policyParameters.setActionPerformer("PEP");
588         policyParameters.setActionAttribute("testing");
589         policyParameters.setRequestID(UUID.randomUUID());
590
591         try {
592
593             Mockito.when(mockPolicyEngine.updatePolicy(policyParameters)).thenReturn(response);
594             result = mockPolicyEngine.updatePolicy(policyParameters);
595
596         } catch (Exception e) {
597             logger.warn(e.getMessage());
598         }
599         assertEquals(result, response);
600     }
601
602     /**
603      * Run the String pushPolicy(String, String, String, String, UUID) method test
604      */
605     @SuppressWarnings("deprecation")
606     public void testPushPolicy() {
607         String response = "Success";
608         String result = null;
609         try {
610
611             Mockito.when(
612                     mockPolicyEngine.pushPolicy("testing", "test", "Base", "default", requestID))
613                     .thenReturn(response);
614             result = mockPolicyEngine.pushPolicy("testing", "test", "Base", "default", requestID);
615
616         } catch (Exception e) {
617             logger.warn(e.getMessage());
618         }
619
620         assertEquals(result, response);
621     }
622
623     public void testPushPolicy2() {
624         PushPolicyParameters policyParameters = new PushPolicyParameters();
625         PolicyChangeResponse result = null;
626
627         // String policyScope = null;
628         policyParameters.setPolicyName("test.junitTest");
629         policyParameters.setPolicyType("Action");
630         policyParameters.setPdpGroup("Default");
631
632         try {
633
634             Mockito.when(mockPolicyEngine.pushPolicy(policyParameters)).thenReturn(response);
635             result = mockPolicyEngine.pushPolicy(policyParameters);
636
637         } catch (Exception e) {
638             logger.warn(e.getMessage());
639         }
640
641         assertEquals(result, response);
642     }
643
644     /**
645      * Run the PolicyChangeResponse deletePolicy(DeletePolicyParameters) method test
646      */
647     public void testDeletePolicy() {
648         DeletePolicyParameters policyParameters = new DeletePolicyParameters();
649         PolicyChangeResponse result = null;
650
651         // String policyScope = null;
652         policyParameters.setPolicyName("test.junitTest.1.xml");
653         policyParameters.setDeleteCondition(DeletePolicyCondition.ALL);
654         policyParameters.setPolicyComponent("PAP");
655         policyParameters.setPdpGroup("Default");
656
657         try {
658
659             Mockito.when(mockPolicyEngine.deletePolicy(policyParameters)).thenReturn(response);
660             result = mockPolicyEngine.deletePolicy(policyParameters);
661
662         } catch (Exception e) {
663             logger.warn(e.getMessage());
664         }
665
666         assertEquals(result, response);
667     }
668
669     /**
670      * Run the PolicyChangeResponse policyEngineImport(ImportParameters) method test
671      */
672     public void testPolicyEngineImport() {
673         ImportParameters importParameters = new ImportParameters();
674         PolicyChangeResponse result = null;
675
676         importParameters.setFilePath(
677                 "C:\\Workspaces\\models\\TestingModel\\ControllerServiceSampleSdnlServiceInstance-v0.1.0-SNAPSHOT.zip");
678         importParameters.setServiceName("ControllerServiceSampleSdnlServiceInstance");
679
680         importParameters.setRequestID(UUID.randomUUID());
681         importParameters.setServiceType(IMPORT_TYPE.MICROSERVICE);
682         importParameters.setVersion("1607-2");
683
684         try {
685
686             Mockito.when(mockPolicyEngine.policyEngineImport(importParameters))
687                     .thenReturn(response);
688             result = mockPolicyEngine.policyEngineImport(importParameters);
689
690         } catch (Exception e) {
691             logger.warn(e.getMessage());
692         }
693
694         assertEquals(result, response);
695     }
696
697     private static JsonObject buildJSON(String jsonString) {
698         JsonObject json = null;;
699         if (jsonString != null) {
700             StringReader in = null;
701
702             in = new StringReader(jsonString);
703
704             JsonReader jsonReader = Json.createReader(in);
705             json = jsonReader.readObject();
706         }
707         return json;
708     }
709 }