04c30ab9f9e74d181864b382b02aa6d320877d1d
[sdnc/northbound.git] / vnfapi / provider / src / test / java / org / openecomp / sdnc / vnfapi / TestPropertyList.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * openECOMP : SDN-C
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights
6  *                                                      reserved.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  * 
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  * 
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.onap.sdnc.vnfapi;
23
24 import java.io.FileNotFoundException;
25 import java.io.FileOutputStream;
26 import java.io.InputStream;
27 import java.io.PrintStream;
28 import java.util.Date;
29 import java.util.Properties;
30
31 import junit.framework.TestCase;
32
33 import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.VnfTopologyOperationInput;
34 import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.VnfTopologyOperationInputBuilder;
35 import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.service.data.ServiceDataBuilder;
36 import org.onap.sdnc.vnfapi.VnfSdnUtil;
37 import org.onap.sdnc.vnfapi.vnfapiProvider;
38 import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.PreloadVnfTopologyOperationInput;
39 import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.PreloadVnfTopologyOperationInputBuilder;
40 import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.preload.data.PreloadDataBuilder;
41 import org.slf4j.Logger;
42 import org.slf4j.LoggerFactory;
43
44 public class TestPropertyList extends TestCase {
45
46
47         private final Logger log = LoggerFactory.getLogger( vnfapiProvider.class );
48         public void testPrintPropertyList() {
49                 InputStream propStr = getClass().getResourceAsStream("/proplist.properties");
50                 
51                 Properties props = new Properties();
52
53                 try
54                 {
55                         props.load(propStr);
56                 }  catch (Exception e)
57                 {
58                         fail("Could not load proplist.properties");
59                 }
60                 
61                 String aptFile = props.getProperty("proplist.aptFile");
62                 
63                 if ((aptFile == null) || (aptFile.length() == 0))
64                 {
65                         fail("proplist.aptFile unset");
66                 }
67                 
68                 PrintStream outStr = null;
69                 
70                 try {
71                         outStr = new PrintStream(new FileOutputStream(aptFile));
72                 } catch (FileNotFoundException e) {
73                         fail("Cannot open apt file "+aptFile);
74                 }
75                 
76                 Date now = new Date();
77                 
78                 outStr.print("      ---");
79                 outStr.print("\n      Service Logic Variables");
80                 outStr.print("\n      ---");
81                 outStr.print("\n      System generated");
82                 outStr.print("\n      ---");
83                 outStr.print("\n      "+now.toString());
84                 outStr.print("\n\nSupported service logic variables");
85                 outStr.print("\n\n   Config/operational tree data for VNF SDN service is passed to the service logic in the following variables");
86                 outStr.print("\n");
87                 VnfSdnUtil.printPropertyList(outStr, "", ServiceDataBuilder.class);
88                 VnfSdnUtil.printPropertyList(outStr, "", PreloadDataBuilder.class);
89                 outStr.print("\n");
90                 outStr.print("\n\n   Input parameters to the vnf-topology-operation RPC are passed to the service logic in the following variables");
91                 outStr.print("\n");
92                 VnfSdnUtil.printPropertyList(outStr, "", VnfTopologyOperationInputBuilder.class);
93                 outStr.print("\n");
94                 outStr.print("\n\n   Input parameters to the preload-vnf-topology-operation -operation RPC are passed to the service logic in the following variables");
95                 outStr.print("\n");
96                 VnfSdnUtil.printPropertyList(outStr, "", PreloadVnfTopologyOperationInputBuilder.class);
97                 outStr.print("\n");
98                 outStr.flush();
99                 outStr.close();
100         }
101
102 }