Add JUnit tests policy/engine PolicyEngineAPI
[policy/engine.git] / PolicyEngineAPI / src / test / java / org / onap / policy / std / StdPolicyEngineTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * PolicyEngineAPI
4  * ================================================================================
5  * Copyright (C) 2018 Ericsson. 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.onap.policy.std;
22
23 import static org.junit.Assert.assertEquals;
24 import static org.junit.Assert.assertNotNull;
25 import static org.mockito.ArgumentMatchers.any;
26 import static org.mockito.ArgumentMatchers.eq;
27 import static org.mockito.Mockito.doReturn;
28 import static org.mockito.Mockito.doThrow;
29 import static org.mockito.Mockito.spy;
30 import static org.onap.policy.std.utils.PolicyCommonConfigConstants.CONFIG_NAME;
31 import static org.onap.policy.std.utils.PolicyCommonConfigConstants.ONAP_NAME;
32 import static org.onap.policy.std.utils.PolicyConfigConstants.CLIENT_ID_PROP_NAME;
33 import static org.onap.policy.std.utils.PolicyConfigConstants.CLIENT_KEY_PROP_NAME;
34 import static org.onap.policy.std.utils.PolicyConfigConstants.COMMA;
35 import static org.onap.policy.std.utils.PolicyConfigConstants.CREATE_DICTIONARY_ITEM_RESOURCE_NAME;
36 import static org.onap.policy.std.utils.PolicyConfigConstants.CREATE_POLICY_RESOURCE_NAME;
37 import static org.onap.policy.std.utils.PolicyConfigConstants.DELETE_POLICY_RESOURCE_NAME;
38 import static org.onap.policy.std.utils.PolicyConfigConstants.DMAAP;
39 import static org.onap.policy.std.utils.PolicyConfigConstants.ENVIRONMENT_PROP_NAME;
40 import static org.onap.policy.std.utils.PolicyConfigConstants.GET_CONFIG_RESOURCE_NAME;
41 import static org.onap.policy.std.utils.PolicyConfigConstants.GET_DECISION_RESOURCE_NAME;
42 import static org.onap.policy.std.utils.PolicyConfigConstants.GET_DICTIONARY_ITEMS_RESOURCE_NAME;
43 import static org.onap.policy.std.utils.PolicyConfigConstants.GET_METRICS_RESOURCE_NAME;
44 import static org.onap.policy.std.utils.PolicyConfigConstants.NOTIFICATION_SERVERS_PROP_NAME;
45 import static org.onap.policy.std.utils.PolicyConfigConstants.NOTIFICATION_TOPIC_PROP_NAME;
46 import static org.onap.policy.std.utils.PolicyConfigConstants.NOTIFICATION_TYPE_PROP_NAME;
47 import static org.onap.policy.std.utils.PolicyConfigConstants.PDP_URL_PROP_NAME;
48 import static org.onap.policy.std.utils.PolicyConfigConstants.POLICY_ENGINE_IMPORT_RESOURCE_NAME;
49 import static org.onap.policy.std.utils.PolicyConfigConstants.PUSH_POLICY_RESOURCE_NAME;
50 import static org.onap.policy.std.utils.PolicyConfigConstants.SEND_EVENT_RESOURCE_NAME;
51 import static org.onap.policy.std.utils.PolicyConfigConstants.UEB;
52 import static org.onap.policy.std.utils.PolicyConfigConstants.UPDATE_DICTIONARY_ITEM_RESOURCE_NAME;
53 import static org.onap.policy.std.utils.PolicyConfigConstants.UPDATE_POLICY_RESOURCE_NAME;
54 import java.io.BufferedWriter;
55 import java.io.File;
56 import java.io.IOException;
57 import java.io.StringReader;
58 import java.nio.file.Files;
59 import java.util.Arrays;
60 import java.util.Collection;
61 import java.util.Collections;
62 import java.util.Date;
63 import java.util.HashMap;
64 import java.util.Map;
65 import java.util.Properties;
66 import java.util.UUID;
67 import javax.json.Json;
68 import javax.json.JsonObject;
69 import javax.json.JsonReader;
70 import org.junit.Rule;
71 import org.junit.Test;
72 import org.junit.rules.TemporaryFolder;
73 import org.junit.runner.RunWith;
74 import org.mockito.Mockito;
75 import org.mockito.junit.MockitoJUnitRunner;
76 import org.onap.policy.api.ConfigRequestParameters;
77 import org.onap.policy.api.DecisionRequestParameters;
78 import org.onap.policy.api.DecisionResponse;
79 import org.onap.policy.api.DeletePolicyParameters;
80 import org.onap.policy.api.DictionaryParameters;
81 import org.onap.policy.api.DictionaryResponse;
82 import org.onap.policy.api.EventRequestParameters;
83 import org.onap.policy.api.ImportParameters;
84 import org.onap.policy.api.MetricsRequestParameters;
85 import org.onap.policy.api.MetricsResponse;
86 import org.onap.policy.api.NotificationScheme;
87 import org.onap.policy.api.PolicyChangeResponse;
88 import org.onap.policy.api.PolicyConfig;
89 import org.onap.policy.api.PolicyConfigException;
90 import org.onap.policy.api.PolicyConfigStatus;
91 import org.onap.policy.api.PolicyConfigType;
92 import org.onap.policy.api.PolicyDecision;
93 import org.onap.policy.api.PolicyDecisionException;
94 import org.onap.policy.api.PolicyEngineException;
95 import org.onap.policy.api.PolicyEventException;
96 import org.onap.policy.api.PolicyException;
97 import org.onap.policy.api.PolicyParameters;
98 import org.onap.policy.api.PolicyResponse;
99 import org.onap.policy.api.PolicyResponseStatus;
100 import org.onap.policy.api.PolicyType;
101 import org.onap.policy.api.PushPolicyParameters;
102 import org.onap.policy.models.APIDictionaryResponse;
103 import org.onap.policy.models.APIPolicyConfigResponse;
104 import org.onap.policy.std.utils.PolicyConfigConstants;
105 import org.springframework.http.HttpMethod;
106 import org.springframework.http.HttpStatus;
107 import org.springframework.http.ResponseEntity;
108 import org.springframework.web.client.HttpClientErrorException;
109 import org.springframework.web.client.RestClientException;
110
111 @RunWith(MockitoJUnitRunner.class)
112 public class StdPolicyEngineTest {
113
114     private static final String ONAP_NAME_VAL = "ONAP_NAME";
115     private static final String POLICY_VERSION = "1.0.0";
116     private static final String POLICY_NAME = "ONAP";
117     private static final String COMMENTS = "";
118     private static final UUID REQUEST_UUID = UUID.randomUUID();
119     private static final String SERVER_NAME = "localhost.com";
120     private static final String PDP_PROP_VALUE = "http://localhost:8092/pdp/ , test, test";
121     private static final String PDP_PROP_VALUE_1 = "https://localhost:8091/pdp/ , onap, onap";
122     private static final String JSON_CONFIGURATION = "{\"name\":\"value\"}";
123     private static final String XML_CONFIGURATION =
124             "<map><entry><string>name</string><string>value</string></entry></map>";
125
126     @Rule
127     public TemporaryFolder temporaryFolder = new TemporaryFolder();
128
129     private static final String CONFIG_PROPERTIES_FILE = "config_pass.properties";
130     private static final String INVALID_CONFIG_PROPERTY_FILE = "config_fail.properties";
131
132     @Test
133     public void testStdPolicyEngineInitialize_noException() throws Exception {
134         final File file = temporaryFolder.newFile(CONFIG_PROPERTIES_FILE);
135
136         creatPropertyFile(file, getDefaultProperties());
137
138         final StdPolicyEngine policyEngine = new StdPolicyEngine(file.toString(), (String) null);
139         policyEngine.setScheme(NotificationScheme.MANUAL_NOTIFICATIONS);
140         assertEquals("TEST", StdPolicyEngine.getEnvironment());
141         assertEquals("http://localhost:8092/pdp/", StdPolicyEngine.getPDPURL());
142         assertEquals(Arrays.asList(UEB, DMAAP), policyEngine.getNotificationType());
143         assertEquals(Arrays.asList(SERVER_NAME, SERVER_NAME), policyEngine.getNotificationURLList());
144     }
145
146     @Test
147     public void testStdPolicyEngineInitializeWithSingleServerName_noException() throws Exception {
148         final File file = temporaryFolder.newFile(CONFIG_PROPERTIES_FILE);
149
150         final Properties properties = new Properties();
151         properties.setProperty(PDP_URL_PROP_NAME, PDP_PROP_VALUE);
152         properties.setProperty(CLIENT_ID_PROP_NAME, "test");
153         properties.setProperty(CLIENT_KEY_PROP_NAME, "test");
154         properties.setProperty(NOTIFICATION_TYPE_PROP_NAME, UEB);
155         properties.setProperty(NOTIFICATION_SERVERS_PROP_NAME, SERVER_NAME);
156         properties.setProperty(NOTIFICATION_TOPIC_PROP_NAME, "test");
157         properties.setProperty(ENVIRONMENT_PROP_NAME, "TEST");
158         creatPropertyFile(file, properties);
159
160         final StdPolicyEngine policyEngine = new StdPolicyEngine(file.toString(), (String) null);
161         policyEngine.setScheme(NotificationScheme.MANUAL_NOTIFICATIONS);
162         assertEquals(Arrays.asList(SERVER_NAME), policyEngine.getNotificationURLList());
163     }
164
165     @Test
166     public void testStdPolicyEngineInitializeWithSingleNotificationType_noException() throws Exception {
167         final File file = temporaryFolder.newFile(CONFIG_PROPERTIES_FILE);
168
169         final Properties properties = new Properties();
170         properties.setProperty(PDP_URL_PROP_NAME, PDP_PROP_VALUE);
171         properties.setProperty(CLIENT_ID_PROP_NAME, "test");
172         properties.setProperty(CLIENT_KEY_PROP_NAME, "test");
173         properties.setProperty(NOTIFICATION_TYPE_PROP_NAME, UEB);
174         properties.setProperty(NOTIFICATION_SERVERS_PROP_NAME, SERVER_NAME);
175         properties.setProperty(NOTIFICATION_TOPIC_PROP_NAME, "test");
176         properties.setProperty(ENVIRONMENT_PROP_NAME, "TEST");
177         creatPropertyFile(file, properties);
178
179         final StdPolicyEngine policyEngine = new StdPolicyEngine(file.toString(), (String) null);
180         policyEngine.setScheme(NotificationScheme.MANUAL_NOTIFICATIONS);
181         assertEquals(Arrays.asList(UEB), policyEngine.getNotificationType());
182     }
183
184     @Test(expected = PolicyEngineException.class)
185     public void testStdPolicyEngineInitialize_InvalidPropertyFile_Exception() throws PolicyEngineException {
186         new StdPolicyEngine("Invalid.properties", (String) null);
187     }
188
189     @Test(expected = PolicyEngineException.class)
190     public void testStdPolicyEngineInitialize_InvalidPropertyFileWithExt_Exception() throws Exception {
191         final File emptyFile = temporaryFolder.newFile("EmptyFile.txt");
192         new StdPolicyEngine(emptyFile.toString(), (String) null);
193     }
194
195     @Test(expected = PolicyEngineException.class)
196     public void testStdPolicyEngineInitialize_NullArguments_Exception() throws Exception {
197         new StdPolicyEngine(null, (String) null);
198     }
199
200     @Test(expected = PolicyEngineException.class)
201     public void testStdPolicyEngineInitialize_PropertyFileMissingMandatoryProperties_Exception() throws Exception {
202         final File file = temporaryFolder.newFile(INVALID_CONFIG_PROPERTY_FILE);
203         final Properties properties = new Properties();
204         properties.setProperty(PDP_URL_PROP_NAME, PDP_PROP_VALUE);
205         creatPropertyFile(file, properties);
206
207         new StdPolicyEngine(file.toString(), (String) null);
208     }
209
210     @Test
211     public void testStdPolicyEngineInitialize_MultiplePdp_noException() throws Exception {
212         final File file = temporaryFolder.newFile(CONFIG_PROPERTIES_FILE);
213
214         final Properties properties = new Properties();
215         properties.setProperty(PDP_URL_PROP_NAME, PDP_PROP_VALUE + PolicyConfigConstants.SEMICOLLON + PDP_PROP_VALUE_1);
216         properties.setProperty(CLIENT_ID_PROP_NAME, "test");
217         properties.setProperty(CLIENT_KEY_PROP_NAME, "test");
218         properties.setProperty(NOTIFICATION_TYPE_PROP_NAME, UEB + COMMA + DMAAP);
219         properties.setProperty(NOTIFICATION_SERVERS_PROP_NAME, SERVER_NAME + COMMA + SERVER_NAME);
220         properties.setProperty(NOTIFICATION_TOPIC_PROP_NAME, "test");
221         properties.setProperty(ENVIRONMENT_PROP_NAME, "TEST");
222         creatPropertyFile(file, properties);
223
224         final StdPolicyEngine policyEngine = new StdPolicyEngine(file.toString(), (String) null);
225         policyEngine.setScheme(NotificationScheme.MANUAL_NOTIFICATIONS);
226         assertEquals("http://localhost:8092/pdp/", StdPolicyEngine.getPDPURL());
227         StdPolicyEngine.rotatePDPList();
228         assertEquals("https://localhost:8091/pdp/", StdPolicyEngine.getPDPURL());
229         assertEquals(Arrays.asList(UEB, DMAAP), policyEngine.getNotificationType());
230         assertEquals(Arrays.asList(SERVER_NAME, SERVER_NAME), policyEngine.getNotificationURLList());
231     }
232
233     @Test(expected = PolicyEngineException.class)
234     public void testStdPolicyEngineInitialize_NoPDP_noException() throws Exception {
235         final File file = temporaryFolder.newFile(CONFIG_PROPERTIES_FILE);
236
237         final Properties properties = new Properties();
238         properties.setProperty(CLIENT_ID_PROP_NAME, "test");
239         properties.setProperty(CLIENT_KEY_PROP_NAME, "test");
240         properties.setProperty(NOTIFICATION_TYPE_PROP_NAME, UEB + COMMA + DMAAP);
241         properties.setProperty(NOTIFICATION_SERVERS_PROP_NAME, SERVER_NAME + COMMA + SERVER_NAME);
242         properties.setProperty(NOTIFICATION_TOPIC_PROP_NAME, "test");
243         properties.setProperty(ENVIRONMENT_PROP_NAME, "TEST");
244         creatPropertyFile(file, properties);
245
246         new StdPolicyEngine(file.toString(), (String) null);
247     }
248
249     @Test
250     public void testStdPolicyEngineInitializeNotificationTypeDMMAP_noException() throws Exception {
251         final File file = temporaryFolder.newFile(CONFIG_PROPERTIES_FILE);
252
253         final Properties properties = new Properties();
254         properties.setProperty(PDP_URL_PROP_NAME, PDP_PROP_VALUE);
255         properties.setProperty(CLIENT_ID_PROP_NAME, "test");
256         properties.setProperty(CLIENT_KEY_PROP_NAME, "test");
257         properties.setProperty(NOTIFICATION_TYPE_PROP_NAME, DMAAP);
258         properties.setProperty(NOTIFICATION_SERVERS_PROP_NAME, SERVER_NAME + COMMA + SERVER_NAME);
259         properties.setProperty(NOTIFICATION_TOPIC_PROP_NAME, "test");
260         properties.setProperty(ENVIRONMENT_PROP_NAME, "TEST");
261         creatPropertyFile(file, properties);
262
263         final StdPolicyEngine policyEngine = new StdPolicyEngine(file.toString(), (String) null);
264         policyEngine.setScheme(NotificationScheme.MANUAL_NOTIFICATIONS);
265
266         assertEquals(Arrays.asList(DMAAP), policyEngine.getNotificationType());
267
268     }
269
270     @Test
271     public void testStdPolicyEngineSendEvent_noException() throws Exception {
272         final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
273         doReturn(new ResponseEntity<>(getStdPolicyResponse(), HttpStatus.ACCEPTED)).when(spyPolicyEngine)
274                 .callNewPDP(eq(SEND_EVENT_RESOURCE_NAME), any(), any(), any());
275
276         final Collection<PolicyResponse> actualPolicyResponses =
277                 spyPolicyEngine.sendEvent(Collections.emptyMap(), REQUEST_UUID);
278
279         assertEquals(1, actualPolicyResponses.size());
280
281     }
282
283     @Test(expected = PolicyEventException.class)
284     public void testStdPolicyEngineSendEvent_NullEventRequestParameters_Exception() throws Exception {
285         final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
286         spyPolicyEngine.sendEvent((EventRequestParameters) null);
287     }
288
289     @Test(expected = PolicyEventException.class)
290     public void testStdPolicyEngineSendEvent_EventRequestParameters_CallPDPThrow401Exception_Exception()
291             throws Exception {
292         final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
293         Mockito.doThrow(new RuntimeException(new RestClientException("Error 401"))).when(spyPolicyEngine)
294                 .callNewPDP(any(), any(), any(), any());
295         spyPolicyEngine.sendEvent(Collections.emptyMap(), REQUEST_UUID);
296     }
297
298     @Test
299     public void testStdPolicyEngineSendEvent_EventRequestParameters_noException() throws Exception {
300         final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
301
302         final ResponseEntity<StdPolicyResponse[]> stubbedResponse =
303                 new ResponseEntity<>(getStdPolicyResponse(), HttpStatus.ACCEPTED);
304
305         doReturn(stubbedResponse).when(spyPolicyEngine).callNewPDP(eq(SEND_EVENT_RESOURCE_NAME), any(), any(), any());
306
307         final EventRequestParameters eventRequestParameters = new EventRequestParameters();
308         eventRequestParameters.setEventAttributes(Collections.emptyMap());
309         eventRequestParameters.setRequestID(REQUEST_UUID);
310
311         final Collection<PolicyResponse> actualPolicyResponses = spyPolicyEngine.sendEvent(eventRequestParameters);
312
313         assertEquals(1, actualPolicyResponses.size());
314
315     }
316
317     @Test
318     public void testStdPolicyEngineGetConfig_ConfigRequestParametersPolicyConfigJSON_noException() throws Exception {
319         final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
320
321         final ResponseEntity<APIPolicyConfigResponse[]> stubbedResponse = new ResponseEntity<>(
322                 getAPIPolicyConfigResponse(PolicyType.JSON, JSON_CONFIGURATION), HttpStatus.ACCEPTED);
323
324         doReturn(stubbedResponse).when(spyPolicyEngine).callNewPDP(eq(GET_CONFIG_RESOURCE_NAME), eq(HttpMethod.POST),
325                 any(), any());
326
327         final Collection<PolicyConfig> actualPolicyResponses = spyPolicyEngine.getConfig(new ConfigRequestParameters());
328
329         assertEquals(1, actualPolicyResponses.size());
330
331         final PolicyConfig actualPolicyConfig = actualPolicyResponses.iterator().next();
332         assertNotNull(actualPolicyConfig.toJSON());
333
334     }
335
336     @Test
337     public void testStdPolicyEngineGetConfig_ConfigRequestParametersPolicyConfigOther_noException() throws Exception {
338         final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
339
340         final ResponseEntity<APIPolicyConfigResponse[]> stubbedResponse =
341                 new ResponseEntity<>(getAPIPolicyConfigResponse(PolicyType.OTHER, COMMENTS), HttpStatus.ACCEPTED);
342
343         doReturn(stubbedResponse).when(spyPolicyEngine).callNewPDP(eq(GET_CONFIG_RESOURCE_NAME), eq(HttpMethod.POST),
344                 any(), any());
345
346         final Collection<PolicyConfig> actualPolicyResponses = spyPolicyEngine.getConfig(new ConfigRequestParameters());
347
348         assertEquals(1, actualPolicyResponses.size());
349
350         final PolicyConfig actualPolicyConfig = actualPolicyResponses.iterator().next();
351         assertNotNull(actualPolicyConfig.toOther());
352
353     }
354
355     @Test
356     public void testStdPolicyEngineGetConfig_ConfigRequestParametersPolicyConfigXML_noException() throws Exception {
357         final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
358
359         final ResponseEntity<APIPolicyConfigResponse[]> stubbedResponse = new ResponseEntity<>(
360                 getAPIPolicyConfigResponse(PolicyType.XML, XML_CONFIGURATION), HttpStatus.ACCEPTED);
361
362         doReturn(stubbedResponse).when(spyPolicyEngine).callNewPDP(eq(GET_CONFIG_RESOURCE_NAME), eq(HttpMethod.POST),
363                 any(), any());
364
365         final Collection<PolicyConfig> actualPolicyResponses = spyPolicyEngine.getConfig(new ConfigRequestParameters());
366
367         assertEquals(1, actualPolicyResponses.size());
368
369         final PolicyConfig actualPolicyConfig = actualPolicyResponses.iterator().next();
370         assertNotNull(actualPolicyConfig.toXML());
371
372     }
373
374     @Test
375     public void testStdPolicyEngineGetConfig_ConfigRequestParametersPolicyConfigProperties_noException()
376             throws Exception {
377         final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
378
379         final ResponseEntity<APIPolicyConfigResponse[]> stubbedResponse =
380                 new ResponseEntity<>(getAPIPolicyConfigResponse(PolicyType.PROPERTIES, COMMENTS), HttpStatus.ACCEPTED);
381
382         doReturn(stubbedResponse).when(spyPolicyEngine).callNewPDP(eq(GET_CONFIG_RESOURCE_NAME), eq(HttpMethod.POST),
383                 any(), any());
384
385         final Collection<PolicyConfig> actualPolicyResponses = spyPolicyEngine.getConfig(new ConfigRequestParameters());
386
387         assertEquals(1, actualPolicyResponses.size());
388
389         final PolicyConfig actualPolicyConfig = actualPolicyResponses.iterator().next();
390         assertNotNull(actualPolicyConfig.toProperties());
391
392     }
393
394     @Test(expected = PolicyConfigException.class)
395     public void testStdPolicyEngineSendEvent_ConfigRequestParameters_CallPDPThrow404Exception_Exception()
396             throws Exception {
397         final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
398         doThrow(new RuntimeException(new RestClientException("Error 404"))).when(spyPolicyEngine).callNewPDP(any(),
399                 any(), any(), any());
400         spyPolicyEngine.getConfig(new ConfigRequestParameters());
401     }
402
403     @Test
404     public void testStdPolicyEngineListConfig_ConfigRequestParametersPolicyConfigProperties_noException()
405             throws Exception {
406         final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
407
408         final APIPolicyConfigResponse[] apiPolicyConfigResponse =
409                 getAPIPolicyConfigResponse(PolicyType.JSON, JSON_CONFIGURATION);
410
411         final ResponseEntity<APIPolicyConfigResponse[]> stubbedResponse =
412                 new ResponseEntity<>(apiPolicyConfigResponse, HttpStatus.ACCEPTED);
413
414         doReturn(stubbedResponse).when(spyPolicyEngine).callNewPDP(eq(GET_CONFIG_RESOURCE_NAME), eq(HttpMethod.POST),
415                 any(), any());
416
417         final Collection<String> actualResponse = spyPolicyEngine.listConfig(new ConfigRequestParameters());
418         assertEquals(1, actualResponse.size());
419         assertNotNull(actualResponse.iterator().next());
420
421     }
422
423     @Test
424     public void testStdPolicyEngineListConfig_ConfigRequestParametersMessageConfigContainsPE300_noException()
425             throws Exception {
426         final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
427
428         final APIPolicyConfigResponse[] apiPolicyConfigResponse =
429                 getAPIPolicyConfigResponse(PolicyType.JSON, JSON_CONFIGURATION, PolicyConfigConstants.PE300);
430
431         final ResponseEntity<APIPolicyConfigResponse[]> stubbedResponse =
432                 new ResponseEntity<>(apiPolicyConfigResponse, HttpStatus.ACCEPTED);
433
434         doReturn(stubbedResponse).when(spyPolicyEngine).callNewPDP(eq(GET_CONFIG_RESOURCE_NAME), eq(HttpMethod.POST),
435                 any(), any());
436
437         final Collection<String> actualResponse = spyPolicyEngine.listConfig(new ConfigRequestParameters());
438
439         assertEquals(1, actualResponse.size());
440
441     }
442
443     @Test
444     public void testStdPolicyEngineListConfig_ConfigRequestParametersWithTestProperty_noException() throws Exception {
445         final Properties defaultProperties = getDefaultProperties();
446         defaultProperties.setProperty(PolicyConfigConstants.JUNIT_PROP_NAME, "test");
447         final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine("test" + CONFIG_PROPERTIES_FILE, defaultProperties);
448
449         final Collection<String> actualResponse = spyPolicyEngine.listConfig(new ConfigRequestParameters());
450
451         assertEquals(1, actualResponse.size());
452
453     }
454
455     @Test
456     public void testStdPolicyEnginGetDecision_PolicyDecision_noException() throws Exception {
457
458         final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
459
460         final ResponseEntity<StdDecisionResponse> stubbedResponse =
461                 new ResponseEntity<>(getStdDecisionResponse(), HttpStatus.ACCEPTED);
462
463         doReturn(stubbedResponse).when(spyPolicyEngine).callNewPDP(eq(GET_DECISION_RESOURCE_NAME), eq(HttpMethod.POST),
464                 any(), any());
465
466         final DecisionResponse actualResponse =
467                 spyPolicyEngine.getDecision(ONAP_NAME_VAL, Collections.emptyMap(), REQUEST_UUID);
468
469         assertNotNull(actualResponse);
470     }
471
472     @Test(expected = PolicyDecisionException.class)
473     public void testStdPolicyEngineGetDecision_PolicyDecision_CallPDPThrow400Exception_Exception() throws Exception {
474         final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
475         doThrow(new RuntimeException(new RestClientException("Error 400"))).when(spyPolicyEngine)
476                 .callNewPDP(eq(GET_DECISION_RESOURCE_NAME), eq(HttpMethod.POST), any(), any());
477         spyPolicyEngine.getDecision(ONAP_NAME_VAL, Collections.emptyMap(), REQUEST_UUID);
478     }
479
480     @Test
481     public void testStdPolicyEnginGetDecision_DecisionRequestParameters_noException() throws Exception {
482
483         final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
484
485         final ResponseEntity<StdDecisionResponse> stubbedResponse =
486                 new ResponseEntity<>(getStdDecisionResponse(), HttpStatus.ACCEPTED);
487
488         doReturn(stubbedResponse).when(spyPolicyEngine).callNewPDP(eq(GET_DECISION_RESOURCE_NAME), eq(HttpMethod.POST),
489                 any(), any());
490
491         final DecisionRequestParameters requestParameters = new DecisionRequestParameters();
492         requestParameters.setOnapName(ONAP_NAME_VAL);
493         requestParameters.setRequestID(REQUEST_UUID);
494         requestParameters.setDecisionAttributes(Collections.emptyMap());
495
496         final DecisionResponse actualResponse = spyPolicyEngine.getDecision(requestParameters);
497
498         assertNotNull(actualResponse);
499     }
500
501     @Test(expected = PolicyDecisionException.class)
502     public void ttestStdPolicyEnginGetDecision_NullDecisionRequestParameters_Exception() throws Exception {
503         final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
504         spyPolicyEngine.getDecision((DecisionRequestParameters) null);
505     }
506
507     @Test
508     public void testStdPolicyEnginGetMetrics_MetricsRequestParameters_noException() throws Exception {
509
510         final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
511
512         final ResponseEntity<String> stubbedResponse = new ResponseEntity<>("Metrics", HttpStatus.ACCEPTED);
513
514         doReturn(stubbedResponse).when(spyPolicyEngine).callNewPDP(eq(GET_METRICS_RESOURCE_NAME), eq(HttpMethod.GET),
515                 any(), any());
516
517         final MetricsResponse actualResponse = spyPolicyEngine.getMetrics(new MetricsRequestParameters());
518         assertNotNull(actualResponse);
519         assertEquals(HttpStatus.ACCEPTED.value(), actualResponse.getResponseCode());
520
521     }
522
523     @Test
524     public void testStdPolicyEngineGetMetrics_MetricsRequestParametersCallPDPThrowHttpException_ResponseWithHttpCode()
525             throws Exception {
526         final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
527         doThrow(new PolicyException(new HttpClientErrorException(HttpStatus.BAD_GATEWAY))).when(spyPolicyEngine)
528                 .callNewPDP(eq(GET_METRICS_RESOURCE_NAME), eq(HttpMethod.GET), any(), any());
529
530         final MetricsResponse actualResponse = spyPolicyEngine.getMetrics(new MetricsRequestParameters());
531         assertNotNull(actualResponse);
532         assertEquals(HttpStatus.BAD_GATEWAY.value(), actualResponse.getResponseCode());
533
534     }
535
536     @Test(expected = PolicyException.class)
537     public void testStdPolicyEngineGetMetrics_MetricsRequestParametersCallPDPThrowPolicyException_Exception()
538             throws Exception {
539         final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
540         doThrow(PolicyException.class).when(spyPolicyEngine).callNewPDP(eq(GET_METRICS_RESOURCE_NAME),
541                 eq(HttpMethod.GET), any(), any());
542
543         spyPolicyEngine.getMetrics(new MetricsRequestParameters());
544
545     }
546
547     @Test
548     public void testStdPolicyEnginPushPolicy_PushPolicyParameters_noException() throws Exception {
549
550         final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
551
552         final ResponseEntity<String> stubbedResponse = new ResponseEntity<>("Successful", HttpStatus.OK);
553
554         doReturn(stubbedResponse).when(spyPolicyEngine).callNewPDP(eq(PUSH_POLICY_RESOURCE_NAME), eq(HttpMethod.PUT),
555                 any(), any());
556
557         final PolicyChangeResponse actualResponse = spyPolicyEngine.pushPolicy(new PushPolicyParameters());
558
559         assertNotNull(actualResponse);
560         assertEquals(HttpStatus.OK.value(), actualResponse.getResponseCode());
561     }
562
563     @Test
564     public void testStdPolicyEnginePushPolicy_PushPolicyParametersThrowsHttpClientErrorException_ResponseWithHttpCode()
565             throws Exception {
566         final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
567         doThrow(new PolicyException(new HttpClientErrorException(HttpStatus.BAD_GATEWAY))).when(spyPolicyEngine)
568                 .callNewPDP(eq(PUSH_POLICY_RESOURCE_NAME), eq(HttpMethod.PUT), any(), any());
569
570         final PolicyChangeResponse actualResponse = spyPolicyEngine.pushPolicy(new PushPolicyParameters());
571
572         assertNotNull(actualResponse);
573         assertEquals(HttpStatus.BAD_GATEWAY.value(), actualResponse.getResponseCode());
574
575     }
576
577     @Test(expected = PolicyException.class)
578     public void testStdPolicyEnginePushPolicy_PushPolicyParameters_Exception() throws Exception {
579         final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
580         doThrow(PolicyException.class).when(spyPolicyEngine).callNewPDP(eq(PUSH_POLICY_RESOURCE_NAME),
581                 eq(HttpMethod.PUT), any(), any());
582
583         spyPolicyEngine.pushPolicy(new PushPolicyParameters());
584
585     }
586
587     @Test
588     public void testStdPolicyEnginDeletePolicy_DeletePolicyParameters_noException() throws Exception {
589
590         final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
591
592         final ResponseEntity<String> stubbedResponse = new ResponseEntity<>("Successful", HttpStatus.OK);
593
594         doReturn(stubbedResponse).when(spyPolicyEngine).callNewPDP(eq(DELETE_POLICY_RESOURCE_NAME),
595                 eq(HttpMethod.DELETE), any(), any());
596
597         final PolicyChangeResponse actualResponse = spyPolicyEngine.deletePolicy(new DeletePolicyParameters());
598
599         assertNotNull(actualResponse);
600         assertEquals(HttpStatus.OK.value(), actualResponse.getResponseCode());
601     }
602
603     @Test
604     public void testStdPolicyEnginGetDictionaryItem_DictionaryParameters_noException() throws Exception {
605
606         final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
607
608         final ResponseEntity<APIDictionaryResponse> stubbedResponse =
609                 new ResponseEntity<>(getAPIDictionaryResponse(), HttpStatus.OK);
610
611         doReturn(stubbedResponse).when(spyPolicyEngine).callNewPDP(eq(GET_DICTIONARY_ITEMS_RESOURCE_NAME),
612                 eq(HttpMethod.POST), any(), any());
613
614         final DictionaryResponse actualResponse = spyPolicyEngine.getDictionaryItem(new DictionaryParameters());
615
616         assertNotNull(actualResponse);
617     }
618
619     @Test
620     public void testStdPolicyGetDictionaryItem_DictionaryParametersWithHttp400ExceptionThrown_ResponseWithHttpCode()
621             throws Exception {
622         final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
623         doThrow(new RuntimeException(new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Error 400")))
624                 .when(spyPolicyEngine)
625                 .callNewPDP(eq(GET_DICTIONARY_ITEMS_RESOURCE_NAME), eq(HttpMethod.POST), any(), any());
626
627         final DictionaryResponse actualResponse = spyPolicyEngine.getDictionaryItem(new DictionaryParameters());
628
629         assertNotNull(actualResponse);
630         assertEquals(HttpStatus.BAD_REQUEST.value(), actualResponse.getResponseCode());
631
632     }
633
634     @Test
635     public void testStdPolicyGetDictionaryItem_DictionaryParametersWithHttp401ExceptionThrown_ResponseWithHttpCode()
636             throws Exception {
637         final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
638         doThrow(new RuntimeException(new HttpClientErrorException(HttpStatus.UNAUTHORIZED, "Error 401")))
639                 .when(spyPolicyEngine)
640                 .callNewPDP(eq(GET_DICTIONARY_ITEMS_RESOURCE_NAME), eq(HttpMethod.POST), any(), any());
641
642         final DictionaryResponse actualResponse = spyPolicyEngine.getDictionaryItem(new DictionaryParameters());
643
644         assertNotNull(actualResponse);
645         assertEquals(HttpStatus.UNAUTHORIZED.value(), actualResponse.getResponseCode());
646
647     }
648
649     @Test
650     public void testStdPolicyGetDictionaryItem_DictionaryParametersWithRunTimeExceptionThrown_ResponseWithHttpCode()
651             throws Exception {
652         final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
653         doThrow(new RuntimeException(new HttpClientErrorException(HttpStatus.INTERNAL_SERVER_ERROR, "Error")))
654                 .when(spyPolicyEngine)
655                 .callNewPDP(eq(GET_DICTIONARY_ITEMS_RESOURCE_NAME), eq(HttpMethod.POST), any(), any());
656
657         final DictionaryResponse actualResponse = spyPolicyEngine.getDictionaryItem(new DictionaryParameters());
658
659         assertNotNull(actualResponse);
660         assertEquals(HttpStatus.INTERNAL_SERVER_ERROR.value(), actualResponse.getResponseCode());
661
662     }
663
664     @Test
665     public void testStdPolicyEnginCreateDictionaryItem_DictionaryParameters_noException() throws Exception {
666
667         final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
668
669         final ResponseEntity<String> stubbedResponse = new ResponseEntity<>("Successful", HttpStatus.OK);
670
671         doReturn(stubbedResponse).when(spyPolicyEngine).callNewPDP(eq(CREATE_DICTIONARY_ITEM_RESOURCE_NAME),
672                 eq(HttpMethod.PUT), any(), any());
673
674         final PolicyChangeResponse actualResponse = spyPolicyEngine.createDictionaryItem(new DictionaryParameters());
675
676         assertNotNull(actualResponse);
677         assertEquals(HttpStatus.OK.value(), actualResponse.getResponseCode());
678     }
679
680     @Test
681     public void testStdPolicyEnginUpdateDictionaryItem_DictionaryParameters_noException() throws Exception {
682
683         final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
684
685         final ResponseEntity<String> stubbedResponse = new ResponseEntity<>("Successful", HttpStatus.OK);
686
687         doReturn(stubbedResponse).when(spyPolicyEngine).callNewPDP(eq(UPDATE_DICTIONARY_ITEM_RESOURCE_NAME),
688                 eq(HttpMethod.PUT), any(), any());
689
690         final PolicyChangeResponse actualResponse = spyPolicyEngine.updateDictionaryItem(new DictionaryParameters());
691
692         assertNotNull(actualResponse);
693         assertEquals(HttpStatus.OK.value(), actualResponse.getResponseCode());
694     }
695
696     @Test
697     public void testStdPolicyEnginPolicyEngineImport_ImportParameters_noException() throws Exception {
698         final File emptyfile = temporaryFolder.newFile("emptyFile.txt");
699         final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
700
701         final ResponseEntity<String> stubbedResponse = new ResponseEntity<>("Successful", HttpStatus.OK);
702
703         doReturn(stubbedResponse).when(spyPolicyEngine).callNewPDP(eq(POLICY_ENGINE_IMPORT_RESOURCE_NAME),
704                 eq(HttpMethod.POST), any(), any());
705
706         final ImportParameters importParameters = new ImportParameters();
707         importParameters.setFilePath(emptyfile.toString());
708         final PolicyChangeResponse actualResponse = spyPolicyEngine.policyEngineImport(importParameters);
709
710         assertNotNull(actualResponse);
711         assertEquals(HttpStatus.OK.value(), actualResponse.getResponseCode());
712     }
713
714     @Test
715     public void testStdPolicyEnginCreatePolicy_PolicyParameters_noException() throws Exception {
716         final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
717
718         final ResponseEntity<String> stubbedResponse = new ResponseEntity<>("Successful", HttpStatus.OK);
719
720         doReturn(stubbedResponse).when(spyPolicyEngine).callNewPDP(eq(CREATE_POLICY_RESOURCE_NAME), eq(HttpMethod.PUT),
721                 any(), any());
722
723         final PolicyChangeResponse actualResponse = spyPolicyEngine.createPolicy(new PolicyParameters());
724
725         assertNotNull(actualResponse);
726         assertEquals(HttpStatus.OK.value(), actualResponse.getResponseCode());
727     }
728
729     @Test
730     public void testStdPolicyEnginUpdatePolicy_PolicyParameters_noException() throws Exception {
731         final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
732
733         final ResponseEntity<String> stubbedResponse = new ResponseEntity<>("Successful", HttpStatus.OK);
734
735         doReturn(stubbedResponse).when(spyPolicyEngine).callNewPDP(eq(UPDATE_POLICY_RESOURCE_NAME), eq(HttpMethod.PUT),
736                 any(), any());
737
738         final PolicyChangeResponse actualResponse = spyPolicyEngine.updatePolicy(new PolicyParameters());
739
740         assertNotNull(actualResponse);
741         assertEquals(HttpStatus.OK.value(), actualResponse.getResponseCode());
742     }
743
744     @Test(expected = PolicyException.class)
745     public void testStdPolicyEnginPushPolicy_NullValues_Exception() throws Exception {
746         final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
747
748         spyPolicyEngine.pushPolicy(null, null, null, null, null);
749     }
750
751     @Test(expected = PolicyException.class)
752     public void testStdPolicyEnginPushPolicy_EmptyPolicyScope_Exception() throws Exception {
753         final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
754
755         spyPolicyEngine.pushPolicy("", null, null, null, null);
756     }
757
758     @Test(expected = PolicyException.class)
759     public void testStdPolicyEnginPushPolicy_EmptyPolicyName_Exception() throws Exception {
760         final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
761
762         spyPolicyEngine.pushPolicy("POLICY_SCOPE", "", null, null, null);
763     }
764
765     @Test
766     public void testStdPolicyEnginPushPolicy_PolicyParameters_noException() throws Exception {
767         final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
768
769         final ResponseEntity<String> stubbedResponse = new ResponseEntity<>("Successful", HttpStatus.OK);
770
771         doReturn(stubbedResponse).when(spyPolicyEngine).callNewPDP(eq(PUSH_POLICY_RESOURCE_NAME), eq(HttpMethod.PUT),
772                 any(), any());
773
774         final String actualResponse =
775                 spyPolicyEngine.pushPolicy("POLICY_SCOPE", ONAP_NAME_VAL, "POLICY_TYPE", "POLICY_GROUP", REQUEST_UUID);
776
777         assertNotNull(actualResponse);
778     }
779
780     @Test
781     public void testStdPolicyEnginCreateUpdateConfigPolicy_PolicyParameters_noException() throws Exception {
782         final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
783
784         final ResponseEntity<String> stubbedResponse = new ResponseEntity<>("Successful", HttpStatus.OK);
785
786         doReturn(stubbedResponse).when(spyPolicyEngine).callNewPDP(eq(UPDATE_POLICY_RESOURCE_NAME), eq(HttpMethod.PUT),
787                 any(), any());
788
789         final String actualResponse = spyPolicyEngine.createUpdateConfigPolicy("POLICY_NAME", ONAP_NAME_VAL,
790                 ONAP_NAME_VAL, "CONFIG_NAME", Collections.emptyMap(), PolicyType.JSON.toString().toUpperCase(), "",
791                 "POLICY_SCOPE", REQUEST_UUID, "", "", "", new Date().toString(), true);
792
793         assertNotNull(actualResponse);
794     }
795
796     @Test(expected = PolicyException.class)
797     public void testStdPolicyEnginCreateUpdateConfigPolicy_NullPolicyName_Exception() throws Exception {
798         final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
799
800         spyPolicyEngine.createUpdateConfigPolicy(null, null, null, null, null, null, null, null, null, null, null, null,
801                 null, true);
802     }
803
804     @Test
805     public void testStdPolicyEnginCreateUpdateConfigFirewallPolicy_PolicyParameters_noException() throws Exception {
806         final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
807
808         final ResponseEntity<String> stubbedResponse = new ResponseEntity<>("Successful", HttpStatus.OK);
809
810         doReturn(stubbedResponse).when(spyPolicyEngine).callNewPDP(eq(UPDATE_POLICY_RESOURCE_NAME), eq(HttpMethod.PUT),
811                 any(), any());
812
813         final String actualResponse =
814                 spyPolicyEngine.createUpdateConfigFirewallPolicy("POLICY_NAME", getJsonObject(JSON_CONFIGURATION),
815                         "POLICY_SCOPE", REQUEST_UUID, "", "", "", new Date().toString(), true);
816
817         assertNotNull(actualResponse);
818     }
819
820     private JsonObject getJsonObject(final String jsonString) {
821         try (final JsonReader jsonReader = Json.createReader(new StringReader(jsonString));) {
822             return jsonReader.readObject();
823         }
824     }
825
826     private StdPolicyEngine getSpyPolicyEngine() throws IOException, PolicyEngineException {
827         return getSpyPolicyEngine(CONFIG_PROPERTIES_FILE, getDefaultProperties());
828     }
829
830     private StdPolicyEngine getSpyPolicyEngine(final String filename, final Properties properties)
831             throws IOException, PolicyEngineException {
832         final File file = temporaryFolder.newFile(filename);
833
834         creatPropertyFile(file, properties);
835
836         final StdPolicyEngine spyPolicyEngine = spy(new StdPolicyEngine(file.toString(), (String) null));
837         spyPolicyEngine.setScheme(NotificationScheme.MANUAL_NOTIFICATIONS);
838         return spyPolicyEngine;
839     }
840
841     private Properties getDefaultProperties() {
842         final Properties properties = new Properties();
843         properties.setProperty(PDP_URL_PROP_NAME, PDP_PROP_VALUE);
844         properties.setProperty(CLIENT_ID_PROP_NAME, "test");
845         properties.setProperty(CLIENT_KEY_PROP_NAME, "test");
846         properties.setProperty(NOTIFICATION_TYPE_PROP_NAME, UEB + COMMA + DMAAP);
847         properties.setProperty(NOTIFICATION_SERVERS_PROP_NAME, SERVER_NAME + COMMA + SERVER_NAME);
848         properties.setProperty(NOTIFICATION_TOPIC_PROP_NAME, "test");
849         properties.setProperty(ENVIRONMENT_PROP_NAME, "TEST");
850         properties.setProperty(PolicyConfigConstants.JUNIT_PROP_NAME, "false");
851         return properties;
852     }
853
854     private StdDecisionResponse getStdDecisionResponse() {
855         final StdDecisionResponse response = new StdDecisionResponse();
856         response.setDecision(PolicyDecision.PERMIT);
857         response.setDetails(PolicyDecision.PERMIT.name());
858
859         return response;
860     }
861
862     private APIDictionaryResponse getAPIDictionaryResponse() {
863         final APIDictionaryResponse response = new APIDictionaryResponse();
864         response.setResponseCode(0);
865         response.setResponseMessage("");
866         response.setDictionaryData(Collections.<String, String>emptyMap());
867         response.setDictionaryJson(Collections.<String, String>emptyMap());
868         return response;
869     }
870
871     private StdPolicyResponse[] getStdPolicyResponse() {
872         final StdPolicyResponse response = new StdPolicyResponse();
873         response.setPolicyResponseStatus(PolicyResponseStatus.ACTION_TAKEN);
874         return new StdPolicyResponse[] {response};
875     }
876
877     private void creatPropertyFile(final File file, final Properties properties) throws IOException {
878         try (final BufferedWriter bufferedWriter = Files.newBufferedWriter(file.toPath());) {
879             properties.store(bufferedWriter, COMMENTS);
880         }
881     }
882
883     private APIPolicyConfigResponse[] getAPIPolicyConfigResponse(final PolicyType policyType,
884             final String configuration) {
885
886         return getAPIPolicyConfigResponse(policyType, configuration, null);
887     }
888
889     private APIPolicyConfigResponse[] getAPIPolicyConfigResponse(final PolicyType policyType,
890             final String configuration, final String policyConfigMessage) {
891         final APIPolicyConfigResponse configResponse = new APIPolicyConfigResponse();
892         configResponse.setConfig(configuration);
893         configResponse.setMatchingConditions(getMatchingConditions());
894         configResponse.setPolicyConfigStatus(PolicyConfigStatus.CONFIG_RETRIEVED);
895         configResponse.setPolicyName(POLICY_NAME);
896         configResponse.setPolicyType(PolicyConfigType.BRMS_RAW);
897         configResponse.setType(policyType);
898         configResponse.setPolicyVersion(POLICY_VERSION);
899         configResponse.setProperty(Collections.emptyMap());
900         configResponse.setPolicyConfigMessage(policyConfigMessage);
901
902         return new APIPolicyConfigResponse[] {configResponse};
903     }
904
905     private Map<String, String> getMatchingConditions() {
906         final Map<String, String> attributes = new HashMap<>();
907         attributes.put(ONAP_NAME, POLICY_NAME);
908         attributes.put(CONFIG_NAME, "Configuration_name");
909         return attributes;
910     }
911
912 }