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