Remove policy-yaml from policy/engine
[policy/engine.git] / PolicyEngineClient / src / test / java / org / onap / policyengine / ListConfigPoliciesClient.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * PolicyEngineClient
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.onap.policyengine;
22
23 import java.util.Collection;
24 import java.util.HashMap;
25 import java.util.Map;
26 import java.util.UUID;
27
28 import org.onap.policy.api.ConfigRequestParameters;
29 import org.onap.policy.api.PolicyConfigException;
30 import org.onap.policy.api.PolicyEngine;
31 import org.onap.policy.api.PolicyEngineException;
32 import org.onap.policy.common.logging.flexlogger.FlexLogger;
33 import org.onap.policy.common.logging.flexlogger.Logger;
34
35 public class ListConfigPoliciesClient {
36         
37         private static final Logger LOGGER      = FlexLogger.getLogger(ListConfigPoliciesClient.class);
38         
39         public static void main(String[] args) {
40                 PolicyEngine policyEngine;
41
42                 // List Config Policies Example 
43                 try {
44                         policyEngine = new PolicyEngine("config.properties");
45                         ConfigRequestParameters parameters = new ConfigRequestParameters();
46                         
47                         parameters.setPolicyName(".*");
48                         parameters.setOnapName(".*");
49                         parameters.setConfigName(".*");
50                         
51                         Map<String, String> configAttributes = new HashMap<>();
52                         configAttributes.put("java", "java");
53                         configAttributes.put("peach", "Tar");
54                         configAttributes.put("true", "false");
55                         configAttributes.put("small", "testPass");
56                         parameters.setConfigAttributes(configAttributes);
57                         
58                         parameters.setRequestID(UUID.randomUUID());
59                         
60                         Collection<String> response = policyEngine.listConfig(parameters);
61                 if(response!=null && !response.contains("PE300")){
62                         for(String configList : response){
63                                 System.out.println(configList.toString()+"\n");
64                         }
65                 }else{
66                     System.out.println("Error! " +response);
67                 }
68
69                 } catch (PolicyConfigException e) {
70                         LOGGER.error("Exception Occured"+e);
71                 } catch (PolicyEngineException e) {
72                         LOGGER.error("Exception Occured"+e);
73                 }
74         }
75         
76 }