Make Service base type optional
[sdc.git] / integration-tests / src / test / java / org / onap / sdc / backend / ci / tests / datatypes / ServiceReqDetails.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.onap.sdc.backend.ci.tests.datatypes;
22
23 import java.util.ArrayList;
24 import java.util.Collections;
25 import lombok.Getter;
26 import lombok.Setter;
27 import org.onap.sdc.backend.ci.tests.datatypes.enums.ServiceInstantiationType;
28 import org.onap.sdc.frontend.ci.tests.datatypes.ModelName;
29 import org.openecomp.sdc.be.model.Service;
30 import org.openecomp.sdc.be.model.category.CategoryDefinition;
31
32 public class ServiceReqDetails extends ComponentReqDetails {
33         
34         protected String serviceType = "MyServiceType";
35         protected String serviceRole = "MyServiceRole";
36         protected String namingPolicy = "MyServiceNamingPolicy";
37         protected Boolean ecompGeneratedNaming = true;
38         protected String instantiationType = ServiceInstantiationType.A_LA_CARTE.getValue();
39         protected String serviceFunction = "";
40         @Getter
41         @Setter
42         private String derivedFromGenericType;
43         @Getter
44         @Setter
45         private String derivedFromGenericVersion;
46
47
48
49         public String getServiceType() {
50                 return serviceType;
51         }
52
53         public void setServiceType(String serviceType) {
54                 this.serviceType = serviceType;
55         }
56         
57         public String getInstantiationType() {
58                 return instantiationType;
59         }
60         
61         public String getServiceRole() {
62                 return serviceRole;
63         }
64
65         public void setServiceRole(String serviceRole) {
66                 this.serviceRole = serviceRole;
67         }
68
69         public String getNamingPolicy() {
70                 return namingPolicy;
71         }
72
73         public void setNamingPolicy(String namingPolicy) {
74                 this.namingPolicy = namingPolicy;
75         }
76
77         public Boolean getEcompGeneratedNaming() {
78                 return ecompGeneratedNaming;
79         }
80
81         public void setEcompGeneratedNaming(Boolean ecompGeneratedNaming) {
82                 this.ecompGeneratedNaming = ecompGeneratedNaming;
83         }
84
85         public String getServiceFunction() {
86                 return serviceFunction;
87         }
88
89         public void setServiceFunction(String serviceFunction) {
90                 this.serviceFunction = serviceFunction;
91         }
92
93         public ServiceReqDetails(String serviceName, String category, ArrayList<String> tags, String description,
94                         String contactId, String icon, String instantiationType) {
95                 this.name = serviceName;
96                 this.tags = tags;
97                 this.description = description;
98                 this.contactId = contactId;
99                 this.icon = icon;
100                 projectCode = "12345";
101                 serviceFunction = "serviceFunction name";
102                 CategoryDefinition categoryDefinition = new CategoryDefinition();
103                 categoryDefinition.setName(category);
104                 categoryDefinition.setIcons(Collections.singletonList(icon));
105                 categories = new ArrayList<>();
106                 categories.add(categoryDefinition);
107                 models.add(ModelName.DEFAULT_MODEL_NAME.getName());
108         }
109
110         public ServiceReqDetails(Service service) {
111                 this.contactId = service.getContactId();
112                 this.categories = service.getCategories();
113                 this.creatorUserId = service.getCreatorUserId();
114                 this.creatorFullName = service.getCreatorFullName();
115                 this.description = service.getDescription();
116                 this.icon = service.getIcon();
117                 this.name = service.getName();
118                 this.projectCode = service.getProjectCode();
119                 this.tags = service.getTags();
120                 this.uniqueId = service.getUniqueId();
121                 this.UUID = service.getUUID();
122                 this.version = service.getVersion();
123                 this.derivedFromGenericType = service.getDerivedFromGenericType();
124                 this.derivedFromGenericVersion = service.getDerivedFromGenericVersion();
125                 this.models = Collections.singletonList(service.getModel());
126         }
127
128         public ServiceReqDetails() {
129                 contactId = "aa1234";
130                 projectCode = "12345";
131         }
132
133         public ServiceReqDetails(ServiceReqDetails a, String newServiceName) {
134                 a.setName(newServiceName);
135         }
136
137         @Override
138         public String toString() {
139                 return "ServiceDetails [name = " + name + ", category = " + getCategory() + ", tags = " + tags + ", description = "
140                                 + description + ", contactId = " + contactId + ", icon = " + icon + ", instantiation type = " + getInstantiationType() + "]";
141         }
142
143         public ServiceReqDetails(ServiceReqDetails aService) {
144                 this(aService.getName(), aService.getCategory(), (ArrayList<String>) aService.getTags(),
145                                 aService.getDescription(), aService.getContactId(), aService.getIcon(), aService.getInstantiationType());
146                 uniqueId = aService.getUniqueId();
147                 version = aService.getVersion();
148         }
149
150         public String getCategory() {
151                 if (categories != null && categories.size() >= 1) {
152                         return categories.get(0).getName();
153                 }
154                 return null;
155         }
156
157 }