Provide user to specify the ouput name while declaring the atrributes
[sdc.git] / integration-tests / src / test / java / org / onap / sdc / frontend / ci / tests / pages / PropertyNameBuilder.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2019 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.sdc.frontend.ci.tests.pages;
22
23 import org.openecomp.sdc.be.model.ComponentInstance;
24 import org.onap.sdc.frontend.ci.tests.datatypes.DataTestIdEnum;
25
26 public class PropertyNameBuilder {
27     private static final String PREFIX_VAL = DataTestIdEnum.PropertiesAssignmentScreen.PROPERTY_VALUE_FIELD_PREFIX.getValue();
28     private static final String PREFIX_KEY = DataTestIdEnum.PropertiesAssignmentScreen.PROPERTY_KEY_FIELD_PREFIX.getValue();
29     private static final String PREFIX_EXPAND = DataTestIdEnum.PropertiesAssignmentScreen.EXPAND_BUTTON.getValue();
30     private static final String PREFIX_INPUT_VAL = DataTestIdEnum.PropertiesAssignmentScreen.INPUT_VALUE_FIELD_PREFIX.getValue();
31     private static final String POPUP_VAL = DataTestIdEnum.PropertiesAssignmentScreen.POPUP_VALUE_FIELD_PREFIX.getValue();
32
33     private PropertyNameBuilder() {
34
35     }
36
37     //VF/Service simple property value field
38     public static String buildSimpleField(String propertyName) {
39         return new StringBuilder().append(PREFIX_VAL).append(propertyName).toString();
40     }
41
42     public static String buildPopupField(String propertyName) {
43         return new StringBuilder().append(POPUP_VAL).append(propertyName).toString();
44     }
45
46     public static String buildIndexedField(String propertyName, int index) {
47         return new StringBuilder().append(PREFIX_VAL).append(propertyName).append(".").append(index).toString();
48     }
49
50     public static String buildIndexedKeyField(String propertyName, int index) {
51         return new StringBuilder().append(PREFIX_KEY).append(propertyName).append(".").append(index).toString();
52     }
53
54     public static String buildIComplexField(String propertyName, String nestedProperty) {
55         return new StringBuilder().append(PREFIX_VAL).append(propertyName).append(".").append(nestedProperty).toString();
56     }
57
58     public static String buildIComplexListField(String propertyName, String nestedProperty, int index) {
59         return new StringBuilder().append(PREFIX_VAL).append(propertyName).append(".").append(index).append(".").append(nestedProperty).toString();
60     }
61
62     public static String buildIExpandButton(String propertyName, int index) {
63         return new StringBuilder().append(PREFIX_EXPAND).append(propertyName).append(".").append(index).toString();
64     }
65
66
67     //VF input value field
68     public static String buildDeclaredInputField(String componentName, String propertyName) {
69         return new StringBuilder().append(PREFIX_INPUT_VAL).append(componentName).append("_").append(propertyName).toString();
70     }
71
72     public static String buildInputField(String propertyName) {
73         return new StringBuilder().append(PREFIX_INPUT_VAL).append(propertyName).toString();
74     }
75
76     //Service Property value field - declared from VF
77     public static String buildServicePropertyValue(String componentName, String propertyName) {
78         return new StringBuilder().append(PREFIX_VAL).append(componentName).append("_").append(propertyName).toString();
79     }
80
81     //Service Input Name
82     public static String buildServiceInputNameServiceLevel(ComponentInstance componentInstance, String propertyName) {
83         return new StringBuilder().append(componentInstance.getNormalizedName())
84                 .append("_").append(propertyName).toString();
85     }
86
87     public static String buildServiceInputNameVfLevel(ComponentInstance componentInstance, String componentName, String propertyName) {
88         return new StringBuilder().append(componentInstance.getNormalizedName())
89                 .append("_").append(componentName).append("_").append(propertyName).toString();
90     }
91
92
93     //Service Input Value
94     public static String buildVfDeclaredPropValue(String componentName, String propertyName) {
95         String inputName = componentName + "_" + propertyName;
96         return new StringBuilder().append("{\"get_input\":\"").append(inputName).append("\"}").toString();
97     }
98
99     public static String buildServiceDeclaredPropertyValue(ComponentInstance componentInstance, String componentName, String propertyName) {
100         String inputName = buildServiceInputNameVfLevel(componentInstance, componentName, propertyName);
101         return new StringBuilder().append("{\"get_input\":\"").append(inputName).append("\"}").toString();
102     }
103
104     public static String buildServiceDeclaredPropValueServiceLevel(ComponentInstance componentInstance, String propertyName) {
105         String inputName = buildServiceInputNameServiceLevel(componentInstance, propertyName);
106         return new StringBuilder().append("{\"get_input\":\"").append(inputName).append("\"}").toString();
107     }
108
109     //Service Input value field
110     public static String buildServiceDeclaredFieldServiceLevel(ComponentInstance componentInstance, String propertyName) {
111         String inputName = buildServiceInputNameServiceLevel(componentInstance, propertyName);
112         return new StringBuilder().append(PREFIX_INPUT_VAL).append(inputName).toString();
113     }
114
115     public static String buildServiceDeclaredFieldVfLevel(ComponentInstance componentInstance, String componentName, String propertyName) {
116         String inputName = buildServiceInputNameVfLevel(componentInstance, componentName, propertyName);
117         return new StringBuilder().append(PREFIX_INPUT_VAL).append(inputName).toString();
118     }
119
120
121 }