Sync Integ to Master
[sdc.git] / test-apis-ci / src / main / java / org / openecomp / sdc / ci / tests / datatypes / enums / ResourceCategoryEnum.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
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.openecomp.sdc.ci.tests.datatypes.enums;
22
23 import java.util.ArrayList;
24 import java.util.Collections;
25 import java.util.List;
26 import java.util.Random;
27
28 import java.util.Random;
29
30 public enum ResourceCategoryEnum {
31
32         NETWORK_L2_3_ROUTERS("Network L2-3", "Router", "resourceNewCategory.network l2-3", "resourceNewCategory.network l2-3.router"), 
33         NETWORK_L2_3_GETEWAY("Network L2-3","Gateway", "resourceNewCategory.network l2-3", "resourceNewCategory.network l2-3.gateway"), 
34         NETWORK_L2_3_WAN_CONNECTORS("Network L2-3", "WAN Connectors", "resourceNewCategory.network l2-3", "resourceNewCategory.network l2-3.lan connectors"), 
35         NETWORK_L2_3_LAN_CONNECTORS("Network L2-3", "LAN Connectors", "resourceNewCategory.network l2-3", "resourceNewCategory.network l2-3.wan connectors"), 
36         NETWORK_L2_3_INFRASTRUCTURE("Network L2-3", "Infrastructure", "resourceNewCategory.network l2-3", "resourceNewCategory.network l2-3.infrastructure"),
37         
38         NETWORK_L4("Network L4+", "Common Network Resources", "resourceNewCategory.network l4+", "resourceNewCategory.network l4+.common network resources"), 
39         
40         APPLICATION_L4_BORDER("Application L4+", "Border Element", "resourceNewCategory.application l4+", "resourceNewCategory.application l4+.border element"), 
41         APPLICATION_L4_APP_SERVER("Application L4+", "Application Server", "resourceNewCategory.application l4+", "resourceNewCategory.application l4+.application server"), 
42         APPLICATION_L4_WEB_SERVERS("Application L4+", "Web Server", "resourceNewCategory.application l4+", "resourceNewCategory.application l4+.web server"), 
43         APPLICATION_L4_CALL_CONTROL("Application L4+","Call Control", "resourceNewCategory.application l4+", "resourceNewCategory.application l4+.call control"), 
44         APPLICATION_L4_MEDIA_SERVER("Application L4+", "Media Servers", "resourceNewCategory.application l4+", "resourceNewCategory.application l4+.media servers"), 
45         APPLICATION_L4_LOAD_BALANCER("Application L4+", "Load Balancer", "resourceNewCategory.application l4+", "resourceNewCategory.application l4+.load balancer"), 
46         APPLICATION_L4_DATABASE("Application L4+","Database", "resourceNewCategory.application l4+", "resourceNewCategory.application l4+.database"), 
47         APPLICATION_L4_FIREWALL("Application L4+", "Firewall", "resourceNewCategory.application l4+", "resourceNewCategory.application l4+.firewall"), 
48         
49         GENERIC_INFRASTRUCTURE("Generic", "Infrastructure", "resourceNewCategory.generic", "resourceNewCategory.generic.infrastructure"), 
50         GENERIC_ABSTRACT("Generic", "Abstract", "resourceNewCategory.generic", "resourceNewCategory.generic.abstract"), 
51         GENERIC_NETWORK_ELEMENTS("Generic","Network Elements", "resourceNewCategory.generic", "resourceNewCategory.generic.network elements"), 
52         GENERIC_DATABASE("Generic", "Database", "resourceNewCategory.generic", "resourceNewCategory.generic.database"),
53         GENERIC_RULES("Generic", "Rules", "resourceNewCategory.generic", "resourceNewCategory.generic.rules"),
54         
55         NETWORK_CONNECTIVITY_CON_POINT("Network Connectivity", "Connection Points", "resourceNewCategory.network connectivity", "resourceNewCategory.network connectivity.connection points"), 
56         NETWORK_CONNECTIVITY_VIRTUAL_LINK("Network Connectivity","Virtual Links", "resourceNewCategory.network connectivity", "resourceNewCategory.network connectivity.virtual links"),
57         
58         TEMPLATE_MONITORING_TEMPLATE("Template", "Monitoring Template", "resourceNewCategory.template", "resourceNewCategory.template.monitoring template"), 
59         
60         ALLOTTED_RESOURCE("Allotted Resource", "Allotted Resource", "resourceNewCategory.allotted resource", "resourceNewCategory.allotted resource.allotted resource"),
61         ALLOTTED_RESOURCE_SERVICE_ADMIN("Allotted Resource", "Service Admin", "resourceNewCategory.allotted resource", "resourceNewCategory.allotted resource.service admin"),
62         ALLOTTED_RESOURCE_CONTRAIL_ROUTE("Allotted Resource", "Contrail Route", "resourceNewCategory.allotted resource", "resourceNewCategory.allotted resource.contrail route"),
63         ALLOTTED_RESOURCE_TUNNEL_XCONNECT("Allotted Resource", "Tunnel XConnect", "resourceNewCategory.allotted resource", "resourceNewCategory.allotted resource.tunnel xconnect"),
64         ALLOTTED_RESOURCE_IP_MUX_DEMUX("Allotted Resource", "IP Mux Demux", "resourceNewCategory.allotted resource", "resourceNewCategory.allotted resource.ip mux demux"),
65         ALLOTTED_RESOURCE_SECURITY_ZONE("Allotted Resource", "Security Zone", "resourceNewCategory.allotted resource", "resourceNewCategory.allotted resource.security zone"),
66         
67         DCAE_COMPONENT_MICROSERVICE("DCAE Component", "Microservice", "resourceNewCategory.dcae component", "resourceNewCategory.dcae component.microservice"),
68         DCAE_COMPONENT_DATABASE("DCAE Component", "Database", "resourceNewCategory.dcae component", "resourceNewCategory.dcae component.database"),
69         DCAE_COMPONENT_POLICY("DCAE Component", "policy", "resourceNewCategory.dcae component", "resourceNewCategory.dcae component.policy"),
70         DCAE_COMPONENT_SOURCE("DCAE Component", "Source", "resourceNewCategory.dcae component", "resourceNewCategory.dcae component.source"),
71         DCAE_COMPONENT_ANALYSTICS("DCAE Component", "Analytics", "resourceNewCategory.dcae component", "resourceNewCategory.dcae component.analytics"),
72         DCAE_COMPONENT_UTILITY("DCAE Component", "Utility", "resourceNewCategory.dcae component", "resourceNewCategory.dcae component.utility"),
73         DCAE_COMPONENT_COLLECTOR("DCAE Component", "Collector", "resourceNewCategory.dcae component", "resourceNewCategory.dcae component.collector"),
74         ;
75         
76         private String category;
77         private String subCategory;
78         private String categoryUniqeId;
79         private String subCategoryUniqeId;
80
81         ResourceCategoryEnum(String category, String subCategory) {
82                 this.category = category;
83                 this.subCategory = subCategory;
84         }
85         
86         private ResourceCategoryEnum(String category, String subCategory, String categoryUniqeId, String subCategoryUniqeId) {
87                 this.category = category;
88                 this.subCategory = subCategory;
89                 this.categoryUniqeId = categoryUniqeId;
90                 this.subCategoryUniqeId = subCategoryUniqeId;
91         }
92
93         public String getCategoryUniqeId() {
94                 return categoryUniqeId;
95         }
96
97         public void setCategoryUniqeId(String categoryUniqeId) {
98                 this.categoryUniqeId = categoryUniqeId;
99         }
100
101         public String getSubCategoryUniqeId() {
102                 return subCategoryUniqeId;
103         }
104
105         public void setSubCategoryUniqeId(String subCategoryUniqeId) {
106                 this.subCategoryUniqeId = subCategoryUniqeId;
107         }
108
109
110         public String getCategory() {
111                 return category;
112         }
113
114         public void setCategory(String category) {
115                 this.category = category;
116         }
117
118         public String getSubCategory() {
119                 return subCategory;
120         }
121
122         public void setSubCategory(String subCategory) {
123                 this.subCategory = subCategory;
124         }
125
126
127         public static ResourceCategoryEnum findEnumNameByValues(String category, String subCategory){
128                 for(ResourceCategoryEnum resourceCategoryEnum : ResourceCategoryEnum.values()) {
129                         if(resourceCategoryEnum.getCategory().equals(category) && resourceCategoryEnum.getSubCategory().equals(subCategory)){
130                                 return resourceCategoryEnum;
131                         }
132                 }
133                 return null;
134         }
135
136
137         /**
138          * @return random category enum except allotted category
139          */
140         public static ResourceCategoryEnum getRandomElement() {
141                 Random random = new Random();
142                 ResourceCategoryEnum resourceCategoryEnum = ResourceCategoryEnum.values()[random.nextInt(ResourceCategoryEnum.values().length)];
143
144                 if(!resourceCategoryEnum.toString().startsWith("ALLOTTED")){
145                         return resourceCategoryEnum;
146                 }else{
147                         return getRandomElement();
148                 }
149         }
150
151
152         /**
153          * @return random  allotted category enum
154          */
155         public static ResourceCategoryEnum getRandomAllottedElement() {
156                 Random random = new Random();
157                 ResourceCategoryEnum resourceCategoryEnum = ResourceCategoryEnum.values()[random.nextInt(ResourceCategoryEnum.values().length)];
158
159                 if(resourceCategoryEnum.toString().startsWith("ALLOTTED")){
160                         return resourceCategoryEnum;
161                 }else{
162                         return getRandomAllottedElement();
163                 }
164         }
165
166 }