Added oparent to sdc main
[sdc.git] / ui-ci / src / main / java / org / openecomp / sdc / 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.openecomp.sdc.ci.tests.pages;
22
23 import org.openecomp.sdc.be.model.ComponentInstance;
24 import org.openecomp.sdc.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     //VF/Service simple property value field
34     public static String buildSimpleField(String propertyName){
35         return new StringBuilder().append(PREFIX_VAL).append(propertyName).toString();
36     }
37
38     public static String buildPopupField(String propertyName){
39         return new StringBuilder().append(POPUP_VAL).append(propertyName).toString();
40     }
41
42     public static String buildIndexedField(String propertyName, int index){
43         return new StringBuilder().append(PREFIX_VAL).append(propertyName).append(".").append(index).toString();
44     }
45
46     public static String buildIndexedKeyField(String propertyName, int index){
47         return new StringBuilder().append(PREFIX_KEY).append(propertyName).append(".").append(index).toString();
48     }
49
50     public static String buildIComplexField(String propertyName, String nestedProperty){
51         return new StringBuilder().append(PREFIX_VAL).append(propertyName).append(".").append(nestedProperty).toString();
52     }
53
54     public static String buildIComplexListField(String propertyName, String nestedProperty, int index){
55         return new StringBuilder().append(PREFIX_VAL).append(propertyName).append(".").append(index).append(".").append(nestedProperty).toString();
56     }
57
58     public static String buildIExpandButton(String propertyName, int index){
59         return new StringBuilder().append(PREFIX_EXPAND).append(propertyName).append(".").append(index).toString();
60     }
61
62
63
64
65     //VF input value field
66     public static String buildDeclaredInputField(String componentName, String propertyName){
67         return new StringBuilder().append(PREFIX_INPUT_VAL).append(componentName).append("_").append(propertyName).toString();
68     }
69
70     public static String buildInputField(String propertyName){
71         return new StringBuilder().append(PREFIX_INPUT_VAL).append(propertyName).toString();
72     }
73
74     //Service Property value field - declared from VF
75     public static String buildServicePropertyValue(String componentName, String propertyName){
76         return new StringBuilder().append(PREFIX_VAL).append(componentName).append("_").append(propertyName).toString();
77     }
78
79     //Service Input Name
80     public static String buildServiceInputNameServiceLevel(ComponentInstance componentInstance, String propertyName){
81         return new StringBuilder().append(componentInstance.getNormalizedName())
82                 .append("_").append(propertyName).toString();
83     }
84
85     public static String buildServiceInputNameVfLevel(ComponentInstance componentInstance, String componentName, String propertyName){
86         return new StringBuilder().append(componentInstance.getNormalizedName())
87                 .append("_").append(componentName).append("_").append(propertyName).toString();
88     }
89
90
91     //Service Input Value
92     public static String buildVfDeclaredPropValue(String componentName, String propertyName){
93         String inputName = componentName + "_" + propertyName;
94         return new StringBuilder().append("{\"get_input\":\"").append(inputName).append("\"}").toString();
95     }
96
97     public static String buildServiceDeclaredPropertyValue(ComponentInstance componentInstance, String componentName, String propertyName){
98         String inputName = buildServiceInputNameVfLevel(componentInstance, componentName, propertyName );
99         return new StringBuilder().append("{\"get_input\":\"").append(inputName).append("\"}").toString();
100     }
101
102     public static String buildServiceDeclaredPropValueServiceLevel(ComponentInstance componentInstance, String propertyName){
103         String inputName = buildServiceInputNameServiceLevel(componentInstance, propertyName );
104         return new StringBuilder().append("{\"get_input\":\"").append(inputName).append("\"}").toString();
105     }
106
107     //Service Input value field
108     public static String buildServiceDeclaredFieldServiceLevel(ComponentInstance componentInstance, String propertyName){
109         String inputName = buildServiceInputNameServiceLevel(componentInstance, propertyName );
110         return new StringBuilder().append(PREFIX_INPUT_VAL).append(inputName).toString();
111     }
112
113     public static String buildServiceDeclaredFieldVfLevel(ComponentInstance componentInstance, String componentName, String propertyName){
114         String inputName = buildServiceInputNameVfLevel(componentInstance, componentName, propertyName );
115         return new StringBuilder().append(PREFIX_INPUT_VAL).append(inputName).toString();
116     }
117
118
119 }