[SDC-29] rebase continue work to align source
[sdc.git] / test-apis-ci / src / main / java / org / openecomp / sdc / ci / tests / execute / category / CategoriesTests.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.execute.category;
22
23 import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.PRODUCT_COMPONENT_TYPE;
24 import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.RESOURCE_COMPONENT_TYPE;
25 import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.SERVICE_COMPONENT_TYPE;
26 import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_ALREADY_EXISTS;
27 import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_CREATED;
28 import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_INVALID_CONTENT;
29 import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_MISSING_INFORMATION;
30 import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_RESTRICTED_OPERATION;
31 import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_SUCCESS;
32 import static org.testng.AssertJUnit.assertEquals;
33 import static org.testng.AssertJUnit.assertTrue;
34
35 import java.io.File;
36 import java.util.ArrayList;
37 import java.util.Arrays;
38 import java.util.HashMap;
39 import java.util.List;
40 import java.util.Map;
41
42 import org.apache.commons.lang3.text.WordUtils;
43 import org.apache.http.entity.mime.MultipartEntityBuilder;
44 import org.apache.http.entity.mime.content.FileBody;
45 import org.json.JSONArray;
46 import org.junit.Rule;
47 import org.junit.rules.TestName;
48 import org.openecomp.sdc.be.dao.api.ActionStatus;
49 import org.openecomp.sdc.be.model.User;
50 import org.openecomp.sdc.be.model.category.CategoryDefinition;
51 import org.openecomp.sdc.be.model.category.SubCategoryDefinition;
52 import org.openecomp.sdc.ci.tests.datatypes.enums.ErrorInfo;
53 import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
54 import org.openecomp.sdc.ci.tests.datatypes.expected.ExpectedCategoryAudit;
55 import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
56 import org.openecomp.sdc.ci.tests.utils.DbUtils;
57 import org.openecomp.sdc.ci.tests.utils.Utils;
58 import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
59 import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils;
60 import org.openecomp.sdc.ci.tests.utils.rest.CategoryRestUtils;
61 import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
62 import org.openecomp.sdc.ci.tests.utils.validation.AuditValidationUtils;
63 import org.openecomp.sdc.ci.tests.utils.validation.CategoryValidationUtils;
64 import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils;
65 import org.testng.SkipException;
66 import org.testng.annotations.BeforeMethod;
67 import org.testng.annotations.Test;
68
69 public class CategoriesTests extends CategoriesBaseTest {
70
71         private static final String GET_CATEGORY_HIERARCHY = "GetCategoryHierarchy";
72         protected static final String ADD_CATEGORY = "AddCategory";
73         protected static final String DELETE_CATEGORY = "DeleteCategory";
74
75         public CategoriesTests() {
76                 super(name, CategoriesTests.class.getName());
77         }
78
79         @Rule
80         public static TestName name = new TestName();
81         private CategoryDefinition categoryDefinition;
82         private List<CategoryDefinition> categoryList;
83         private List<SubCategoryDefinition> subCategoryList;
84         private Map<String, List<String>> subCategoriesToDeleteMap;
85
86         @BeforeMethod
87         public void init() throws Exception {
88                 subCategoriesToDeleteMap = new HashMap<String, List<String>>();
89                 DbUtils.deleteFromEsDbByPattern("_all");
90
91                 categoryDefinition = new CategoryDefinition();
92                 categoryDefinition.setName("Abcd");
93                 categoryList = defineCategories();
94                 subCategoryList = defineSubCategories(categoryList.size());
95         }
96
97         // pass
98         @Test
99         public void createServiceCategorySuccessFlow() throws Exception {
100                 // Add New category
101                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
102                                 SERVICE_COMPONENT_TYPE);
103                 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
104                                 createCategotyRest.getErrorCode().intValue());
105                 categoryDefinition.setNormalizedName("abcd");
106                 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
107                 // Audit validation
108                 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
109                                 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
110                 // get service category and validate that category added as defined
111                 // (also set catalog uniqeId)
112                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
113                                 SERVICE_COMPONENT_TYPE);
114                 assertEquals("Check response code after get all categories ", STATUS_CODE_SUCCESS,
115                                 getAllCategoriesRest.getErrorCode().intValue());
116                 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition); // also
117                                                                                                                                                                                                                         // set
118                                                                                                                                                                                                                         // catalog
119                                                                                                                                                                                                                         // uniqeId
120
121         }
122
123         // pass
124         @Test
125         public void createResourceCategorySuccessFlow() throws Exception {
126                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
127                                 RESOURCE_COMPONENT_TYPE);
128                 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
129                                 createCategotyRest.getErrorCode().intValue());
130                 categoryDefinition.setNormalizedName("abcd");
131                 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
132                 // Get Category
133                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
134                                 RESOURCE_COMPONENT_TYPE);
135                 assertEquals("Check response code after get all categories ", STATUS_CODE_SUCCESS,
136                                 getAllCategoriesRest.getErrorCode().intValue());
137                 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
138                 // Audit validation
139                 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
140                                 STATUS_CODE_CREATED, AUDIT_RESOURCE_TYPE);
141         }
142
143         // pass
144         @Test
145         public void createProductCategorySuccessFlow() throws Exception {
146                 // Add Category by Product-strategist
147                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition,
148                                 sdncProductStrategistUserDetails, PRODUCT_COMPONENT_TYPE);
149                 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
150                                 createCategotyRest.getErrorCode().intValue());
151                 categoryDefinition.setNormalizedName("abcd");
152                 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
153
154                 // Get Category
155                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
156                                 PRODUCT_COMPONENT_TYPE);
157                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
158                                 getAllCategoriesRest.getErrorCode().intValue());
159                 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
160                 // Audit validation
161                 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncProductStrategistUserDetails,
162                                 STATUS_CODE_CREATED, AUDIT_PRODUCT_TYPE);
163         }
164
165         @Test
166         public void CategoryNameValidation_FirstWordStartWithAlphaNumeric_01() throws Exception { // category
167                                                                                                                                                                                                 // for
168                                                                                                                                                                                                 // service
169                 categoryDefinition.setName("Category14AadE  &&&---+++.'''###=:@@@____");
170                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
171                                 SERVICE_COMPONENT_TYPE);
172                 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
173                                 createCategotyRest.getErrorCode().intValue());
174                 categoryDefinition.setName("Category14AadE &-+.'#=:@_");
175                 categoryDefinition.setNormalizedName("category14aade &-+.'#=:@_");
176                 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
177                 // Get service category and validate that category added as defined
178                 // (also set catalog uniqeId)
179                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
180                                 SERVICE_COMPONENT_TYPE);
181                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
182                                 getAllCategoriesRest.getErrorCode().intValue());
183                 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
184                 // Audit validation
185                 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
186                                 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
187         }
188
189         @Test
190         public void categoryNameValidation_FirstWordStartWithAlphaNumeric_02() throws Exception { // category
191                                                                                                                                                                                                 // for
192                                                                                                                                                                                                 // resource
193                 categoryDefinition.setName("Category14AadE  &&&---+++.'''###=:@@@____");
194                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
195                                 RESOURCE_COMPONENT_TYPE);
196                 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
197                                 createCategotyRest.getErrorCode().intValue());
198                 categoryDefinition.setName("Category14AadE &-+.'#=:@_");
199                 categoryDefinition.setNormalizedName("category14aade &-+.'#=:@_");
200                 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
201                 // Get service category and validate that category added as defined
202                 // (also set catalog uniqeId)
203                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
204                                 RESOURCE_COMPONENT_TYPE);
205                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
206                                 getAllCategoriesRest.getErrorCode().intValue());
207                 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
208                 // Audit validation
209                 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
210                                 STATUS_CODE_CREATED, AUDIT_RESOURCE_TYPE);
211         }
212
213         @Test
214         public void categoryNameValidation_FirstWordStartWithAlphaNumeric_03() throws Exception { // category
215                                                                                                                                                                                                 // for
216                                                                                                                                                                                                 // resource
217                 categoryDefinition.setName("Category14AadE  &&&---+++.'''###=:@@@____");
218                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition,
219                                 sdncProductStrategistUserDetails, PRODUCT_COMPONENT_TYPE);
220                 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
221                                 createCategotyRest.getErrorCode().intValue());
222                 categoryDefinition.setName("Category14AadE &-+.'#=:@_");
223                 categoryDefinition.setNormalizedName("category14aade &-+.'#=:@_");
224                 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
225                 // Get service category and validate that category added as defined
226                 // (also set catalog uniqeId)
227                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
228                                 PRODUCT_COMPONENT_TYPE);
229                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
230                                 getAllCategoriesRest.getErrorCode().intValue());
231                 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
232                 // Audit validation
233                 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncProductStrategistUserDetails,
234                                 STATUS_CODE_CREATED, AUDIT_PRODUCT_TYPE);
235         }
236
237         // pass
238         @Test
239         public void createServiceCategoryByNonAdminUser() throws Exception {
240                 // Add New category
241                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition,
242                                 sdncProductStrategistUserDetails, SERVICE_COMPONENT_TYPE);
243                 assertEquals("Check response code after create Category", STATUS_CODE_RESTRICTED_OPERATION,
244                                 createCategotyRest.getErrorCode().intValue());
245                 // get service category and validate that category was not added
246                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
247                                 SERVICE_COMPONENT_TYPE);
248                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
249                                 getAllCategoriesRest.getErrorCode().intValue());
250                 CategoryValidationUtils.verifyCategoryNotExistsInGetResponse(getAllCategoriesRest, categoryDefinition);
251                 // Audit validation
252                 AuditValidationUtils.categoryAuditFailure(ADD_CATEGORY, categoryDefinition, sdncProductStrategistUserDetails,
253                                 ActionStatus.RESTRICTED_OPERATION, STATUS_CODE_RESTRICTED_OPERATION, AUDIT_SERVICE_TYPE);
254         }
255
256         // pass
257         @Test
258         public void createResourceCategoryByNonAdminUser() throws Exception {
259                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition,
260                                 sdncProductStrategistUserDetails, RESOURCE_COMPONENT_TYPE);
261                 assertEquals("Check response code after create Category", STATUS_CODE_RESTRICTED_OPERATION,
262                                 createCategotyRest.getErrorCode().intValue());
263                 // get service category and validate that category was not added
264                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
265                                 RESOURCE_COMPONENT_TYPE);
266                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
267                                 getAllCategoriesRest.getErrorCode().intValue());
268                 CategoryValidationUtils.verifyCategoryNotExistsInGetResponse(getAllCategoriesRest, categoryDefinition);
269                 // Audit validation
270                 AuditValidationUtils.categoryAuditFailure(ADD_CATEGORY, categoryDefinition, sdncProductStrategistUserDetails,
271                                 ActionStatus.RESTRICTED_OPERATION, STATUS_CODE_RESTRICTED_OPERATION, AUDIT_RESOURCE_TYPE);
272         }
273
274         // pass
275         @Test
276         public void createProductCategoryByNonProductStrategistUser() throws Exception {
277                 // Add New product category not by Product-Strategist
278                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
279                                 PRODUCT_COMPONENT_TYPE);
280                 assertEquals("Check response code after create Category", STATUS_CODE_RESTRICTED_OPERATION,
281                                 createCategotyRest.getErrorCode().intValue());
282                 // get service category and validate that category was not added
283                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
284                                 PRODUCT_COMPONENT_TYPE);
285                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
286                                 getAllCategoriesRest.getErrorCode().intValue());
287                 CategoryValidationUtils.verifyCategoryNotExistsInGetResponse(getAllCategoriesRest, categoryDefinition);
288                 // Audit validation
289                 AuditValidationUtils.categoryAuditFailure(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
290                                 ActionStatus.RESTRICTED_OPERATION, STATUS_CODE_RESTRICTED_OPERATION, AUDIT_PRODUCT_TYPE);
291
292         }
293
294         // pass
295         @Test
296         public void addCategoryByNonExistingUser() throws Exception {
297                 User sdncAdminUserDetailsNonExisting = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
298                 sdncAdminUserDetailsNonExisting.setUserId("bt555h");
299                 // Add New category
300                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition,
301                                 sdncAdminUserDetailsNonExisting, SERVICE_COMPONENT_TYPE);
302                 assertEquals("Check response code after create Category", STATUS_CODE_RESTRICTED_OPERATION,
303                                 createCategotyRest.getErrorCode().intValue());
304                 // get service category and validate that category was not added
305                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
306                                 SERVICE_COMPONENT_TYPE);
307                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
308                                 getAllCategoriesRest.getErrorCode().intValue());
309                 CategoryValidationUtils.verifyCategoryNotExistsInGetResponse(getAllCategoriesRest, categoryDefinition);
310                 // Audit validation
311                 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name());
312                 ExpectedCategoryAudit expectedCatrgoryAuditJavaObject = new ExpectedCategoryAudit();
313                 expectedCatrgoryAuditJavaObject.setAction(ADD_CATEGORY);
314                 expectedCatrgoryAuditJavaObject.setModifier("(" + sdncAdminUserDetailsNonExisting.getUserId() + ")");
315                 expectedCatrgoryAuditJavaObject.setCategoryName(categoryDefinition.getName());
316                 expectedCatrgoryAuditJavaObject.setSubCategoryName("");
317                 expectedCatrgoryAuditJavaObject.setGroupingName("");
318                 expectedCatrgoryAuditJavaObject.setResourceType(AUDIT_SERVICE_TYPE);
319                 expectedCatrgoryAuditJavaObject.setStatus(String.valueOf(STATUS_CODE_RESTRICTED_OPERATION));
320                 expectedCatrgoryAuditJavaObject.setDesc(errorInfo.getAuditDesc());
321                 AuditValidationUtils.validateCategoryAudit(expectedCatrgoryAuditJavaObject, ADD_CATEGORY);
322         }
323
324         @Test
325         public void addServiceCategoryAllowedcharacters_01() throws Exception {
326                 categoryDefinition.setName("1234AbcdE&");
327                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
328                                 SERVICE_COMPONENT_TYPE);
329                 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
330                                 createCategotyRest.getErrorCode().intValue());
331                 categoryDefinition.setNormalizedName("1234abcde&"); // normalization
332                 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
333                 // Get service category and validate that category added as defined
334                 // (also set catalog uniqeId)
335                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
336                                 SERVICE_COMPONENT_TYPE);
337                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
338                                 getAllCategoriesRest.getErrorCode().intValue());
339                 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
340                 // Audit validation
341                 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
342                                 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
343         }
344
345         @Test
346         public void addServiceCategoryAllowedcharacters_02() throws Exception {
347                 categoryDefinition.setName("1234AbcdE-");
348                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
349                                 SERVICE_COMPONENT_TYPE);
350                 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
351                                 createCategotyRest.getErrorCode().intValue());
352                 categoryDefinition.setNormalizedName("1234abcde-"); // normalization
353                 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
354                 // Get service category and validate that category added as defined
355                 // (also set catalog uniqeId)
356                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
357                                 SERVICE_COMPONENT_TYPE);
358                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
359                                 getAllCategoriesRest.getErrorCode().intValue());
360                 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
361                 // Audit validation
362                 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
363                                 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
364         }
365
366         @Test
367         public void addServiceCategoryAllowedcharacters_03() throws Exception {
368                 categoryDefinition.setName("1234AbcdE+");
369                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
370                                 SERVICE_COMPONENT_TYPE);
371                 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
372                                 createCategotyRest.getErrorCode().intValue());
373                 categoryDefinition.setNormalizedName("1234abcde+"); // normalization
374                 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
375                 // Get service category and validate that category added as defined
376                 // (also set catalog uniqeId)
377                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
378                                 SERVICE_COMPONENT_TYPE);
379                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
380                                 getAllCategoriesRest.getErrorCode().intValue());
381                 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
382                 // Audit validation
383                 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
384                                 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
385         }
386
387         @Test
388         public void addServiceCategoryAllowedcharacters_04() throws Exception {
389                 categoryDefinition.setName("1234AbcdE.");
390                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
391                                 SERVICE_COMPONENT_TYPE);
392                 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
393                                 createCategotyRest.getErrorCode().intValue());
394                 categoryDefinition.setNormalizedName("1234abcde."); // normalization
395                 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
396                 // Get service category and validate that category added as defined
397                 // (also set catalog uniqeId)
398                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
399                                 SERVICE_COMPONENT_TYPE);
400                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
401                                 getAllCategoriesRest.getErrorCode().intValue());
402                 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
403                 // Audit validation
404                 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
405                                 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
406         }
407
408         @Test
409         public void addServiceCategoryAllowedcharacters_05() throws Exception {
410                 categoryDefinition.setName("1234AbcdE'");
411                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
412                                 SERVICE_COMPONENT_TYPE);
413                 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
414                                 createCategotyRest.getErrorCode().intValue());
415                 categoryDefinition.setNormalizedName("1234abcde'");
416                 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
417                 // Get service category and validate that category added as defined
418                 // (also set catalog uniqeId)
419                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
420                                 SERVICE_COMPONENT_TYPE);
421                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
422                                 getAllCategoriesRest.getErrorCode().intValue());
423                 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
424                 // Audit validation
425                 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
426                                 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
427         }
428
429         @Test
430         public void addServiceCategoryAllowedcharacters_06() throws Exception {
431                 categoryDefinition.setName("1234AbcdE=");
432                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
433                                 SERVICE_COMPONENT_TYPE);
434                 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
435                                 createCategotyRest.getErrorCode().intValue());
436                 categoryDefinition.setNormalizedName("1234abcde="); // normalization
437                 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
438                 // Get service category and validate that category added as defined
439                 // (also set catalog uniqeId)
440                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
441                                 SERVICE_COMPONENT_TYPE);
442                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
443                                 getAllCategoriesRest.getErrorCode().intValue());
444                 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
445                 // Audit validation
446                 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
447                                 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
448         }
449
450         @Test
451         public void addServiceCategoryAllowedcharacters_07() throws Exception {
452                 categoryDefinition.setName("1234AbcdE:");
453                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
454                                 SERVICE_COMPONENT_TYPE);
455                 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
456                                 createCategotyRest.getErrorCode().intValue());
457                 categoryDefinition.setNormalizedName("1234abcde:"); // normalization
458                 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
459                 // Get service category and validate that category added as defined
460                 // (also set catalog uniqeId)
461                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
462                                 SERVICE_COMPONENT_TYPE);
463                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
464                                 getAllCategoriesRest.getErrorCode().intValue());
465                 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
466                 // Audit validation
467                 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
468                                 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
469         }
470
471         @Test
472         public void addServiceCategoryAllowedcharacters_08() throws Exception {
473                 categoryDefinition.setName("1234AbcdE@");
474                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
475                                 SERVICE_COMPONENT_TYPE);
476                 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
477                                 createCategotyRest.getErrorCode().intValue());
478                 categoryDefinition.setNormalizedName("1234abcde@"); // normalization
479                 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
480                 // Get service category and validate that category added as defined
481                 // (also set catalog uniqeId)
482                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
483                                 SERVICE_COMPONENT_TYPE);
484                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
485                                 getAllCategoriesRest.getErrorCode().intValue());
486                 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
487                 // Audit validation
488                 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
489                                 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
490         }
491
492         @Test
493         public void addServiceCategoryAllowedcharacters_09() throws Exception {
494                 categoryDefinition.setName("1234AbcdE_");
495                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
496                                 SERVICE_COMPONENT_TYPE);
497                 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
498                                 createCategotyRest.getErrorCode().intValue());
499                 categoryDefinition.setNormalizedName("1234abcde_"); // normalization
500                 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
501                 // Get service category and validate that category added as defined
502                 // (also set catalog uniqeId)
503                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
504                                 SERVICE_COMPONENT_TYPE);
505                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
506                                 getAllCategoriesRest.getErrorCode().intValue());
507                 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
508                 // Audit validation
509                 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
510                                 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
511         }
512
513         @Test
514         public void addServiceCategoryAllowedcharacters_10() throws Exception {
515                 categoryDefinition.setName("1234AbcdE#");
516                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
517                                 SERVICE_COMPONENT_TYPE);
518                 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
519                                 createCategotyRest.getErrorCode().intValue());
520                 categoryDefinition.setNormalizedName("1234abcde#"); // normalization
521                 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
522                 // Get service category and validate that category added as defined
523                 // (also set catalog uniqeId)
524                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
525                                 SERVICE_COMPONENT_TYPE);
526                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
527                                 getAllCategoriesRest.getErrorCode().intValue());
528                 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
529                 // Audit validation
530                 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
531                                 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
532         }
533
534         @Test
535         public void addServiceCategoryAllowedcharacters_11() throws Exception {
536                 categoryDefinition.setName("1234AbcdE d");
537                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
538                                 SERVICE_COMPONENT_TYPE);
539                 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
540                                 createCategotyRest.getErrorCode().intValue());
541                 categoryDefinition.setNormalizedName("1234abcde d"); // normalization
542                 categoryDefinition.setName("1234AbcdE D");
543                 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
544                 // Get service category and validate that category added as defined
545                 // (also set catalog uniqeId)
546                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
547                                 SERVICE_COMPONENT_TYPE);
548                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
549                                 getAllCategoriesRest.getErrorCode().intValue());
550                 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
551                 // Audit validation
552                 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
553                                 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
554         }
555
556         @Test
557         public void addServiceCategoryAllowedcharacters_12() throws Exception {
558                 categoryDefinition.setName("1234AbcdE   &_=+.-'#:@ d");
559                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
560                                 SERVICE_COMPONENT_TYPE);
561                 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
562                                 createCategotyRest.getErrorCode().intValue());
563                 categoryDefinition.setNormalizedName("1234abcde &_=+.-'#:@ d"); // normalization
564                 categoryDefinition.setName("1234AbcdE &_=+.-'#:@ D");
565                 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
566                 // Get service category and validate that category added as defined
567                 // (also set catalog uniqeId)
568                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
569                                 SERVICE_COMPONENT_TYPE);
570                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
571                                 getAllCategoriesRest.getErrorCode().intValue());
572                 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
573                 // Audit validation
574                 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
575                                 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
576         }
577
578         @Test
579         public void categoryNameValidation_RemoveSpaceFromBeginning() throws Exception {
580                 categoryDefinition.setName("  Category01");
581                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
582                                 SERVICE_COMPONENT_TYPE);
583                 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
584                                 createCategotyRest.getErrorCode().intValue());
585                 categoryDefinition.setNormalizedName("category01"); // normalization
586                 categoryDefinition.setName("Category01");
587                 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
588                 // Get service category and validate that category added as defined
589                 // (also set catalog uniqeId)
590                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
591                                 SERVICE_COMPONENT_TYPE);
592                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
593                                 getAllCategoriesRest.getErrorCode().intValue());
594                 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
595                 // Audit validation
596                 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
597                                 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
598         }
599
600         @Test
601         public void categoryNameValidation_RemoveSpaceFromEnd() throws Exception {
602                 categoryDefinition.setName("Category01    ");
603                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
604                                 SERVICE_COMPONENT_TYPE);
605                 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
606                                 createCategotyRest.getErrorCode().intValue());
607                 categoryDefinition.setNormalizedName("category01"); // normalization
608                 categoryDefinition.setName("Category01");
609                 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
610                 // Get service category and validate that category added as defined
611                 // (also set catalog uniqeId)
612                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
613                                 SERVICE_COMPONENT_TYPE);
614                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
615                                 getAllCategoriesRest.getErrorCode().intValue());
616                 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
617                 // Audit validation
618                 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
619                                 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
620         }
621
622         @Test
623         public void categoryNameValidation_RemoveExtraSpace() throws Exception {
624                 categoryDefinition.setName("Category    02");
625                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
626                                 SERVICE_COMPONENT_TYPE);
627                 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
628                                 createCategotyRest.getErrorCode().intValue());
629                 categoryDefinition.setNormalizedName("category 02"); // normalization
630                 categoryDefinition.setName("Category 02");
631                 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
632                 // Get service category and validate that category added as defined
633                 // (also set catalog uniqeId)
634                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
635                                 SERVICE_COMPONENT_TYPE);
636                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
637                                 getAllCategoriesRest.getErrorCode().intValue());
638                 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
639                 // Audit validation
640                 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
641                                 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
642         }
643
644         @Test
645         public void categoryNameValidation_RemoveExtraAmpersand() throws Exception {
646                 categoryDefinition.setName("Category&& &02");
647                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
648                                 SERVICE_COMPONENT_TYPE);
649                 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
650                                 createCategotyRest.getErrorCode().intValue());
651                 categoryDefinition.setNormalizedName("category& &02"); // normalization
652                 categoryDefinition.setName("Category& &02");
653                 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
654                 // Get service category and validate that category added as defined
655                 // (also set catalog uniqeId)
656                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
657                                 SERVICE_COMPONENT_TYPE);
658                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
659                                 getAllCategoriesRest.getErrorCode().intValue());
660                 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
661                 // Audit validation
662                 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
663                                 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
664         }
665
666         @Test
667         public void categoryNameValidation_RemoveExtraDash() throws Exception {
668                 categoryDefinition.setName("CategorY-- --02");
669                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
670                                 SERVICE_COMPONENT_TYPE);
671                 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
672                                 createCategotyRest.getErrorCode().intValue());
673                 categoryDefinition.setName("CategorY- -02");
674                 categoryDefinition.setNormalizedName("category- -02");
675                 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
676                 // Get service category and validate that category added as defined
677                 // (also set catalog uniqeId)
678                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
679                                 SERVICE_COMPONENT_TYPE);
680                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
681                                 getAllCategoriesRest.getErrorCode().intValue());
682                 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
683                 // Audit validation
684                 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
685                                 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
686         }
687
688         @Test
689         public void categoryNameValidation_RemoveExtraPlus() throws Exception {
690                 categoryDefinition.setName("CateGory++++ +02");
691                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
692                                 SERVICE_COMPONENT_TYPE);
693                 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
694                                 createCategotyRest.getErrorCode().intValue());
695                 categoryDefinition.setName("CateGory+ +02");
696                 categoryDefinition.setNormalizedName("category+ +02");
697                 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
698                 // Get service category and validate that category added as defined
699                 // (also set catalog uniqeId)
700                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
701                                 SERVICE_COMPONENT_TYPE);
702                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
703                                 getAllCategoriesRest.getErrorCode().intValue());
704                 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
705                 // Audit validation
706                 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
707                                 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
708         }
709
710         @Test
711         public void categoryNameValidation_RemoveExtraPeriod() throws Exception {
712                 categoryDefinition.setName("Category.... .02");
713                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
714                                 SERVICE_COMPONENT_TYPE);
715                 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
716                                 createCategotyRest.getErrorCode().intValue());
717                 categoryDefinition.setName("Category. .02");
718                 categoryDefinition.setNormalizedName("category. .02");
719                 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
720                 // Get service category and validate that category added as defined
721                 // (also set catalog uniqeId)
722                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
723                                 SERVICE_COMPONENT_TYPE);
724                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
725                                 getAllCategoriesRest.getErrorCode().intValue());
726                 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
727                 // Audit validation
728                 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
729                                 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
730         }
731
732         @Test
733         public void categoryNameValidation_RemoveExtraApostrophe() throws Exception {
734                 categoryDefinition.setName("CaTegory''' '02");
735                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
736                                 SERVICE_COMPONENT_TYPE);
737                 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
738                                 createCategotyRest.getErrorCode().intValue());
739                 categoryDefinition.setName("CaTegory' '02");
740                 categoryDefinition.setNormalizedName("category' '02");
741                 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
742                 // Get service category and validate that category added as defined
743                 // (also set catalog uniqeId)
744                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
745                                 SERVICE_COMPONENT_TYPE);
746                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
747                                 getAllCategoriesRest.getErrorCode().intValue());
748                 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
749                 // Audit validation
750                 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
751                                 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
752         }
753
754         @Test
755         public void categoryNameValidation_RemoveExtraHashtag() throws Exception {
756                 categoryDefinition.setName("Category### #02");
757                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
758                                 SERVICE_COMPONENT_TYPE);
759                 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
760                                 createCategotyRest.getErrorCode().intValue());
761                 categoryDefinition.setName("Category# #02");
762                 categoryDefinition.setNormalizedName("category# #02");
763                 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
764                 // Get service category and validate that category added as defined
765                 // (also set catalog uniqeId)
766                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
767                                 SERVICE_COMPONENT_TYPE);
768                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
769                                 getAllCategoriesRest.getErrorCode().intValue());
770                 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
771                 // Audit validation
772                 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
773                                 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
774         }
775
776         @Test
777         public void categoryNameValidation_RemoveExtrEequal() throws Exception {
778                 categoryDefinition.setName("Category=== =02");
779                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
780                                 SERVICE_COMPONENT_TYPE);
781                 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
782                                 createCategotyRest.getErrorCode().intValue());
783                 categoryDefinition.setName("Category= =02");
784                 categoryDefinition.setNormalizedName("category= =02");
785                 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
786                 // Get service category and validate that category added as defined
787                 // (also set catalog uniqeId)
788                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
789                                 SERVICE_COMPONENT_TYPE);
790                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
791                                 getAllCategoriesRest.getErrorCode().intValue());
792                 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
793                 // Audit validation
794                 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
795                                 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
796         }
797
798         @Test
799         public void categoryNameValidation_RemoveExtrColon() throws Exception {
800                 categoryDefinition.setName("Category::: :02");
801                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
802                                 SERVICE_COMPONENT_TYPE);
803                 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
804                                 createCategotyRest.getErrorCode().intValue());
805                 categoryDefinition.setName("Category: :02");
806                 categoryDefinition.setNormalizedName("category: :02");
807                 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
808                 // Get service category and validate that category added as defined
809                 // (also set catalog uniqeId)
810                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
811                                 SERVICE_COMPONENT_TYPE);
812                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
813                                 getAllCategoriesRest.getErrorCode().intValue());
814                 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
815                 // Audit validation
816                 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
817                                 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
818         }
819
820         @Test
821         public void categoryNameValidation_RemoveExtrAt() throws Exception {
822                 categoryDefinition.setName("Category@@@ @a2");
823                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
824                                 SERVICE_COMPONENT_TYPE);
825                 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
826                                 createCategotyRest.getErrorCode().intValue());
827                 categoryDefinition.setName("Category@ @a2");
828                 categoryDefinition.setNormalizedName("category@ @a2");
829                 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
830                 // Get service category and validate that category added as defined
831                 // (also set catalog uniqeId)
832                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
833                                 SERVICE_COMPONENT_TYPE);
834                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
835                                 getAllCategoriesRest.getErrorCode().intValue());
836                 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
837                 // Audit validation
838                 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
839                                 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
840         }
841
842         @Test
843         public void categoryNameValidation_RemoveExtraUnderscore() throws Exception {
844                 categoryDefinition.setName("Category___ _22");
845                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
846                                 SERVICE_COMPONENT_TYPE);
847                 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
848                                 createCategotyRest.getErrorCode().intValue());
849                 categoryDefinition.setName("Category_ _22");
850                 categoryDefinition.setNormalizedName("category_ _22");
851                 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
852                 // Get service category and validate that category added as defined
853                 // (also set catalog uniqeId)
854                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
855                                 SERVICE_COMPONENT_TYPE);
856                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
857                                 getAllCategoriesRest.getErrorCode().intValue());
858                 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
859                 // Audit validation
860                 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
861                                 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
862         }
863
864         @Test
865         public void categoryNameValidation_FirstWordStartWithNumber() throws Exception {
866                 categoryDefinition.setName("1Category one");
867                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
868                                 SERVICE_COMPONENT_TYPE);
869                 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
870                                 createCategotyRest.getErrorCode().intValue());
871                 categoryDefinition.setName("1Category One");
872                 categoryDefinition.setNormalizedName("1category one");
873                 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
874                 // Get service category and validate that category added as defined
875                 // (also set catalog uniqeId)
876                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
877                                 SERVICE_COMPONENT_TYPE);
878                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
879                                 getAllCategoriesRest.getErrorCode().intValue());
880                 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
881                 // Audit validation
882                 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
883                                 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
884         }
885
886         @Test
887         public void categoryNameValidation_FirstWordStartWithNonAlphaNumeric() throws Exception { // The
888                                                                                                                                                                                                 // first
889                                                                                                                                                                                                 // word
890                                                                                                                                                                                                 // must
891                                                                                                                                                                                                 // start
892                                                                                                                                                                                                 // with
893                                                                                                                                                                                                 // an
894                                                                                                                                                                                                 // alpha-numeric
895                                                                                                                                                                                                 // character
896                                                                                                                                                                                                 // [a-Z
897                                                                                                                                                                                                 // A..Z,
898                                                                                                                                                                                                 // 0..9]
899                 char invalidChars[] = { '&', '-', '+', '.', '\'', '#', '=', ':', '@', '_' };
900                 for (int i = 0; i < invalidChars.length; i++) {
901                         DbUtils.deleteFromEsDbByPattern("_all");
902                         categoryDefinition.setName(invalidChars[i] + "AbcD123");
903                         categoryDefinition.setNormalizedName((invalidChars[i] + "AbcD123").toLowerCase());
904                         RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition,
905                                         sdncAdminUserDetails1, SERVICE_COMPONENT_TYPE);
906                         assertEquals("Check response code after create Category", STATUS_CODE_INVALID_CONTENT,
907                                         createCategotyRest.getErrorCode().intValue());
908
909                         // get service category and validate that category was not added
910                         RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
911                                         SERVICE_COMPONENT_TYPE);
912                         assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
913                                         getAllCategoriesRest.getErrorCode().intValue());
914                         CategoryValidationUtils.verifyCategoryNotExistsInGetResponse(getAllCategoriesRest, categoryDefinition);
915                         // Audit validation
916                         AuditValidationUtils.categoryAuditFailure(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails1,
917                                         ActionStatus.COMPONENT_ELEMENT_INVALID_NAME_FORMAT, STATUS_CODE_INVALID_CONTENT, AUDIT_SERVICE_TYPE,
918                                         "Service", "category");
919
920                 }
921         }
922
923         @Test
924         public void addServiceCategoryAlreadyExist_uniqueness() throws Exception { // Verify
925                                                                                                                                                                 // category
926                                                                                                                                                                 // name
927                                                                                                                                                                 // duplication
928                                                                                                                                                                 // ("uniqueness")
929                                                                                                                                                                 // as
930                                                                                                                                                                 // non-case-sensitive,
931                                                                                                                                                                 // so
932                                                                                                                                                                 // we
933                                                                                                                                                                 // don’t
934                                                                                                                                                                 // create
935                                                                                                                                                                 // duplicate
936                                                                                                                                                                 // names
937                                                                                                                                                                 // with
938                                                                                                                                                                 // upper/lower
939                                                                                                                                                                 // case
940                                                                                                                                                                 // inconsistency.
941                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
942                                 SERVICE_COMPONENT_TYPE);
943                 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
944                                 createCategotyRest.getErrorCode().intValue());
945                 categoryDefinition.setNormalizedName("abcd");
946                 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
947                 // get service category and validate that category added as defined
948                 // (also set catalog uniqeId)
949                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
950                                 SERVICE_COMPONENT_TYPE);
951                 assertEquals("Check response code after get all categories ", STATUS_CODE_SUCCESS,
952                                 getAllCategoriesRest.getErrorCode().intValue());
953                 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition); // also
954                                                                                                                                                                                                                         // set
955                                                                                                                                                                                                                         // catalog
956                                                                                                                                                                                                                         // uniqeId
957                 // Audit validation
958                 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
959                                 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
960                 // Create same category name again
961                 DbUtils.deleteFromEsDbByPattern("_all");
962                 CategoryDefinition categoryDataDefinition2 = new CategoryDefinition();
963                 categoryDataDefinition2.setName(categoryDefinition.getName());
964                 RestResponse addDuplicateCategoryRest = CategoryRestUtils.createCategory(categoryDataDefinition2,
965                                 sdncAdminUserDetails, SERVICE_COMPONENT_TYPE);
966                 assertEquals("Check response code after create Category", STATUS_CODE_ALREADY_EXISTS,
967                                 addDuplicateCategoryRest.getErrorCode().intValue());
968                 // Audit validation
969                 AuditValidationUtils.categoryAuditFailure(ADD_CATEGORY, categoryDataDefinition2, sdncAdminUserDetails,
970                                 ActionStatus.COMPONENT_CATEGORY_ALREADY_EXISTS, STATUS_CODE_ALREADY_EXISTS, AUDIT_SERVICE_TYPE,
971                                 "Service", categoryDefinition.getName());
972                 // Get Category and verify that category was created is not deleted
973                 getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails, SERVICE_COMPONENT_TYPE);
974                 assertEquals("Check response code after get all categories ", STATUS_CODE_SUCCESS,
975                                 getAllCategoriesRest.getErrorCode().intValue());
976                 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
977
978         }
979
980         @Test
981         public void categoryNameValidation_ReplaceAndWithAmpersand_01() throws Exception {
982                 categoryDefinition.setName("At and T");
983                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
984                                 SERVICE_COMPONENT_TYPE);
985                 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
986                                 createCategotyRest.getErrorCode().intValue());
987                 categoryDefinition.setName("At & T");
988                 categoryDefinition.setNormalizedName("at & t");
989                 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
990                 // Get service category and validate that category added as defined
991                 // (also set catalog uniqeId)
992                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
993                                 SERVICE_COMPONENT_TYPE);
994                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
995                                 getAllCategoriesRest.getErrorCode().intValue());
996                 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
997                 // Audit validation
998                 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
999                                 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1000         }
1001
1002         @Test
1003         public void categoryNameValidation_ReplaceAndWithAmpersand_02() throws Exception {
1004                 categoryDefinition.setName("At and t");
1005                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
1006                                 SERVICE_COMPONENT_TYPE);
1007                 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1008                                 createCategotyRest.getErrorCode().intValue());
1009                 categoryDefinition.setName("At & T");
1010                 categoryDefinition.setNormalizedName("at & t");
1011                 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1012                 // Get service category and validate that category added as defined
1013                 // (also set catalog uniqeId)
1014                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1015                                 SERVICE_COMPONENT_TYPE);
1016                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1017                                 getAllCategoriesRest.getErrorCode().intValue());
1018                 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1019                 // Audit validation
1020                 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1021                                 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1022         }
1023
1024         @Test
1025         public void categoryNameValidation_ReplaceAndWithAmpersand_03() throws Exception {
1026                 categoryDefinition.setName("Atand T");
1027                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
1028                                 SERVICE_COMPONENT_TYPE);
1029                 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1030                                 createCategotyRest.getErrorCode().intValue());
1031                 categoryDefinition.setNormalizedName("atand t");
1032                 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1033                 // Get service category and validate that category added as defined
1034                 // (also set catalog uniqeId)
1035                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1036                                 SERVICE_COMPONENT_TYPE);
1037                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1038                                 getAllCategoriesRest.getErrorCode().intValue());
1039                 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1040                 // Audit validation
1041                 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1042                                 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1043         }
1044
1045         @Test
1046         public void categoryNameValidation_ReplaceAndWithAmpersand_04() throws Exception {
1047                 categoryDefinition.setName("At andT");
1048                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
1049                                 SERVICE_COMPONENT_TYPE);
1050                 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1051                                 createCategotyRest.getErrorCode().intValue());
1052                 categoryDefinition.setNormalizedName("at andt");
1053                 categoryDefinition.setName("At AndT");
1054                 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1055                 // Get service category and validate that category added as defined
1056                 // (also set catalog uniqeId)
1057                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1058                                 SERVICE_COMPONENT_TYPE);
1059                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1060                                 getAllCategoriesRest.getErrorCode().intValue());
1061                 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1062                 // Audit validation
1063                 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1064                                 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1065         }
1066
1067         @Test
1068         public void categoryNameValidation_ReplaceAndWithAmpersand_05() throws Exception {
1069                 categoryDefinition.setName(" and AttT");
1070                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
1071                                 SERVICE_COMPONENT_TYPE);
1072                 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1073                                 createCategotyRest.getErrorCode().intValue());
1074                 categoryDefinition.setNormalizedName("and attt");
1075                 categoryDefinition.setName("And AttT");
1076                 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1077                 // Get service category and validate that category added as defined
1078                 // (also set catalog uniqeId)
1079                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1080                                 SERVICE_COMPONENT_TYPE);
1081                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1082                                 getAllCategoriesRest.getErrorCode().intValue());
1083                 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1084                 // Audit validation
1085                 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1086                                 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1087         }
1088
1089         @Test
1090         public void categoryNameValidation_ReplaceAndWithAmpersand_06() throws Exception {
1091                 categoryDefinition.setName("AttT and ");
1092                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
1093                                 SERVICE_COMPONENT_TYPE);
1094                 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1095                                 createCategotyRest.getErrorCode().intValue());
1096                 categoryDefinition.setNormalizedName("attt and");
1097                 categoryDefinition.setName("AttT And");
1098                 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1099                 // Get service category and validate that category added as defined
1100                 // (also set catalog uniqeId)
1101                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1102                                 SERVICE_COMPONENT_TYPE);
1103                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1104                                 getAllCategoriesRest.getErrorCode().intValue());
1105                 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1106                 // Audit validation
1107                 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1108                                 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1109         }
1110
1111         // Bug
1112         @Test
1113         public void categoryNameValidation_ReplaceAndWithAmpersand_07() throws Exception {
1114                 categoryDefinition.setName(" and a");
1115                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
1116                                 SERVICE_COMPONENT_TYPE);
1117                 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1118                                 createCategotyRest.getErrorCode().intValue());
1119                 categoryDefinition.setNormalizedName("and a");
1120                 categoryDefinition.setName("And a");
1121                 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1122                 // Get service category and validate that category added as defined
1123                 // (also set catalog uniqeId)
1124                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1125                                 SERVICE_COMPONENT_TYPE);
1126                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1127                                 getAllCategoriesRest.getErrorCode().intValue());
1128                 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1129                 // Audit validation
1130                 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1131                                 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1132         }
1133
1134         @Test
1135         public void categoryNameValidationMaxLength() throws Exception {
1136                 categoryDefinition.setName("AsdfghjQ234567890@#.&:+-_");
1137                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
1138                                 SERVICE_COMPONENT_TYPE);
1139                 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1140                                 createCategotyRest.getErrorCode().intValue());
1141                 categoryDefinition.setNormalizedName("asdfghjq234567890@#.&:+-_");
1142                 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1143                 // Get service category and validate that category added as defined
1144                 // (also set catalog uniqeId)
1145                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1146                                 SERVICE_COMPONENT_TYPE);
1147                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1148                                 getAllCategoriesRest.getErrorCode().intValue());
1149                 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1150                 // Audit validation
1151                 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1152                                 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1153
1154         }
1155
1156         @Test
1157         public void categoryNameValidationMaxLengthAfterNormalization() throws Exception {
1158                 categoryDefinition.setName("  A jQ234 @@@___ +++ At and T and and ");
1159                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
1160                                 SERVICE_COMPONENT_TYPE);
1161                 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1162                                 createCategotyRest.getErrorCode().intValue());
1163                 categoryDefinition.setName("A JQ234 @_ + At & T & And");
1164                 categoryDefinition.setNormalizedName("a jq234 @_ + at & t & and");
1165                 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1166                 // Get service category and validate that category added as defined
1167                 // (also set catalog uniqeId)
1168                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1169                                 SERVICE_COMPONENT_TYPE);
1170                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1171                                 getAllCategoriesRest.getErrorCode().intValue());
1172                 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1173                 // Audit validation
1174                 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1175                                 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1176
1177         }
1178
1179         @Test
1180         public void categoryNameValidationExceedMaxLengthAfterNormalization() throws Exception {
1181                 categoryDefinition.setName("  AbdfghBCVa jQ234 @@___ +++ At and T   ");
1182                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
1183                                 SERVICE_COMPONENT_TYPE);
1184                 assertEquals("Check response code after create Category", STATUS_CODE_INVALID_CONTENT,
1185                                 createCategotyRest.getErrorCode().intValue());
1186                 categoryDefinition.setNormalizedName("abdfghbcva jq234 @_ + at&t");
1187                 // get service category and validate that category was not added
1188                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1189                                 SERVICE_COMPONENT_TYPE);
1190                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1191                                 getAllCategoriesRest.getErrorCode().intValue());
1192                 CategoryValidationUtils.verifyCategoryNotExistsInGetResponse(getAllCategoriesRest, categoryDefinition);
1193                 // Audit validation
1194                 AuditValidationUtils.categoryAuditFailure(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1195                                 ActionStatus.COMPONENT_ELEMENT_INVALID_NAME_LENGTH, STATUS_CODE_INVALID_CONTENT, AUDIT_SERVICE_TYPE,
1196                                 "Service", "category");
1197         }
1198
1199         @Test
1200         public void categoryNameValidationMinLengthAfterNormalization() throws Exception { // MinLengthAfterNormalization
1201                                                                                                                                                                                 // =
1202                                                                                                                                                                                 // 4
1203                                                                                                                                                                                 // characters
1204                 categoryDefinition.setName("  At and  T   ");
1205                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
1206                                 SERVICE_COMPONENT_TYPE);
1207                 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1208                                 createCategotyRest.getErrorCode().intValue());
1209                 categoryDefinition.setName("At & T");
1210                 categoryDefinition.setNormalizedName("at & t");
1211                 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1212                 // Get service category and validate that category added as defined
1213                 // (also set catalog uniqeId)
1214                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1215                                 SERVICE_COMPONENT_TYPE);
1216                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1217                                 getAllCategoriesRest.getErrorCode().intValue());
1218                 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1219                 // Audit validation
1220                 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1221                                 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1222         }
1223
1224         @Test
1225         public void categoryNameValidationLessThanMinLengthAfterNormalization() throws Exception {
1226                 categoryDefinition.setName("  A&&&&&&&&&&&&&&&&&T   ");
1227                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
1228                                 SERVICE_COMPONENT_TYPE);
1229                 assertEquals("Check response code after create Category", STATUS_CODE_INVALID_CONTENT,
1230                                 createCategotyRest.getErrorCode().intValue());
1231                 categoryDefinition.setNormalizedName("a&t");
1232                 // get service category and validate that category was not added
1233                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1234                                 SERVICE_COMPONENT_TYPE);
1235                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1236                                 getAllCategoriesRest.getErrorCode().intValue());
1237                 CategoryValidationUtils.verifyCategoryNotExistsInGetResponse(getAllCategoriesRest, categoryDefinition);
1238                 // Audit validation
1239                 AuditValidationUtils.categoryAuditFailure(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1240                                 ActionStatus.COMPONENT_ELEMENT_INVALID_NAME_LENGTH, STATUS_CODE_INVALID_CONTENT, AUDIT_SERVICE_TYPE,
1241                                 "Service", "category");
1242         }
1243
1244         @Test
1245         public void categoryNameValidationIsNull() throws Exception {
1246                 categoryDefinition.setName(null);
1247                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
1248                                 SERVICE_COMPONENT_TYPE);
1249                 assertEquals("Check response code after create Category", STATUS_CODE_INVALID_CONTENT,
1250                                 createCategotyRest.getErrorCode().intValue());
1251                 // get service category and validate that category was not added
1252                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1253                                 SERVICE_COMPONENT_TYPE);
1254                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1255                                 getAllCategoriesRest.getErrorCode().intValue());
1256                 CategoryValidationUtils.verifyCategoryNotExistsInGetResponse(getAllCategoriesRest, categoryDefinition);
1257                 // Audit validation
1258                 AuditValidationUtils.categoryAuditFailure(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1259                                 ActionStatus.COMPONENT_ELEMENT_INVALID_NAME_LENGTH, STATUS_CODE_INVALID_CONTENT, AUDIT_SERVICE_TYPE,
1260                                 "Service", "category");
1261         }
1262
1263         @Test
1264         public void categoryNameValidationIsEmpty() throws Exception {
1265                 categoryDefinition.setName("");
1266                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
1267                                 SERVICE_COMPONENT_TYPE);
1268                 assertEquals("Check response code after create Category", STATUS_CODE_INVALID_CONTENT,
1269                                 createCategotyRest.getErrorCode().intValue());
1270                 categoryDefinition.setNormalizedName("");
1271                 // get service category and validate that category was not added
1272                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1273                                 SERVICE_COMPONENT_TYPE);
1274                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1275                                 getAllCategoriesRest.getErrorCode().intValue());
1276                 CategoryValidationUtils.verifyCategoryNotExistsInGetResponse(getAllCategoriesRest, categoryDefinition);
1277                 // Audit validation
1278                 AuditValidationUtils.categoryAuditFailure(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1279                                 ActionStatus.COMPONENT_ELEMENT_INVALID_NAME_FORMAT, STATUS_CODE_INVALID_CONTENT, AUDIT_SERVICE_TYPE,
1280                                 "Service", "category");
1281         }
1282
1283         @Test
1284         public void categoryNameValidationInvalidCharacters() throws Exception {
1285                 char invalidChars[] = { '~', '!', '$', '%', '^', '*', '(', ')', '"', '{', '}', '[', ']', '?', '>', '<', '/',
1286                                 '|', '\\', ',' };
1287                 for (int i = 0; i < invalidChars.length; i++) {
1288                         DbUtils.deleteFromEsDbByPattern("_all");
1289                         // DbUtils.cleanAllAudits();
1290                         categoryDefinition.setName("AbcD123" + invalidChars[i]);
1291                         RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
1292                                         SERVICE_COMPONENT_TYPE);
1293                         assertEquals("Check response code after create Category", STATUS_CODE_INVALID_CONTENT,
1294                                         createCategotyRest.getErrorCode().intValue());
1295                         categoryDefinition.setNormalizedName("");
1296                         // get service category and validate that category was not added
1297                         RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1298                                         SERVICE_COMPONENT_TYPE);
1299                         assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1300                                         getAllCategoriesRest.getErrorCode().intValue());
1301                         CategoryValidationUtils.verifyCategoryNotExistsInGetResponse(getAllCategoriesRest, categoryDefinition);
1302                         // Audit validation
1303                         AuditValidationUtils.categoryAuditFailure(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1304                                         ActionStatus.COMPONENT_ELEMENT_INVALID_NAME_FORMAT, STATUS_CODE_INVALID_CONTENT, AUDIT_SERVICE_TYPE,
1305                                         "Service", "category");
1306                 }
1307         }
1308
1309         @Test
1310         public void categoryNameValidationSameNameDifferentResourceType() throws Exception { // same
1311                                                                                                                                                                                         // Catalog
1312                                                                                                                                                                                         // Name
1313                                                                                                                                                                                         // for
1314                                                                                                                                                                                         // service/resource/product
1315                                                                                                                                                                                         // is
1316                                                                                                                                                                                         // allowed
1317                 String name = ("Abcd");
1318                 CategoryDefinition categoryDataDefinition1 = new CategoryDefinition();
1319                 CategoryDefinition categoryDataDefinition2 = new CategoryDefinition();
1320                 CategoryDefinition categoryDataDefinition3 = new CategoryDefinition();
1321                 categoryDataDefinition1.setName(name);
1322                 categoryDataDefinition2.setName(name);
1323                 categoryDataDefinition3.setName(name);
1324                 // CREATE CATEGORY FOR SERVICE
1325                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDataDefinition1,
1326                                 sdncAdminUserDetails, SERVICE_COMPONENT_TYPE);
1327                 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1328                                 createCategotyRest.getErrorCode().intValue());
1329                 categoryDataDefinition1.setNormalizedName("abcd");
1330                 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDataDefinition1);
1331                 // get service category and validate that category added as defined
1332                 // (also set catalog uniqeId)
1333                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1334                                 SERVICE_COMPONENT_TYPE);
1335                 assertEquals("Check response code after get all categories ", STATUS_CODE_SUCCESS,
1336                                 getAllCategoriesRest.getErrorCode().intValue());
1337                 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDataDefinition1); // also
1338                                                                                                                                                                                                                                         // set
1339                                                                                                                                                                                                                                         // catalog
1340                                                                                                                                                                                                                                         // uniqeId
1341                 // Audit validation
1342                 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDataDefinition1, sdncAdminUserDetails,
1343                                 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1344                 // CREATE CATEGORY FOR RESOURCE_COMPONENT_TYPE
1345                 DbUtils.deleteFromEsDbByPattern("_all");
1346                 createCategotyRest = CategoryRestUtils.createCategory(categoryDataDefinition2, sdncAdminUserDetails,
1347                                 RESOURCE_COMPONENT_TYPE);
1348                 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1349                                 createCategotyRest.getErrorCode().intValue());
1350                 categoryDataDefinition2.setNormalizedName("abcd");
1351                 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDataDefinition2);
1352                 // Get Category
1353                 getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails, RESOURCE_COMPONENT_TYPE);
1354                 assertEquals("Check response code after get all categories ", STATUS_CODE_SUCCESS,
1355                                 getAllCategoriesRest.getErrorCode().intValue());
1356                 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDataDefinition2);
1357                 // Audit validation
1358                 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDataDefinition2, sdncAdminUserDetails,
1359                                 STATUS_CODE_CREATED, AUDIT_RESOURCE_TYPE);
1360                 // CREATE CATEGORY FOR PRODUCT
1361                 DbUtils.deleteFromEsDbByPattern("_all");
1362                 RestResponse addCategotyRest = CategoryRestUtils.createCategory(categoryDataDefinition3,
1363                                 sdncProductStrategistUserDetails, PRODUCT_COMPONENT_TYPE);
1364                 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1365                                 addCategotyRest.getErrorCode().intValue());
1366                 categoryDataDefinition3.setNormalizedName("abcd");
1367                 CategoryValidationUtils.validateCreateCategoryResponse(addCategotyRest, categoryDataDefinition3);
1368
1369                 // Get Category
1370                 getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails, PRODUCT_COMPONENT_TYPE);
1371                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1372                                 getAllCategoriesRest.getErrorCode().intValue());
1373                 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDataDefinition3);
1374                 // Audit validation
1375                 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncProductStrategistUserDetails,
1376                                 STATUS_CODE_CREATED, AUDIT_PRODUCT_TYPE);
1377         }
1378
1379         @Test
1380         public void categoryNameValidationFirstLetterOfKeyWordsCapitalized() throws Exception { // First
1381                                                                                                                                                                                         // letter
1382                                                                                                                                                                                         // of
1383                                                                                                                                                                                         // key
1384                                                                                                                                                                                         // words
1385                                                                                                                                                                                         // are
1386                                                                                                                                                                                         // capitalized
1387                 categoryDefinition.setName("beNNy shaY michEl");
1388                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
1389                                 SERVICE_COMPONENT_TYPE);
1390                 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1391                                 createCategotyRest.getErrorCode().intValue());
1392                 categoryDefinition.setName("BeNNy ShaY MichEl");
1393                 categoryDefinition.setNormalizedName("benny shay michel");
1394                 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1395                 // Get service category and validate that category added as defined
1396                 // (also set catalog uniqeId)
1397                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1398                                 SERVICE_COMPONENT_TYPE);
1399                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1400                                 getAllCategoriesRest.getErrorCode().intValue());
1401                 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1402                 // Audit validation
1403                 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1404                                 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1405         }
1406
1407         @Test
1408         public void categoryNameValidationConjunctions_01() throws Exception { // Normalize
1409                                                                                                                                                         // the
1410                                                                                                                                                         // category
1411                                                                                                                                                         // name
1412                                                                                                                                                         // conjunctions
1413                                                                                                                                                         // ('of',
1414                                                                                                                                                         // 'to',
1415                                                                                                                                                         // 'for',
1416                                                                                                                                                         // 'as',
1417                                                                                                                                                         // 'a',
1418                                                                                                                                                         // 'an'
1419                                                                                                                                                         // ,
1420                                                                                                                                                         // 'the')
1421                                                                                                                                                         // are
1422                                                                                                                                                         // lower
1423                                                                                                                                                         // case.
1424                 categoryDefinition.setName(" bank OF america  ");
1425                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
1426                                 SERVICE_COMPONENT_TYPE);
1427                 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1428                                 createCategotyRest.getErrorCode().intValue());
1429                 categoryDefinition.setName("Bank of America");
1430                 categoryDefinition.setNormalizedName("bank of america");
1431                 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1432                 // Get service category and validate that category added as defined
1433                 // (also set catalog uniqeId)
1434                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1435                                 SERVICE_COMPONENT_TYPE);
1436                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1437                                 getAllCategoriesRest.getErrorCode().intValue());
1438                 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1439                 // Audit validation
1440                 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1441                                 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1442         }
1443
1444         @Test
1445         public void categoryNameValidationConjunctions_02() throws Exception { // Normalize
1446                                                                                                                                                         // the
1447                                                                                                                                                         // category
1448                                                                                                                                                         // name
1449                                                                                                                                                         // conjunctions
1450                                                                                                                                                         // ('of',
1451                                                                                                                                                         // 'to',
1452                                                                                                                                                         // 'for',
1453                                                                                                                                                         // 'as',
1454                                                                                                                                                         // 'a',
1455                                                                                                                                                         // 'an'
1456                                                                                                                                                         // ,
1457                                                                                                                                                         // 'the')
1458                                                                                                                                                         // are
1459                                                                                                                                                         // lower
1460                                                                                                                                                         // case.
1461                 categoryDefinition.setName("THE america bank   ");
1462                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
1463                                 SERVICE_COMPONENT_TYPE);
1464                 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1465                                 createCategotyRest.getErrorCode().intValue());
1466                 categoryDefinition.setName("THE America Bank");
1467                 categoryDefinition.setNormalizedName("the america bank");
1468                 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1469                 // Get service category and validate that category added as defined
1470                 // (also set catalog uniqeId)
1471                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1472                                 SERVICE_COMPONENT_TYPE);
1473                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1474                                 getAllCategoriesRest.getErrorCode().intValue());
1475                 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1476                 // Audit validation
1477                 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1478                                 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1479         }
1480
1481         @Test
1482         public void categoryNameValidationConjunctions_03() throws Exception { // Normalize
1483                                                                                                                                                         // the
1484                                                                                                                                                         // category
1485                                                                                                                                                         // name
1486                                                                                                                                                         // conjunctions
1487                                                                                                                                                         // ('of',
1488                                                                                                                                                         // 'to',
1489                                                                                                                                                         // 'for',
1490                                                                                                                                                         // 'as',
1491                                                                                                                                                         // 'a',
1492                                                                                                                                                         // 'an'
1493                                                                                                                                                         // ,
1494                                                                                                                                                         // 'the')
1495                                                                                                                                                         // are
1496                                                                                                                                                         // lower
1497                                                                                                                                                         // case.
1498                 categoryDefinition.setName("   A bank OF america  ");
1499                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
1500                                 SERVICE_COMPONENT_TYPE);
1501                 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1502                                 createCategotyRest.getErrorCode().intValue());
1503                 categoryDefinition.setName("A Bank of America");
1504                 categoryDefinition.setNormalizedName("a bank of america");
1505                 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1506                 // Get service category and validate that category added as defined
1507                 // (also set catalog uniqeId)
1508                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1509                                 SERVICE_COMPONENT_TYPE);
1510                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1511                                 getAllCategoriesRest.getErrorCode().intValue());
1512                 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1513                 // Audit validation
1514                 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1515                                 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1516         }
1517
1518         @Test
1519         public void categoryNameValidationConjunctions_04() throws Exception { // Normalize
1520                                                                                                                                                         // the
1521                                                                                                                                                         // category
1522                                                                                                                                                         // name
1523                                                                                                                                                         // conjunctions
1524                                                                                                                                                         // ('of',
1525                                                                                                                                                         // 'to',
1526                                                                                                                                                         // 'for',
1527                                                                                                                                                         // 'as',
1528                                                                                                                                                         // 'a',
1529                                                                                                                                                         // 'an'
1530                                                                                                                                                         // ,
1531                                                                                                                                                         // 'the')
1532                                                                                                                                                         // are
1533                                                                                                                                                         // lower
1534                                                                                                                                                         // case.
1535                 categoryDefinition.setName("  bank  america is A big ban  ");
1536                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
1537                                 SERVICE_COMPONENT_TYPE);
1538                 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1539                                 createCategotyRest.getErrorCode().intValue());
1540                 categoryDefinition.setName("Bank America Is a Big Ban");
1541                 categoryDefinition.setNormalizedName("bank america is a big ban");
1542                 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1543                 // Get service category and validate that category added as defined
1544                 // (also set catalog uniqeId)
1545                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1546                                 SERVICE_COMPONENT_TYPE);
1547                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1548                                 getAllCategoriesRest.getErrorCode().intValue());
1549                 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1550                 // Audit validation
1551                 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1552                                 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1553         }
1554
1555         @Test
1556         public void categoryNameValidationConjunctions_05() throws Exception { // Normalize
1557                                                                                                                                                         // the
1558                                                                                                                                                         // category
1559                                                                                                                                                         // name
1560                                                                                                                                                         // conjunctions
1561                                                                                                                                                         // ('of',
1562                                                                                                                                                         // 'to',
1563                                                                                                                                                         // 'for',
1564                                                                                                                                                         // 'as',
1565                                                                                                                                                         // 'a',
1566                                                                                                                                                         // 'an'
1567                                                                                                                                                         // ,
1568                                                                                                                                                         // 'the')
1569                                                                                                                                                         // are
1570                                                                                                                                                         // lower
1571                                                                                                                                                         // case.
1572                 categoryDefinition.setName(" aN apple comPany inC ");
1573                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
1574                                 SERVICE_COMPONENT_TYPE);
1575                 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1576                                 createCategotyRest.getErrorCode().intValue());
1577                 categoryDefinition.setName("AN Apple ComPany InC");
1578                 categoryDefinition.setNormalizedName("an apple company inc");
1579                 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1580                 // Get service category and validate that category added as defined
1581                 // (also set catalog uniqeId)
1582                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1583                                 SERVICE_COMPONENT_TYPE);
1584                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1585                                 getAllCategoriesRest.getErrorCode().intValue());
1586                 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1587                 // Audit validation
1588                 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1589                                 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1590         }
1591
1592         @Test
1593         public void categoryNameValidationConjunctions_06() throws Exception { // Normalize
1594                                                                                                                                                         // the
1595                                                                                                                                                         // category
1596                                                                                                                                                         // name
1597                                                                                                                                                         // conjunctions
1598                                                                                                                                                         // ('of',
1599                                                                                                                                                         // 'to',
1600                                                                                                                                                         // 'for',
1601                                                                                                                                                         // 'as',
1602                                                                                                                                                         // 'a',
1603                                                                                                                                                         // 'an'
1604                                                                                                                                                         // ,
1605                                                                                                                                                         // 'the')
1606                                                                                                                                                         // are
1607                                                                                                                                                         // lower
1608                                                                                                                                                         // case.
1609                 categoryDefinition.setName(" eat AN apple ANAN");
1610                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
1611                                 SERVICE_COMPONENT_TYPE);
1612                 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1613                                 createCategotyRest.getErrorCode().intValue());
1614                 categoryDefinition.setName("Eat an Apple ANAN");
1615                 categoryDefinition.setNormalizedName("eat an apple anan");
1616                 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1617                 // Get service category and validate that category added as defined
1618                 // (also set catalog uniqeId)
1619                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1620                                 SERVICE_COMPONENT_TYPE);
1621                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1622                                 getAllCategoriesRest.getErrorCode().intValue());
1623                 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1624                 // Audit validation
1625                 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1626                                 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1627         }
1628
1629         @Test
1630         public void categoryNameValidationConjunctions_07() throws Exception { // Normalize
1631                                                                                                                                                         // the
1632                                                                                                                                                         // category
1633                                                                                                                                                         // name
1634                                                                                                                                                         // conjunctions
1635                                                                                                                                                         // ('of',
1636                                                                                                                                                         // 'to',
1637                                                                                                                                                         // 'for',
1638                                                                                                                                                         // 'as',
1639                                                                                                                                                         // 'a',
1640                                                                                                                                                         // 'an'
1641                                                                                                                                                         // ,
1642                                                                                                                                                         // 'the')
1643                                                                                                                                                         // are
1644                                                                                                                                                         // lower
1645                                                                                                                                                         // case.
1646                 categoryDefinition.setName(" united states OF americA ");
1647                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
1648                                 SERVICE_COMPONENT_TYPE);
1649                 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1650                                 createCategotyRest.getErrorCode().intValue());
1651                 categoryDefinition.setName("United States of AmericA");
1652                 categoryDefinition.setNormalizedName("united states of america");
1653                 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1654                 // Get service category and validate that category added as defined
1655                 // (also set catalog uniqeId)
1656                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1657                                 SERVICE_COMPONENT_TYPE);
1658                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1659                                 getAllCategoriesRest.getErrorCode().intValue());
1660                 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1661                 // Audit validation
1662                 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1663                                 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1664         }
1665
1666         // need to re-check
1667         @Test
1668         public void categoryNameValidationConjunctions_08() throws Exception { // Normalize
1669                                                                                                                                                         // the
1670                                                                                                                                                         // category
1671                                                                                                                                                         // name
1672                                                                                                                                                         // conjunctions
1673                                                                                                                                                         // ('of',
1674                                                                                                                                                         // 'to',
1675                                                                                                                                                         // 'for',
1676                                                                                                                                                         // 'as',
1677                                                                                                                                                         // 'a',
1678                                                                                                                                                         // 'an'
1679                                                                                                                                                         // ,
1680                                                                                                                                                         // 'the')
1681                                                                                                                                                         // are
1682                                                                                                                                                         // lower
1683                                                                                                                                                         // case.
1684                 categoryDefinition.setName(" oF united states OF amer ");
1685                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
1686                                 SERVICE_COMPONENT_TYPE);
1687                 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1688                                 createCategotyRest.getErrorCode().intValue());
1689                 categoryDefinition.setName("OF United States of Amer");
1690                 categoryDefinition.setNormalizedName("of united states of amer");
1691                 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1692                 // Get service category and validate that category added as defined
1693                 // (also set catalog uniqeId)
1694                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1695                                 SERVICE_COMPONENT_TYPE);
1696                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1697                                 getAllCategoriesRest.getErrorCode().intValue());
1698                 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1699                 // Audit validation
1700                 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1701                                 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1702         }
1703
1704         @Test
1705         public void categoryNameValidationConjunctions_09() throws Exception { // Normalize
1706                                                                                                                                                         // the
1707                                                                                                                                                         // category
1708                                                                                                                                                         // name
1709                                                                                                                                                         // conjunctions
1710                                                                                                                                                         // ('of',
1711                                                                                                                                                         // 'to',
1712                                                                                                                                                         // 'for',
1713                                                                                                                                                         // 'as',
1714                                                                                                                                                         // 'a',
1715                                                                                                                                                         // 'an'
1716                                                                                                                                                         // ,
1717                                                                                                                                                         // 'the')
1718                                                                                                                                                         // are
1719                                                                                                                                                         // lower
1720                                                                                                                                                         // case.
1721                 categoryDefinition.setName(" to Apple TO at&T TOO ");
1722                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
1723                                 SERVICE_COMPONENT_TYPE);
1724                 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1725                                 createCategotyRest.getErrorCode().intValue());
1726                 categoryDefinition.setName("To Apple to At&T TOO");
1727                 categoryDefinition.setNormalizedName("to apple to at&t too");
1728                 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1729                 // Get service category and validate that category added as defined
1730                 // (also set catalog uniqeId)
1731                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1732                                 SERVICE_COMPONENT_TYPE);
1733                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1734                                 getAllCategoriesRest.getErrorCode().intValue());
1735                 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1736                 // Audit validation
1737                 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1738                                 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1739         }
1740
1741         @Test
1742         public void categoryNameValidationConjunctions_10() throws Exception { // Normalize
1743                                                                                                                                                         // the
1744                                                                                                                                                         // category
1745                                                                                                                                                         // name
1746                                                                                                                                                         // conjunctions
1747                                                                                                                                                         // ('of',
1748                                                                                                                                                         // 'to',
1749                                                                                                                                                         // 'for',
1750                                                                                                                                                         // 'as',
1751                                                                                                                                                         // 'a',
1752                                                                                                                                                         // 'an'
1753                                                                                                                                                         // ,
1754                                                                                                                                                         // 'the')
1755                                                                                                                                                         // are
1756                                                                                                                                                         // lower
1757                                                                                                                                                         // case.
1758                 categoryDefinition.setName(" eat apple AS you liiikeas ");
1759                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
1760                                 SERVICE_COMPONENT_TYPE);
1761                 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1762                                 createCategotyRest.getErrorCode().intValue());
1763                 categoryDefinition.setName("Eat Apple as You Liiikeas");
1764                 categoryDefinition.setNormalizedName("eat apple as you liiikeas");
1765                 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1766                 // Get service category and validate that category added as defined
1767                 // (also set catalog uniqeId)
1768                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1769                                 SERVICE_COMPONENT_TYPE);
1770                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1771                                 getAllCategoriesRest.getErrorCode().intValue());
1772                 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1773                 // Audit validation
1774                 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1775                                 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1776         }
1777
1778         @Test
1779         public void categoryNameValidationConjunctions_11() throws Exception { // Normalize
1780                                                                                                                                                         // the
1781                                                                                                                                                         // category
1782                                                                                                                                                         // name
1783                                                                                                                                                         // conjunctions
1784                                                                                                                                                         // ('of',
1785                                                                                                                                                         // 'to',
1786                                                                                                                                                         // 'for',
1787                                                                                                                                                         // 'as',
1788                                                                                                                                                         // 'a',
1789                                                                                                                                                         // 'an'
1790                                                                                                                                                         // ,
1791                                                                                                                                                         // 'the')
1792                                                                                                                                                         // are
1793                                                                                                                                                         // lower
1794                                                                                                                                                         // case.
1795                 categoryDefinition.setName(" as you may want ");
1796                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
1797                                 SERVICE_COMPONENT_TYPE);
1798                 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1799                                 createCategotyRest.getErrorCode().intValue());
1800                 categoryDefinition.setName("As You May Want");
1801                 categoryDefinition.setNormalizedName("as you may want");
1802                 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1803                 // Get service category and validate that category added as defined
1804                 // (also set catalog uniqeId)
1805                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1806                                 SERVICE_COMPONENT_TYPE);
1807                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1808                                 getAllCategoriesRest.getErrorCode().intValue());
1809                 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1810                 // Audit validation
1811                 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1812                                 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1813         }
1814
1815         @Test
1816         public void categoryNameValidationConjunctions_12() throws Exception { // Normalize
1817                                                                                                                                                         // the
1818                                                                                                                                                         // category
1819                                                                                                                                                         // name
1820                                                                                                                                                         // conjunctions
1821                                                                                                                                                         // ('of',
1822                                                                                                                                                         // 'to',
1823                                                                                                                                                         // 'for',
1824                                                                                                                                                         // 'as',
1825                                                                                                                                                         // 'a',
1826                                                                                                                                                         // 'an'
1827                                                                                                                                                         // ,
1828                                                                                                                                                         // 'the')
1829                                                                                                                                                         // are
1830                                                                                                                                                         // lower
1831                                                                                                                                                         // case.
1832                 categoryDefinition.setName(" the bank OF america ");
1833                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
1834                                 SERVICE_COMPONENT_TYPE);
1835                 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1836                                 createCategotyRest.getErrorCode().intValue());
1837                 categoryDefinition.setName("The Bank of America");
1838                 categoryDefinition.setNormalizedName("the bank of america");
1839                 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1840                 // Get service category and validate that category added as defined
1841                 // (also set catalog uniqeId)
1842                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1843                                 SERVICE_COMPONENT_TYPE);
1844                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1845                                 getAllCategoriesRest.getErrorCode().intValue());
1846                 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1847                 // Audit validation
1848                 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1849                                 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1850         }
1851
1852         // need to recheck
1853         @Test
1854         public void categoryNameValidationConjunctions_13() throws Exception { // Normalize
1855                                                                                                                                                         // the
1856                                                                                                                                                         // category
1857                                                                                                                                                         // name
1858                                                                                                                                                         // conjunctions
1859                                                                                                                                                         // ('of',
1860                                                                                                                                                         // 'to',
1861                                                                                                                                                         // 'for',
1862                                                                                                                                                         // 'as',
1863                                                                                                                                                         // 'a',
1864                                                                                                                                                         // 'an'
1865                                                                                                                                                         // ,
1866                                                                                                                                                         // 'the')
1867                                                                                                                                                         // are
1868                                                                                                                                                         // lower
1869                                                                                                                                                         // case.
1870                 categoryDefinition.setName("  To tel-toto ");
1871                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
1872                                 SERVICE_COMPONENT_TYPE);
1873                 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1874                                 createCategotyRest.getErrorCode().intValue());
1875                 categoryDefinition.setName("To Tel-toto");
1876                 categoryDefinition.setNormalizedName("to tel-toto");
1877                 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1878                 // Get service category and validate that category added as defined
1879                 // (also set catalog uniqeId)
1880                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1881                                 SERVICE_COMPONENT_TYPE);
1882                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1883                                 getAllCategoriesRest.getErrorCode().intValue());
1884                 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1885                 // Audit validation
1886                 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1887                                 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1888         }
1889
1890         // recheck
1891         @Test
1892         public void categoryNameValidationConjunctions_14() throws Exception { // Normalize
1893                                                                                                                                                         // the
1894                                                                                                                                                         // category
1895                                                                                                                                                         // name
1896                                                                                                                                                         // conjunctions
1897                                                                                                                                                         // ('of',
1898                                                                                                                                                         // 'to',
1899                                                                                                                                                         // 'for',
1900                                                                                                                                                         // 'as',
1901                                                                                                                                                         // 'a',
1902                                                                                                                                                         // 'an'
1903                                                                                                                                                         // ,
1904                                                                                                                                                         // 'the')
1905                                                                                                                                                         // are
1906                                                                                                                                                         // lower
1907                                                                                                                                                         // case.
1908                 categoryDefinition.setName("   tel-aviv To   la ");
1909                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
1910                                 SERVICE_COMPONENT_TYPE);
1911                 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1912                                 createCategotyRest.getErrorCode().intValue());
1913                 categoryDefinition.setName("Tel-aviv to La");
1914                 categoryDefinition.setNormalizedName("tel-aviv to la");
1915                 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1916                 // Get service category and validate that category added as defined
1917                 // (also set catalog uniqeId)
1918                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1919                                 SERVICE_COMPONENT_TYPE);
1920                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1921                                 getAllCategoriesRest.getErrorCode().intValue());
1922                 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1923                 // Audit validation
1924                 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1925                                 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1926         }
1927
1928         @Test
1929         public void createServiceCategoryHttpCspUserIdIsEmpty() throws Exception {
1930                 User sdncAdminUserDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
1931                 sdncAdminUserDetails1.setUserId("");
1932                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
1933                                 SERVICE_COMPONENT_TYPE);
1934                 assertEquals("Check response code after create Consumer", STATUS_CODE_MISSING_INFORMATION,
1935                                 createCategotyRest.getErrorCode().intValue());
1936                 categoryDefinition.setName("Abcd");
1937                 // get service category and validate that category was not added
1938                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1939                                 SERVICE_COMPONENT_TYPE);
1940                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1941                                 getAllCategoriesRest.getErrorCode().intValue());
1942                 CategoryValidationUtils.verifyCategoryNotExistsInGetResponse(getAllCategoriesRest, categoryDefinition);
1943                 // Audit validation
1944                 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.MISSING_INFORMATION.name());
1945                 ExpectedCategoryAudit expectedCatrgoryAuditJavaObject = new ExpectedCategoryAudit();
1946                 expectedCatrgoryAuditJavaObject.setAction(ADD_CATEGORY);
1947                 expectedCatrgoryAuditJavaObject.setModifier("");
1948                 expectedCatrgoryAuditJavaObject.setCategoryName(categoryDefinition.getName());
1949                 expectedCatrgoryAuditJavaObject.setSubCategoryName("");
1950                 expectedCatrgoryAuditJavaObject.setGroupingName("");
1951                 expectedCatrgoryAuditJavaObject.setResourceType(AUDIT_SERVICE_TYPE);
1952                 expectedCatrgoryAuditJavaObject.setStatus(String.valueOf(STATUS_CODE_MISSING_INFORMATION));
1953                 expectedCatrgoryAuditJavaObject.setDesc(errorInfo.getAuditDesc());
1954                 AuditValidationUtils.validateCategoryAudit(expectedCatrgoryAuditJavaObject, ADD_CATEGORY);
1955         }
1956
1957         @Test
1958         public void createServiceCategorHttpCspUserIdIsNull() throws Exception {
1959                 User sdncAdminUserDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
1960                 sdncAdminUserDetails1.setUserId(null);
1961                 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
1962                                 SERVICE_COMPONENT_TYPE);
1963                 assertEquals("Check response code after create Consumer", STATUS_CODE_MISSING_INFORMATION,
1964                                 createCategotyRest.getErrorCode().intValue());
1965                 categoryDefinition.setName("Abcd");
1966                 // get service category and validate that category was not added
1967                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1968                                 SERVICE_COMPONENT_TYPE);
1969                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1970                                 getAllCategoriesRest.getErrorCode().intValue());
1971                 CategoryValidationUtils.verifyCategoryNotExistsInGetResponse(getAllCategoriesRest, categoryDefinition);
1972                 // Audit validation
1973                 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.MISSING_INFORMATION.name());
1974                 ExpectedCategoryAudit expectedCatrgoryAuditJavaObject = new ExpectedCategoryAudit();
1975                 expectedCatrgoryAuditJavaObject.setAction(ADD_CATEGORY);
1976                 expectedCatrgoryAuditJavaObject.setModifier("");
1977                 expectedCatrgoryAuditJavaObject.setCategoryName(categoryDefinition.getName());
1978                 expectedCatrgoryAuditJavaObject.setSubCategoryName("");
1979                 expectedCatrgoryAuditJavaObject.setGroupingName("");
1980                 expectedCatrgoryAuditJavaObject.setResourceType(AUDIT_SERVICE_TYPE);
1981                 expectedCatrgoryAuditJavaObject.setStatus(String.valueOf(STATUS_CODE_MISSING_INFORMATION));
1982                 expectedCatrgoryAuditJavaObject.setDesc(errorInfo.getAuditDesc());
1983                 AuditValidationUtils.validateCategoryAudit(expectedCatrgoryAuditJavaObject, ADD_CATEGORY);
1984         }
1985
1986         @Test
1987         public void createSrvcCategoryHttpCspUserIdHeaderIsMissing() throws Exception {
1988                 RestResponse createConsumerRest = CategoryRestUtils
1989                                 .createServiceCategoryHttpCspAtuUidIsMissing(categoryDefinition, sdncAdminUserDetails);
1990                 assertEquals("Check response code after create Consumer", STATUS_CODE_MISSING_INFORMATION,
1991                                 createConsumerRest.getErrorCode().intValue());
1992                 categoryDefinition.setName("Abcd");
1993                 // get service category and validate that category was not added
1994                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1995                                 SERVICE_COMPONENT_TYPE);
1996                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1997                                 getAllCategoriesRest.getErrorCode().intValue());
1998                 CategoryValidationUtils.verifyCategoryNotExistsInGetResponse(getAllCategoriesRest, categoryDefinition);
1999                 // Audit validation
2000                 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.MISSING_INFORMATION.name());
2001                 ExpectedCategoryAudit expectedCatrgoryAuditJavaObject = new ExpectedCategoryAudit();
2002                 expectedCatrgoryAuditJavaObject.setAction(ADD_CATEGORY);
2003                 expectedCatrgoryAuditJavaObject.setModifier("");
2004                 expectedCatrgoryAuditJavaObject.setCategoryName(categoryDefinition.getName());
2005                 expectedCatrgoryAuditJavaObject.setSubCategoryName("");
2006                 expectedCatrgoryAuditJavaObject.setGroupingName("");
2007                 expectedCatrgoryAuditJavaObject.setResourceType(AUDIT_SERVICE_TYPE);
2008                 expectedCatrgoryAuditJavaObject.setStatus(String.valueOf(STATUS_CODE_MISSING_INFORMATION));
2009                 expectedCatrgoryAuditJavaObject.setDesc(errorInfo.getAuditDesc());
2010                 AuditValidationUtils.validateCategoryAudit(expectedCatrgoryAuditJavaObject, ADD_CATEGORY);
2011         }
2012
2013         @Test
2014         public void getServiceCategoryHierarchySuccessFlow() throws Exception {
2015
2016                 int numOfCategories = 3;
2017                 List<CategoryDefinition> categories = new ArrayList<CategoryDefinition>();
2018                 RestResponse restResponse;
2019                 CategoryDefinition category;
2020                 String categoryName = categoryDefinition.getName();
2021                 for (int i = 0; i < numOfCategories; i++) {
2022                         categoryDefinition.setName(categoryName + i);
2023                         restResponse = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
2024                                         SERVICE_COMPONENT_TYPE);
2025                         category = ResponseParser.parseToObject(restResponse.getResponse(), CategoryDefinition.class);
2026                         categories.add(category);
2027                 }
2028                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
2029                                 SERVICE_COMPONENT_TYPE);
2030                 assertEquals("Check response code after get all categories ", STATUS_CODE_SUCCESS,
2031                                 getAllCategoriesRest.getErrorCode().intValue());
2032
2033                 AuditValidationUtils.GetCategoryHierarchyAuditSuccess(GET_CATEGORY_HIERARCHY, AUDIT_SERVICE_TYPE,
2034                                 sdncAdminUserDetails, STATUS_CODE_SUCCESS);
2035                 for (CategoryDefinition categoryCurr : categories) {
2036                         CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryCurr);
2037                 }
2038         }
2039
2040         ///////////////////////////////// US570520 /////////////////////////////////
2041         private List<CategoryDefinition> defineCategories() throws Exception {
2042                 String firstCategory = "FirstCategory";
2043                 String secondCategory = "secondCategory";
2044                 String thirdCategory = "ThirdCategory";
2045                 String forthCategory = "forthCategory";
2046                 CategoryDefinition category1 = new CategoryDefinition(categoryDefinition);
2047                 category1.setName(firstCategory);
2048                 CategoryDefinition category2 = new CategoryDefinition(categoryDefinition);
2049                 category2.setName(secondCategory);
2050                 CategoryDefinition category3 = new CategoryDefinition(categoryDefinition);
2051                 category3.setName(thirdCategory);
2052                 CategoryDefinition category4 = new CategoryDefinition(categoryDefinition);
2053                 category4.setName(forthCategory);
2054                 ArrayList<CategoryDefinition> categoryList = new ArrayList<CategoryDefinition>();
2055                 categoryList.add(category1);
2056                 categoryList.add(category2);
2057                 categoryList.add(category3);
2058                 categoryList.add(category4);
2059                 return categoryList;
2060         }
2061
2062         @Test
2063         public void getAllResourceCategoriesHirarchy() throws Exception {
2064                 createAndValidateCategoriesExist(RESOURCE_COMPONENT_TYPE, categoryList);
2065
2066                 for (int i = 0; i < categoryList.size(); i++) {
2067                         List<String> subCategorieUniqueIdList = new ArrayList<String>();
2068                         for (int j = 0; j < subCategoryList.size(); j++) {
2069                                 RestResponse createSubCategory = CategoryRestUtils.createSubCategory(subCategoryList.get(j),
2070                                                 categoryList.get(i), sdncAdminUserDetails, RESOURCE_COMPONENT_TYPE);
2071                                 if (createSubCategory.getErrorCode().intValue() == STATUS_CODE_CREATED) {
2072                                         String subCategoryUniqeId = ResponseParser.getUniqueIdFromResponse(createSubCategory);
2073                                         subCategorieUniqueIdList.add(subCategoryUniqeId);
2074                                         subCategoriesToDeleteMap.put(categoryList.get(i).getUniqueId(), subCategorieUniqueIdList);
2075                                 }
2076                         }
2077                 }
2078
2079                 DbUtils.deleteFromEsDbByPattern("_all");
2080                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
2081                                 RESOURCE_COMPONENT_TYPE);
2082                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
2083                                 getAllCategoriesRest.getErrorCode().intValue());
2084
2085                 for (int i = 0; i < categoryList.size(); i++) {
2086                         for (int j = 0; j < subCategoryList.size(); j++) {
2087                                 CategoryValidationUtils.verifySubCategoryExistInGetResponse(getAllCategoriesRest,
2088                                                 categoryList.get(i).getUniqueId(), subCategoryList.get(j));
2089                         }
2090                 }
2091
2092                 checkAuditSuccess(RESOURCE_COMPONENT_TYPE);
2093         }
2094
2095         private List<SubCategoryDefinition> defineSubCategories(int catListSize) {
2096                 List<SubCategoryDefinition> subCatList = new ArrayList<SubCategoryDefinition>();
2097                 for (int j = 1; j <= catListSize; j++) {
2098                         SubCategoryDefinition subCategory = new SubCategoryDefinition();
2099                         subCategory.setName("SubCategory" + String.valueOf(j));
2100                         subCatList.add(subCategory);
2101                 }
2102                 return subCatList;
2103         }
2104
2105         private void createAndValidateCategoriesExist(String comp, List<CategoryDefinition> categoryList) throws Exception {
2106                 createCategories(comp, categoryList);
2107                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails, comp);
2108                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
2109                                 getAllCategoriesRest.getErrorCode().intValue());
2110                 verifyCategoriesExist(categoryList, getAllCategoriesRest);
2111         }
2112
2113         private void verifyCategoriesExist(List<CategoryDefinition> categoryList, RestResponse getAllCategoriesRest) {
2114                 for (int i = 0; i < categoryList.size(); i++) {
2115                         categoryList.get(i).setName(WordUtils.capitalize(categoryList.get(i).getName()));
2116                         CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryList.get(i));
2117                 }
2118         }
2119
2120         private void createCategories(String comp, List<CategoryDefinition> categoryList) throws Exception {
2121                 for (int i = 0; i < categoryList.size(); i++) {
2122                         CategoryRestUtils.createCategory(categoryList.get(i), sdncAdminUserDetails, comp);
2123                 }
2124         }
2125
2126         @Test
2127         public void getAllServiceCategoriesHirarchy() throws Exception {
2128                 // deleteCategories(categoryList, SERVICE_COMPONENT_TYPE);
2129                 createAndValidateCategoriesExist(SERVICE_COMPONENT_TYPE, categoryList);
2130                 checkAuditSuccess(SERVICE_COMPONENT_TYPE);
2131                 // deleteCategories(categoryList, SERVICE_COMPONENT_TYPE);
2132         }
2133
2134         @Test
2135         public void getAllResourceCategories_noAttUserHeader() throws Exception {
2136                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(new User(), RESOURCE_COMPONENT_TYPE);
2137                 assertEquals("Check response code after get Category", 403, getAllCategoriesRest.getErrorCode().intValue());
2138                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_INFORMATION.name(), new ArrayList<String>(),
2139                                 getAllCategoriesRest.getResponse());
2140
2141                 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.MISSING_INFORMATION.name());
2142                 ExpectedCategoryAudit expectedCatrgoryAuditJavaObject = new ExpectedCategoryAudit();
2143                 expectedCatrgoryAuditJavaObject.setAction(GET_CATEGORY_HIERARCHY);
2144                 expectedCatrgoryAuditJavaObject.setModifierName("");
2145                 expectedCatrgoryAuditJavaObject.setModifierUid("");
2146                 expectedCatrgoryAuditJavaObject.setDetails(RESOURCE_COMPONENT_TYPE);
2147                 expectedCatrgoryAuditJavaObject.setStatus(String.valueOf(STATUS_CODE_MISSING_INFORMATION));
2148                 expectedCatrgoryAuditJavaObject.setDesc(errorInfo.getAuditDesc());
2149                 AuditValidationUtils.validateGetCategoryHirarchy(expectedCatrgoryAuditJavaObject, GET_CATEGORY_HIERARCHY);
2150         }
2151
2152         @Test
2153         public void getAllResourceCategories_userNotProvisioned() throws Exception {
2154                 User notProvisionedUser = new User();
2155                 notProvisionedUser.setUserId("aa0001");
2156                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(notProvisionedUser,
2157                                 RESOURCE_COMPONENT_TYPE);
2158                 assertEquals("Check response code after get Category", 409, getAllCategoriesRest.getErrorCode().intValue());
2159                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(),
2160                                 getAllCategoriesRest.getResponse());
2161
2162                 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name());
2163                 ExpectedCategoryAudit expectedCatrgoryAuditJavaObject = new ExpectedCategoryAudit();
2164                 expectedCatrgoryAuditJavaObject.setAction(GET_CATEGORY_HIERARCHY);
2165                 expectedCatrgoryAuditJavaObject.setModifierName("");
2166                 expectedCatrgoryAuditJavaObject.setModifierUid(notProvisionedUser.getUserId());
2167                 expectedCatrgoryAuditJavaObject.setDetails(RESOURCE_COMPONENT_TYPE);
2168                 expectedCatrgoryAuditJavaObject.setStatus(String.valueOf(STATUS_CODE_RESTRICTED_OPERATION));
2169                 expectedCatrgoryAuditJavaObject.setDesc(errorInfo.getAuditDesc());
2170                 AuditValidationUtils.validateGetCategoryHirarchy(expectedCatrgoryAuditJavaObject, GET_CATEGORY_HIERARCHY);
2171         }
2172
2173         @Test
2174         public void getAllResourceCategories_unsupportedComponent() throws Exception {
2175                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails, "comp");
2176                 assertEquals("Check response code after get all categories hirarchy", 400,
2177                                 getAllCategoriesRest.getErrorCode().intValue());
2178                 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.UNSUPPORTED_ERROR.name(),
2179                                 new ArrayList<String>(Arrays.asList("component type")), getAllCategoriesRest.getResponse());
2180
2181                 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.UNSUPPORTED_ERROR.name());
2182                 ExpectedCategoryAudit expectedCatrgoryAuditJavaObject = new ExpectedCategoryAudit();
2183                 expectedCatrgoryAuditJavaObject.setAction(GET_CATEGORY_HIERARCHY);
2184                 expectedCatrgoryAuditJavaObject.setModifierUid(sdncAdminUserDetails.getUserId());
2185                 expectedCatrgoryAuditJavaObject.setModifierName(sdncAdminUserDetails.getFullName());
2186                 expectedCatrgoryAuditJavaObject.setDetails("comp");
2187                 expectedCatrgoryAuditJavaObject.setStatus(String.valueOf(STATUS_CODE_INVALID_CONTENT));
2188                 expectedCatrgoryAuditJavaObject.setDesc(AuditValidationUtils.buildAuditDescription(errorInfo,
2189                                 new ArrayList<String>(Arrays.asList("component type"))));
2190                 AuditValidationUtils.validateGetCategoryHirarchy(expectedCatrgoryAuditJavaObject, GET_CATEGORY_HIERARCHY);
2191         }
2192
2193         @Test(enabled = false)
2194         public void getAllResourceCategories_emptyList() throws Exception {
2195                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
2196                                 RESOURCE_COMPONENT_TYPE);
2197                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
2198                                 getAllCategoriesRest.getErrorCode().intValue());
2199                 JSONArray jArr = new JSONArray(getAllCategoriesRest.getResponse());
2200                 assertTrue(jArr.length() == 0);
2201
2202                 checkAuditSuccess(RESOURCE_COMPONENT_TYPE);
2203         }
2204
2205         private void checkAuditSuccess(String componentType) throws Exception {
2206                 ExpectedCategoryAudit expectedCatrgoryAuditJavaObject = new ExpectedCategoryAudit();
2207                 expectedCatrgoryAuditJavaObject.setAction(GET_CATEGORY_HIERARCHY);
2208                 expectedCatrgoryAuditJavaObject.setModifierName(sdncAdminUserDetails.getFullName());
2209                 expectedCatrgoryAuditJavaObject.setModifierUid(sdncAdminUserDetails.getUserId());
2210                 expectedCatrgoryAuditJavaObject.setDetails(componentType);
2211                 expectedCatrgoryAuditJavaObject.setStatus("200");
2212                 expectedCatrgoryAuditJavaObject.setDesc("OK");
2213                 AuditValidationUtils.validateGetCategoryHirarchy(expectedCatrgoryAuditJavaObject, GET_CATEGORY_HIERARCHY);
2214         }
2215
2216         @Test(enabled = false)
2217         public void getAllServiceCategories_emptyList() throws Exception {
2218                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
2219                                 SERVICE_COMPONENT_TYPE);
2220                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
2221                                 getAllCategoriesRest.getErrorCode().intValue());
2222                 JSONArray jArr = new JSONArray(getAllCategoriesRest.getResponse());
2223                 assertTrue(jArr.length() == 0);
2224
2225                 checkAuditSuccess(SERVICE_COMPONENT_TYPE);
2226         }
2227
2228         @Test(enabled = false)
2229         public void getAllProductCategories_emptyList() throws Exception {
2230                 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
2231                                 PRODUCT_COMPONENT_TYPE);
2232                 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
2233                                 getAllCategoriesRest.getErrorCode().intValue());
2234                 JSONArray jArr = new JSONArray(getAllCategoriesRest.getResponse());
2235                 assertTrue(jArr.length() == 0);
2236
2237                 checkAuditSuccess(PRODUCT_COMPONENT_TYPE);
2238         }
2239
2240         // @Test
2241         // public void getAllResourceCategories_generalError() throws Exception
2242         // {
2243         // User user = new User();
2244         // RestResponse getAllCategoriesRest =
2245         // CategoryRestUtils.getAllCategories(user, SERVICE_COMPONENT_TYPE);
2246         // assertEquals("Check response code after get Category", 500,
2247         // getAllCategoriesRest.getErrorCode().intValue());
2248         // Utils.checkBodyResponseOnError(ActionStatus.GENERAL_ERROR.name(), new
2249         // ArrayList<String>(), getAllCategoriesRest.getResponse());
2250         // }
2251
2252         //////////////////////////////////////////////////////////////////////////////
2253
2254         @Test
2255         public void importCategories() throws Exception {
2256
2257                 String importResourceDir = config.getImportTypesConfigDir() + File.separator + "categoryTypesTest.zip";
2258
2259                 MultipartEntityBuilder mpBuilder = MultipartEntityBuilder.create();
2260                 mpBuilder.addPart("categoriesZip", new FileBody(new File(importResourceDir)));
2261
2262                 RestResponse importResult = CategoryRestUtils.importCategories(mpBuilder, sdncAdminUserDetails.getUserId());
2263                 assertEquals("Check response code after Import", BaseRestUtils.STATUS_CODE_CREATED,
2264                                 importResult.getErrorCode().intValue());
2265
2266                 Map<String, Object> map = ResponseParser.parseToObjectUsingMapper(importResult.getResponse(), Map.class);
2267                 assertEquals("Check  entries count", 2, map.size());
2268
2269                 List<Map<String, Object>> resources = (List<Map<String, Object>>) map.get("resources");
2270                 assertEquals("Check resource category  entries count", 1, resources.size());
2271
2272                 List<Map<String, Object>> services = (List<Map<String, Object>>) map.get("services");
2273                 assertEquals("Check resource category  entries count", 2, services.size());
2274
2275                 RestResponse allCategories = CategoryRestUtils.getAllCategories(sdncAdminUserDetails, "resources");
2276                 List<CategoryDefinition> resourceCategories = ResponseParser.parseCategories(allCategories);
2277                 for (Map<String, Object> resource : resources) {
2278                         boolean exist = false;
2279
2280                         for (CategoryDefinition categ : resourceCategories) {
2281                                 if (categ.getName().equals(resource.get("name"))) {
2282                                         exist = true;
2283                                         break;
2284                                 }
2285                         }
2286                         assertTrue("Check existance resource category  " + resource.get("name"), exist);
2287                 }
2288
2289                 allCategories = CategoryRestUtils.getAllCategories(sdncAdminUserDetails, "services");
2290                 List<CategoryDefinition> servicesCategories = ResponseParser.parseCategories(allCategories);
2291                 for (Map<String, Object> service : services) {
2292                         boolean exist = false;
2293
2294                         for (CategoryDefinition categ : servicesCategories) {
2295                                 if (categ.getName().equals(service.get("name"))) {
2296                                         exist = true;
2297                                         break;
2298                                 }
2299                         }
2300                         assertTrue("Check existance service category  " + service.get("name"), exist);
2301                 }
2302         }
2303 }