[POLICY-11] Sample Query with variable arguments
[policy/drools-applications.git] / controlloop / templates / template.demo.v1.0.0 / template.demo / src / test / java / org / onap / policy / template / demo / TestAPPCPayload.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * demo
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.policy.template.demo;
22
23 import java.util.HashMap;
24 import java.util.UUID;
25
26 import org.junit.Test;
27 import org.onap.policy.appc.CommonHeader;
28 import org.onap.policy.appc.Request;
29 import org.onap.policy.appc.util.Serialization;
30 import org.onap.policy.vnf.trafficgenerator.PGRequest;
31 import org.onap.policy.vnf.trafficgenerator.PGStream;
32 import org.onap.policy.vnf.trafficgenerator.PGStreams;
33
34 public class TestAPPCPayload {
35
36         @Test
37         public void test() {
38                 PGRequest request = new PGRequest();
39                 request.pgStreams = new PGStreams();
40                 
41                 PGStream pgStream;
42                 for(int i = 0; i < 5; i++){
43                         pgStream = new PGStream();
44                         pgStream.streamId = "fw_udp"+(i+1);
45                         pgStream.isEnabled = "true";
46                         request.pgStreams.pgStream.add(pgStream);
47                 }
48                 
49                 Request appc = new Request();
50                 appc.CommonHeader = new CommonHeader();
51                 appc.CommonHeader.RequestID = UUID.randomUUID();
52                 appc.Action = "ModifyConfig";
53                 appc.Payload = new HashMap<String, Object>();
54                 appc.Payload.put("pg-streams", request);
55                 System.out.println(Serialization.gsonPretty.toJson(appc));
56         }
57
58 }