2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.openecomp.sdc.ci.tests.execute.category;
23 import org.apache.commons.lang3.text.WordUtils;
24 import org.apache.http.entity.mime.MultipartEntityBuilder;
25 import org.apache.http.entity.mime.content.FileBody;
26 import org.json.JSONArray;
27 import org.junit.Rule;
28 import org.junit.rules.TestName;
29 import org.openecomp.sdc.be.dao.api.ActionStatus;
30 import org.openecomp.sdc.be.model.User;
31 import org.openecomp.sdc.be.model.category.CategoryDefinition;
32 import org.openecomp.sdc.be.model.category.SubCategoryDefinition;
33 import org.openecomp.sdc.ci.tests.datatypes.enums.ErrorInfo;
34 import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
35 import org.openecomp.sdc.ci.tests.datatypes.expected.ExpectedCategoryAudit;
36 import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
37 import org.openecomp.sdc.ci.tests.utils.DbUtils;
38 import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
39 import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils;
40 import org.openecomp.sdc.ci.tests.utils.rest.CategoryRestUtils;
41 import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
42 import org.openecomp.sdc.ci.tests.utils.validation.AuditValidationUtils;
43 import org.openecomp.sdc.ci.tests.utils.validation.CategoryValidationUtils;
44 import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils;
45 import org.testng.annotations.BeforeMethod;
46 import org.testng.annotations.Test;
51 import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.*;
52 import static org.testng.AssertJUnit.assertEquals;
53 import static org.testng.AssertJUnit.assertTrue;
55 public class CategoriesTests extends CategoriesBaseTest {
57 private static final String GET_CATEGORY_HIERARCHY = "GetCategoryHierarchy";
58 protected static final String ADD_CATEGORY = "AddCategory";
59 protected static final String DELETE_CATEGORY = "DeleteCategory";
61 public CategoriesTests() {
62 super(name, CategoriesTests.class.getName());
66 public static TestName name = new TestName();
67 private CategoryDefinition categoryDefinition;
68 private List<CategoryDefinition> categoryList;
69 private List<SubCategoryDefinition> subCategoryList;
70 private Map<String, List<String>> subCategoriesToDeleteMap;
73 public void init() throws Exception {
74 subCategoriesToDeleteMap = new HashMap<String, List<String>>();
75 DbUtils.deleteFromEsDbByPattern("_all");
77 categoryDefinition = new CategoryDefinition();
78 categoryDefinition.setName("Abcd");
79 categoryList = defineCategories();
80 subCategoryList = defineSubCategories(categoryList.size());
85 public void createServiceCategorySuccessFlow() throws Exception {
87 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
88 SERVICE_COMPONENT_TYPE);
89 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
90 createCategotyRest.getErrorCode().intValue());
91 categoryDefinition.setNormalizedName("abcd");
92 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
94 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
95 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
96 // get service category and validate that category added as defined
97 // (also set catalog uniqeId)
98 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
99 SERVICE_COMPONENT_TYPE);
100 assertEquals("Check response code after get all categories ", STATUS_CODE_SUCCESS,
101 getAllCategoriesRest.getErrorCode().intValue());
102 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition); // also
111 public void createResourceCategorySuccessFlow() throws Exception {
112 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
113 RESOURCE_COMPONENT_TYPE);
114 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
115 createCategotyRest.getErrorCode().intValue());
116 categoryDefinition.setNormalizedName("abcd");
117 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
119 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
120 RESOURCE_COMPONENT_TYPE);
121 assertEquals("Check response code after get all categories ", STATUS_CODE_SUCCESS,
122 getAllCategoriesRest.getErrorCode().intValue());
123 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
125 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
126 STATUS_CODE_CREATED, AUDIT_RESOURCE_TYPE);
131 public void createProductCategorySuccessFlow() throws Exception {
132 // Add Category by Product-strategist
133 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition,
134 sdncProductStrategistUserDetails, PRODUCT_COMPONENT_TYPE);
135 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
136 createCategotyRest.getErrorCode().intValue());
137 categoryDefinition.setNormalizedName("abcd");
138 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
141 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
142 PRODUCT_COMPONENT_TYPE);
143 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
144 getAllCategoriesRest.getErrorCode().intValue());
145 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
147 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncProductStrategistUserDetails,
148 STATUS_CODE_CREATED, AUDIT_PRODUCT_TYPE);
152 public void CategoryNameValidation_FirstWordStartWithAlphaNumeric_01() throws Exception { // category
155 categoryDefinition.setName("Category14AadE &&&---+++.'''###=:@@@____");
156 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
157 SERVICE_COMPONENT_TYPE);
158 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
159 createCategotyRest.getErrorCode().intValue());
160 categoryDefinition.setName("Category14AadE &-+.'#=:@_");
161 categoryDefinition.setNormalizedName("category14aade &-+.'#=:@_");
162 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
163 // Get service category and validate that category added as defined
164 // (also set catalog uniqeId)
165 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
166 SERVICE_COMPONENT_TYPE);
167 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
168 getAllCategoriesRest.getErrorCode().intValue());
169 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
171 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
172 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
176 public void categoryNameValidation_FirstWordStartWithAlphaNumeric_02() throws Exception { // category
179 categoryDefinition.setName("Category14AadE &&&---+++.'''###=:@@@____");
180 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
181 RESOURCE_COMPONENT_TYPE);
182 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
183 createCategotyRest.getErrorCode().intValue());
184 categoryDefinition.setName("Category14AadE &-+.'#=:@_");
185 categoryDefinition.setNormalizedName("category14aade &-+.'#=:@_");
186 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
187 // Get service category and validate that category added as defined
188 // (also set catalog uniqeId)
189 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
190 RESOURCE_COMPONENT_TYPE);
191 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
192 getAllCategoriesRest.getErrorCode().intValue());
193 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
195 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
196 STATUS_CODE_CREATED, AUDIT_RESOURCE_TYPE);
200 public void categoryNameValidation_FirstWordStartWithAlphaNumeric_03() throws Exception { // category
203 categoryDefinition.setName("Category14AadE &&&---+++.'''###=:@@@____");
204 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition,
205 sdncProductStrategistUserDetails, PRODUCT_COMPONENT_TYPE);
206 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
207 createCategotyRest.getErrorCode().intValue());
208 categoryDefinition.setName("Category14AadE &-+.'#=:@_");
209 categoryDefinition.setNormalizedName("category14aade &-+.'#=:@_");
210 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
211 // Get service category and validate that category added as defined
212 // (also set catalog uniqeId)
213 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
214 PRODUCT_COMPONENT_TYPE);
215 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
216 getAllCategoriesRest.getErrorCode().intValue());
217 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
219 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncProductStrategistUserDetails,
220 STATUS_CODE_CREATED, AUDIT_PRODUCT_TYPE);
225 public void createServiceCategoryByNonAdminUser() throws Exception {
227 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition,
228 sdncProductStrategistUserDetails, SERVICE_COMPONENT_TYPE);
229 assertEquals("Check response code after create Category", STATUS_CODE_RESTRICTED_OPERATION,
230 createCategotyRest.getErrorCode().intValue());
231 // get service category and validate that category was not added
232 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
233 SERVICE_COMPONENT_TYPE);
234 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
235 getAllCategoriesRest.getErrorCode().intValue());
236 CategoryValidationUtils.verifyCategoryNotExistsInGetResponse(getAllCategoriesRest, categoryDefinition);
238 AuditValidationUtils.categoryAuditFailure(ADD_CATEGORY, categoryDefinition, sdncProductStrategistUserDetails,
239 ActionStatus.RESTRICTED_OPERATION, STATUS_CODE_RESTRICTED_OPERATION, AUDIT_SERVICE_TYPE);
244 public void createResourceCategoryByNonAdminUser() throws Exception {
245 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition,
246 sdncProductStrategistUserDetails, RESOURCE_COMPONENT_TYPE);
247 assertEquals("Check response code after create Category", STATUS_CODE_RESTRICTED_OPERATION,
248 createCategotyRest.getErrorCode().intValue());
249 // get service category and validate that category was not added
250 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
251 RESOURCE_COMPONENT_TYPE);
252 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
253 getAllCategoriesRest.getErrorCode().intValue());
254 CategoryValidationUtils.verifyCategoryNotExistsInGetResponse(getAllCategoriesRest, categoryDefinition);
256 AuditValidationUtils.categoryAuditFailure(ADD_CATEGORY, categoryDefinition, sdncProductStrategistUserDetails,
257 ActionStatus.RESTRICTED_OPERATION, STATUS_CODE_RESTRICTED_OPERATION, AUDIT_RESOURCE_TYPE);
262 public void createProductCategoryByNonProductStrategistUser() throws Exception {
263 // Add New product category not by Product-Strategist
264 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
265 PRODUCT_COMPONENT_TYPE);
266 assertEquals("Check response code after create Category", STATUS_CODE_RESTRICTED_OPERATION,
267 createCategotyRest.getErrorCode().intValue());
268 // get service category and validate that category was not added
269 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
270 PRODUCT_COMPONENT_TYPE);
271 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
272 getAllCategoriesRest.getErrorCode().intValue());
273 CategoryValidationUtils.verifyCategoryNotExistsInGetResponse(getAllCategoriesRest, categoryDefinition);
275 AuditValidationUtils.categoryAuditFailure(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
276 ActionStatus.RESTRICTED_OPERATION, STATUS_CODE_RESTRICTED_OPERATION, AUDIT_PRODUCT_TYPE);
282 public void addCategoryByNonExistingUser() throws Exception {
283 User sdncAdminUserDetailsNonExisting = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
284 sdncAdminUserDetailsNonExisting.setUserId("bt555h");
286 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition,
287 sdncAdminUserDetailsNonExisting, SERVICE_COMPONENT_TYPE);
288 assertEquals("Check response code after create Category", STATUS_CODE_RESTRICTED_OPERATION,
289 createCategotyRest.getErrorCode().intValue());
290 // get service category and validate that category was not added
291 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
292 SERVICE_COMPONENT_TYPE);
293 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
294 getAllCategoriesRest.getErrorCode().intValue());
295 CategoryValidationUtils.verifyCategoryNotExistsInGetResponse(getAllCategoriesRest, categoryDefinition);
297 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name());
298 ExpectedCategoryAudit expectedCatrgoryAuditJavaObject = new ExpectedCategoryAudit();
299 expectedCatrgoryAuditJavaObject.setAction(ADD_CATEGORY);
300 expectedCatrgoryAuditJavaObject.setModifier("(" + sdncAdminUserDetailsNonExisting.getUserId() + ")");
301 expectedCatrgoryAuditJavaObject.setCategoryName(categoryDefinition.getName());
302 expectedCatrgoryAuditJavaObject.setSubCategoryName("");
303 expectedCatrgoryAuditJavaObject.setGroupingName("");
304 expectedCatrgoryAuditJavaObject.setResourceType(AUDIT_SERVICE_TYPE);
305 expectedCatrgoryAuditJavaObject.setStatus(String.valueOf(STATUS_CODE_RESTRICTED_OPERATION));
306 expectedCatrgoryAuditJavaObject.setDesc(errorInfo.getAuditDesc());
307 AuditValidationUtils.validateCategoryAudit(expectedCatrgoryAuditJavaObject, ADD_CATEGORY);
311 public void addServiceCategoryAllowedcharacters_01() throws Exception {
312 categoryDefinition.setName("1234AbcdE&");
313 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
314 SERVICE_COMPONENT_TYPE);
315 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
316 createCategotyRest.getErrorCode().intValue());
317 categoryDefinition.setNormalizedName("1234abcde&"); // normalization
318 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
319 // Get service category and validate that category added as defined
320 // (also set catalog uniqeId)
321 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
322 SERVICE_COMPONENT_TYPE);
323 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
324 getAllCategoriesRest.getErrorCode().intValue());
325 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
327 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
328 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
332 public void addServiceCategoryAllowedcharacters_02() throws Exception {
333 categoryDefinition.setName("1234AbcdE-");
334 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
335 SERVICE_COMPONENT_TYPE);
336 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
337 createCategotyRest.getErrorCode().intValue());
338 categoryDefinition.setNormalizedName("1234abcde-"); // normalization
339 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
340 // Get service category and validate that category added as defined
341 // (also set catalog uniqeId)
342 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
343 SERVICE_COMPONENT_TYPE);
344 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
345 getAllCategoriesRest.getErrorCode().intValue());
346 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
348 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
349 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
353 public void addServiceCategoryAllowedcharacters_03() throws Exception {
354 categoryDefinition.setName("1234AbcdE+");
355 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
356 SERVICE_COMPONENT_TYPE);
357 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
358 createCategotyRest.getErrorCode().intValue());
359 categoryDefinition.setNormalizedName("1234abcde+"); // normalization
360 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
361 // Get service category and validate that category added as defined
362 // (also set catalog uniqeId)
363 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
364 SERVICE_COMPONENT_TYPE);
365 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
366 getAllCategoriesRest.getErrorCode().intValue());
367 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
369 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
370 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
374 public void addServiceCategoryAllowedcharacters_04() throws Exception {
375 categoryDefinition.setName("1234AbcdE.");
376 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
377 SERVICE_COMPONENT_TYPE);
378 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
379 createCategotyRest.getErrorCode().intValue());
380 categoryDefinition.setNormalizedName("1234abcde."); // normalization
381 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
382 // Get service category and validate that category added as defined
383 // (also set catalog uniqeId)
384 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
385 SERVICE_COMPONENT_TYPE);
386 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
387 getAllCategoriesRest.getErrorCode().intValue());
388 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
390 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
391 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
395 public void addServiceCategoryAllowedcharacters_05() throws Exception {
396 categoryDefinition.setName("1234AbcdE'");
397 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
398 SERVICE_COMPONENT_TYPE);
399 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
400 createCategotyRest.getErrorCode().intValue());
401 categoryDefinition.setNormalizedName("1234abcde'");
402 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
403 // Get service category and validate that category added as defined
404 // (also set catalog uniqeId)
405 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
406 SERVICE_COMPONENT_TYPE);
407 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
408 getAllCategoriesRest.getErrorCode().intValue());
409 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
411 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
412 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
416 public void addServiceCategoryAllowedcharacters_06() throws Exception {
417 categoryDefinition.setName("1234AbcdE=");
418 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
419 SERVICE_COMPONENT_TYPE);
420 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
421 createCategotyRest.getErrorCode().intValue());
422 categoryDefinition.setNormalizedName("1234abcde="); // normalization
423 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
424 // Get service category and validate that category added as defined
425 // (also set catalog uniqeId)
426 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
427 SERVICE_COMPONENT_TYPE);
428 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
429 getAllCategoriesRest.getErrorCode().intValue());
430 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
432 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
433 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
437 public void addServiceCategoryAllowedcharacters_07() throws Exception {
438 categoryDefinition.setName("1234AbcdE:");
439 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
440 SERVICE_COMPONENT_TYPE);
441 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
442 createCategotyRest.getErrorCode().intValue());
443 categoryDefinition.setNormalizedName("1234abcde:"); // normalization
444 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
445 // Get service category and validate that category added as defined
446 // (also set catalog uniqeId)
447 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
448 SERVICE_COMPONENT_TYPE);
449 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
450 getAllCategoriesRest.getErrorCode().intValue());
451 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
453 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
454 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
458 public void addServiceCategoryAllowedcharacters_08() throws Exception {
459 categoryDefinition.setName("1234AbcdE@");
460 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
461 SERVICE_COMPONENT_TYPE);
462 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
463 createCategotyRest.getErrorCode().intValue());
464 categoryDefinition.setNormalizedName("1234abcde@"); // normalization
465 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
466 // Get service category and validate that category added as defined
467 // (also set catalog uniqeId)
468 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
469 SERVICE_COMPONENT_TYPE);
470 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
471 getAllCategoriesRest.getErrorCode().intValue());
472 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
474 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
475 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
479 public void addServiceCategoryAllowedcharacters_09() throws Exception {
480 categoryDefinition.setName("1234AbcdE_");
481 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
482 SERVICE_COMPONENT_TYPE);
483 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
484 createCategotyRest.getErrorCode().intValue());
485 categoryDefinition.setNormalizedName("1234abcde_"); // normalization
486 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
487 // Get service category and validate that category added as defined
488 // (also set catalog uniqeId)
489 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
490 SERVICE_COMPONENT_TYPE);
491 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
492 getAllCategoriesRest.getErrorCode().intValue());
493 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
495 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
496 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
500 public void addServiceCategoryAllowedcharacters_10() throws Exception {
501 categoryDefinition.setName("1234AbcdE#");
502 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
503 SERVICE_COMPONENT_TYPE);
504 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
505 createCategotyRest.getErrorCode().intValue());
506 categoryDefinition.setNormalizedName("1234abcde#"); // normalization
507 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
508 // Get service category and validate that category added as defined
509 // (also set catalog uniqeId)
510 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
511 SERVICE_COMPONENT_TYPE);
512 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
513 getAllCategoriesRest.getErrorCode().intValue());
514 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
516 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
517 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
521 public void addServiceCategoryAllowedcharacters_11() throws Exception {
522 categoryDefinition.setName("1234AbcdE d");
523 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
524 SERVICE_COMPONENT_TYPE);
525 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
526 createCategotyRest.getErrorCode().intValue());
527 categoryDefinition.setNormalizedName("1234abcde d"); // normalization
528 categoryDefinition.setName("1234AbcdE D");
529 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
530 // Get service category and validate that category added as defined
531 // (also set catalog uniqeId)
532 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
533 SERVICE_COMPONENT_TYPE);
534 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
535 getAllCategoriesRest.getErrorCode().intValue());
536 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
538 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
539 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
543 public void addServiceCategoryAllowedcharacters_12() throws Exception {
544 categoryDefinition.setName("1234AbcdE &_=+.-'#:@ d");
545 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
546 SERVICE_COMPONENT_TYPE);
547 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
548 createCategotyRest.getErrorCode().intValue());
549 categoryDefinition.setNormalizedName("1234abcde &_=+.-'#:@ d"); // normalization
550 categoryDefinition.setName("1234AbcdE &_=+.-'#:@ D");
551 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
552 // Get service category and validate that category added as defined
553 // (also set catalog uniqeId)
554 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
555 SERVICE_COMPONENT_TYPE);
556 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
557 getAllCategoriesRest.getErrorCode().intValue());
558 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
560 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
561 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
565 public void categoryNameValidation_RemoveSpaceFromBeginning() throws Exception {
566 categoryDefinition.setName(" Category01");
567 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
568 SERVICE_COMPONENT_TYPE);
569 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
570 createCategotyRest.getErrorCode().intValue());
571 categoryDefinition.setNormalizedName("category01"); // normalization
572 categoryDefinition.setName("Category01");
573 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
574 // Get service category and validate that category added as defined
575 // (also set catalog uniqeId)
576 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
577 SERVICE_COMPONENT_TYPE);
578 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
579 getAllCategoriesRest.getErrorCode().intValue());
580 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
582 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
583 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
587 public void categoryNameValidation_RemoveSpaceFromEnd() throws Exception {
588 categoryDefinition.setName("Category01 ");
589 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
590 SERVICE_COMPONENT_TYPE);
591 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
592 createCategotyRest.getErrorCode().intValue());
593 categoryDefinition.setNormalizedName("category01"); // normalization
594 categoryDefinition.setName("Category01");
595 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
596 // Get service category and validate that category added as defined
597 // (also set catalog uniqeId)
598 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
599 SERVICE_COMPONENT_TYPE);
600 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
601 getAllCategoriesRest.getErrorCode().intValue());
602 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
604 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
605 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
609 public void categoryNameValidation_RemoveExtraSpace() throws Exception {
610 categoryDefinition.setName("Category 02");
611 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
612 SERVICE_COMPONENT_TYPE);
613 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
614 createCategotyRest.getErrorCode().intValue());
615 categoryDefinition.setNormalizedName("category 02"); // normalization
616 categoryDefinition.setName("Category 02");
617 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
618 // Get service category and validate that category added as defined
619 // (also set catalog uniqeId)
620 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
621 SERVICE_COMPONENT_TYPE);
622 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
623 getAllCategoriesRest.getErrorCode().intValue());
624 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
626 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
627 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
631 public void categoryNameValidation_RemoveExtraAmpersand() throws Exception {
632 categoryDefinition.setName("Category&& &02");
633 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
634 SERVICE_COMPONENT_TYPE);
635 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
636 createCategotyRest.getErrorCode().intValue());
637 categoryDefinition.setNormalizedName("category& &02"); // normalization
638 categoryDefinition.setName("Category& &02");
639 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
640 // Get service category and validate that category added as defined
641 // (also set catalog uniqeId)
642 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
643 SERVICE_COMPONENT_TYPE);
644 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
645 getAllCategoriesRest.getErrorCode().intValue());
646 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
648 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
649 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
653 public void categoryNameValidation_RemoveExtraDash() throws Exception {
654 categoryDefinition.setName("CategorY-- --02");
655 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
656 SERVICE_COMPONENT_TYPE);
657 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
658 createCategotyRest.getErrorCode().intValue());
659 categoryDefinition.setName("CategorY- -02");
660 categoryDefinition.setNormalizedName("category- -02");
661 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
662 // Get service category and validate that category added as defined
663 // (also set catalog uniqeId)
664 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
665 SERVICE_COMPONENT_TYPE);
666 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
667 getAllCategoriesRest.getErrorCode().intValue());
668 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
670 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
671 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
675 public void categoryNameValidation_RemoveExtraPlus() throws Exception {
676 categoryDefinition.setName("CateGory++++ +02");
677 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
678 SERVICE_COMPONENT_TYPE);
679 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
680 createCategotyRest.getErrorCode().intValue());
681 categoryDefinition.setName("CateGory+ +02");
682 categoryDefinition.setNormalizedName("category+ +02");
683 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
684 // Get service category and validate that category added as defined
685 // (also set catalog uniqeId)
686 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
687 SERVICE_COMPONENT_TYPE);
688 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
689 getAllCategoriesRest.getErrorCode().intValue());
690 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
692 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
693 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
697 public void categoryNameValidation_RemoveExtraPeriod() throws Exception {
698 categoryDefinition.setName("Category.... .02");
699 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
700 SERVICE_COMPONENT_TYPE);
701 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
702 createCategotyRest.getErrorCode().intValue());
703 categoryDefinition.setName("Category. .02");
704 categoryDefinition.setNormalizedName("category. .02");
705 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
706 // Get service category and validate that category added as defined
707 // (also set catalog uniqeId)
708 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
709 SERVICE_COMPONENT_TYPE);
710 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
711 getAllCategoriesRest.getErrorCode().intValue());
712 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
714 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
715 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
719 public void categoryNameValidation_RemoveExtraApostrophe() throws Exception {
720 categoryDefinition.setName("CaTegory''' '02");
721 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
722 SERVICE_COMPONENT_TYPE);
723 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
724 createCategotyRest.getErrorCode().intValue());
725 categoryDefinition.setName("CaTegory' '02");
726 categoryDefinition.setNormalizedName("category' '02");
727 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
728 // Get service category and validate that category added as defined
729 // (also set catalog uniqeId)
730 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
731 SERVICE_COMPONENT_TYPE);
732 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
733 getAllCategoriesRest.getErrorCode().intValue());
734 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
736 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
737 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
741 public void categoryNameValidation_RemoveExtraHashtag() throws Exception {
742 categoryDefinition.setName("Category### #02");
743 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
744 SERVICE_COMPONENT_TYPE);
745 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
746 createCategotyRest.getErrorCode().intValue());
747 categoryDefinition.setName("Category# #02");
748 categoryDefinition.setNormalizedName("category# #02");
749 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
750 // Get service category and validate that category added as defined
751 // (also set catalog uniqeId)
752 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
753 SERVICE_COMPONENT_TYPE);
754 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
755 getAllCategoriesRest.getErrorCode().intValue());
756 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
758 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
759 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
763 public void categoryNameValidation_RemoveExtrEequal() throws Exception {
764 categoryDefinition.setName("Category=== =02");
765 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
766 SERVICE_COMPONENT_TYPE);
767 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
768 createCategotyRest.getErrorCode().intValue());
769 categoryDefinition.setName("Category= =02");
770 categoryDefinition.setNormalizedName("category= =02");
771 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
772 // Get service category and validate that category added as defined
773 // (also set catalog uniqeId)
774 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
775 SERVICE_COMPONENT_TYPE);
776 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
777 getAllCategoriesRest.getErrorCode().intValue());
778 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
780 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
781 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
785 public void categoryNameValidation_RemoveExtrColon() throws Exception {
786 categoryDefinition.setName("Category::: :02");
787 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
788 SERVICE_COMPONENT_TYPE);
789 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
790 createCategotyRest.getErrorCode().intValue());
791 categoryDefinition.setName("Category: :02");
792 categoryDefinition.setNormalizedName("category: :02");
793 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
794 // Get service category and validate that category added as defined
795 // (also set catalog uniqeId)
796 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
797 SERVICE_COMPONENT_TYPE);
798 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
799 getAllCategoriesRest.getErrorCode().intValue());
800 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
802 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
803 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
807 public void categoryNameValidation_RemoveExtrAt() throws Exception {
808 categoryDefinition.setName("Category@@@ @a2");
809 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
810 SERVICE_COMPONENT_TYPE);
811 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
812 createCategotyRest.getErrorCode().intValue());
813 categoryDefinition.setName("Category@ @a2");
814 categoryDefinition.setNormalizedName("category@ @a2");
815 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
816 // Get service category and validate that category added as defined
817 // (also set catalog uniqeId)
818 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
819 SERVICE_COMPONENT_TYPE);
820 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
821 getAllCategoriesRest.getErrorCode().intValue());
822 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
824 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
825 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
829 public void categoryNameValidation_RemoveExtraUnderscore() throws Exception {
830 categoryDefinition.setName("Category___ _22");
831 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
832 SERVICE_COMPONENT_TYPE);
833 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
834 createCategotyRest.getErrorCode().intValue());
835 categoryDefinition.setName("Category_ _22");
836 categoryDefinition.setNormalizedName("category_ _22");
837 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
838 // Get service category and validate that category added as defined
839 // (also set catalog uniqeId)
840 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
841 SERVICE_COMPONENT_TYPE);
842 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
843 getAllCategoriesRest.getErrorCode().intValue());
844 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
846 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
847 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
851 public void categoryNameValidation_FirstWordStartWithNumber() throws Exception {
852 categoryDefinition.setName("1Category one");
853 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
854 SERVICE_COMPONENT_TYPE);
855 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
856 createCategotyRest.getErrorCode().intValue());
857 categoryDefinition.setName("1Category One");
858 categoryDefinition.setNormalizedName("1category one");
859 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
860 // Get service category and validate that category added as defined
861 // (also set catalog uniqeId)
862 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
863 SERVICE_COMPONENT_TYPE);
864 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
865 getAllCategoriesRest.getErrorCode().intValue());
866 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
868 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
869 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
873 public void categoryNameValidation_FirstWordStartWithNonAlphaNumeric() throws Exception { // The
885 char invalidChars[] = { '&', '-', '+', '.', '\'', '#', '=', ':', '@', '_' };
886 for (int i = 0; i < invalidChars.length; i++) {
887 DbUtils.deleteFromEsDbByPattern("_all");
888 categoryDefinition.setName(invalidChars[i] + "AbcD123");
889 categoryDefinition.setNormalizedName((invalidChars[i] + "AbcD123").toLowerCase());
890 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition,
891 sdncAdminUserDetails1, SERVICE_COMPONENT_TYPE);
892 assertEquals("Check response code after create Category", STATUS_CODE_INVALID_CONTENT,
893 createCategotyRest.getErrorCode().intValue());
895 // get service category and validate that category was not added
896 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
897 SERVICE_COMPONENT_TYPE);
898 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
899 getAllCategoriesRest.getErrorCode().intValue());
900 CategoryValidationUtils.verifyCategoryNotExistsInGetResponse(getAllCategoriesRest, categoryDefinition);
902 AuditValidationUtils.categoryAuditFailure(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails1,
903 ActionStatus.COMPONENT_ELEMENT_INVALID_NAME_FORMAT, STATUS_CODE_INVALID_CONTENT, AUDIT_SERVICE_TYPE,
904 "Service", "category");
910 public void addServiceCategoryAlreadyExist_uniqueness() throws Exception { // Verify
916 // non-case-sensitive,
927 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
928 SERVICE_COMPONENT_TYPE);
929 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
930 createCategotyRest.getErrorCode().intValue());
931 categoryDefinition.setNormalizedName("abcd");
932 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
933 // get service category and validate that category added as defined
934 // (also set catalog uniqeId)
935 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
936 SERVICE_COMPONENT_TYPE);
937 assertEquals("Check response code after get all categories ", STATUS_CODE_SUCCESS,
938 getAllCategoriesRest.getErrorCode().intValue());
939 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition); // also
944 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
945 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
946 // Create same category name again
947 DbUtils.deleteFromEsDbByPattern("_all");
948 CategoryDefinition categoryDataDefinition2 = new CategoryDefinition();
949 categoryDataDefinition2.setName(categoryDefinition.getName());
950 RestResponse addDuplicateCategoryRest = CategoryRestUtils.createCategory(categoryDataDefinition2,
951 sdncAdminUserDetails, SERVICE_COMPONENT_TYPE);
952 assertEquals("Check response code after create Category", STATUS_CODE_ALREADY_EXISTS,
953 addDuplicateCategoryRest.getErrorCode().intValue());
955 AuditValidationUtils.categoryAuditFailure(ADD_CATEGORY, categoryDataDefinition2, sdncAdminUserDetails,
956 ActionStatus.COMPONENT_CATEGORY_ALREADY_EXISTS, STATUS_CODE_ALREADY_EXISTS, AUDIT_SERVICE_TYPE,
957 "Service", categoryDefinition.getName());
958 // Get Category and verify that category was created is not deleted
959 getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails, SERVICE_COMPONENT_TYPE);
960 assertEquals("Check response code after get all categories ", STATUS_CODE_SUCCESS,
961 getAllCategoriesRest.getErrorCode().intValue());
962 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
967 public void categoryNameValidation_ReplaceAndWithAmpersand_01() throws Exception {
968 categoryDefinition.setName("At and T");
969 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
970 SERVICE_COMPONENT_TYPE);
971 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
972 createCategotyRest.getErrorCode().intValue());
973 categoryDefinition.setName("At & T");
974 categoryDefinition.setNormalizedName("at & t");
975 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
976 // Get service category and validate that category added as defined
977 // (also set catalog uniqeId)
978 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
979 SERVICE_COMPONENT_TYPE);
980 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
981 getAllCategoriesRest.getErrorCode().intValue());
982 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
984 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
985 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
989 public void categoryNameValidation_ReplaceAndWithAmpersand_02() throws Exception {
990 categoryDefinition.setName("At and t");
991 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
992 SERVICE_COMPONENT_TYPE);
993 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
994 createCategotyRest.getErrorCode().intValue());
995 categoryDefinition.setName("At & T");
996 categoryDefinition.setNormalizedName("at & t");
997 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
998 // Get service category and validate that category added as defined
999 // (also set catalog uniqeId)
1000 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1001 SERVICE_COMPONENT_TYPE);
1002 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1003 getAllCategoriesRest.getErrorCode().intValue());
1004 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1006 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1007 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1011 public void categoryNameValidation_ReplaceAndWithAmpersand_03() throws Exception {
1012 categoryDefinition.setName("Atand T");
1013 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
1014 SERVICE_COMPONENT_TYPE);
1015 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1016 createCategotyRest.getErrorCode().intValue());
1017 categoryDefinition.setNormalizedName("atand t");
1018 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1019 // Get service category and validate that category added as defined
1020 // (also set catalog uniqeId)
1021 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1022 SERVICE_COMPONENT_TYPE);
1023 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1024 getAllCategoriesRest.getErrorCode().intValue());
1025 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1027 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1028 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1032 public void categoryNameValidation_ReplaceAndWithAmpersand_04() throws Exception {
1033 categoryDefinition.setName("At andT");
1034 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
1035 SERVICE_COMPONENT_TYPE);
1036 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1037 createCategotyRest.getErrorCode().intValue());
1038 categoryDefinition.setNormalizedName("at andt");
1039 categoryDefinition.setName("At AndT");
1040 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1041 // Get service category and validate that category added as defined
1042 // (also set catalog uniqeId)
1043 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1044 SERVICE_COMPONENT_TYPE);
1045 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1046 getAllCategoriesRest.getErrorCode().intValue());
1047 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1049 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1050 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1054 public void categoryNameValidation_ReplaceAndWithAmpersand_05() throws Exception {
1055 categoryDefinition.setName(" and AttT");
1056 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
1057 SERVICE_COMPONENT_TYPE);
1058 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1059 createCategotyRest.getErrorCode().intValue());
1060 categoryDefinition.setNormalizedName("and attt");
1061 categoryDefinition.setName("And AttT");
1062 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1063 // Get service category and validate that category added as defined
1064 // (also set catalog uniqeId)
1065 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1066 SERVICE_COMPONENT_TYPE);
1067 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1068 getAllCategoriesRest.getErrorCode().intValue());
1069 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1071 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1072 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1076 public void categoryNameValidation_ReplaceAndWithAmpersand_06() throws Exception {
1077 categoryDefinition.setName("AttT and ");
1078 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
1079 SERVICE_COMPONENT_TYPE);
1080 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1081 createCategotyRest.getErrorCode().intValue());
1082 categoryDefinition.setNormalizedName("attt and");
1083 categoryDefinition.setName("AttT And");
1084 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1085 // Get service category and validate that category added as defined
1086 // (also set catalog uniqeId)
1087 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1088 SERVICE_COMPONENT_TYPE);
1089 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1090 getAllCategoriesRest.getErrorCode().intValue());
1091 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1093 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1094 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1099 public void categoryNameValidation_ReplaceAndWithAmpersand_07() throws Exception {
1100 categoryDefinition.setName(" and a");
1101 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
1102 SERVICE_COMPONENT_TYPE);
1103 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1104 createCategotyRest.getErrorCode().intValue());
1105 categoryDefinition.setNormalizedName("and a");
1106 categoryDefinition.setName("And a");
1107 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1108 // Get service category and validate that category added as defined
1109 // (also set catalog uniqeId)
1110 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1111 SERVICE_COMPONENT_TYPE);
1112 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1113 getAllCategoriesRest.getErrorCode().intValue());
1114 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1116 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1117 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1121 public void categoryNameValidationMaxLength() throws Exception {
1122 categoryDefinition.setName("AsdfghjQ234567890@#.&:+-_");
1123 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
1124 SERVICE_COMPONENT_TYPE);
1125 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1126 createCategotyRest.getErrorCode().intValue());
1127 categoryDefinition.setNormalizedName("asdfghjq234567890@#.&:+-_");
1128 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1129 // Get service category and validate that category added as defined
1130 // (also set catalog uniqeId)
1131 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1132 SERVICE_COMPONENT_TYPE);
1133 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1134 getAllCategoriesRest.getErrorCode().intValue());
1135 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1137 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1138 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1143 public void categoryNameValidationMaxLengthAfterNormalization() throws Exception {
1144 categoryDefinition.setName(" A jQ234 @@@___ +++ At and T and and ");
1145 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
1146 SERVICE_COMPONENT_TYPE);
1147 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1148 createCategotyRest.getErrorCode().intValue());
1149 categoryDefinition.setName("A JQ234 @_ + At & T & And");
1150 categoryDefinition.setNormalizedName("a jq234 @_ + at & t & and");
1151 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1152 // Get service category and validate that category added as defined
1153 // (also set catalog uniqeId)
1154 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1155 SERVICE_COMPONENT_TYPE);
1156 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1157 getAllCategoriesRest.getErrorCode().intValue());
1158 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1160 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1161 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1166 public void categoryNameValidationExceedMaxLengthAfterNormalization() throws Exception {
1167 categoryDefinition.setName(" AbdfghBCVa jQ234 @@___ +++ At and T ");
1168 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
1169 SERVICE_COMPONENT_TYPE);
1170 assertEquals("Check response code after create Category", STATUS_CODE_INVALID_CONTENT,
1171 createCategotyRest.getErrorCode().intValue());
1172 categoryDefinition.setNormalizedName("abdfghbcva jq234 @_ + at&t");
1173 // get service category and validate that category was not added
1174 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1175 SERVICE_COMPONENT_TYPE);
1176 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1177 getAllCategoriesRest.getErrorCode().intValue());
1178 CategoryValidationUtils.verifyCategoryNotExistsInGetResponse(getAllCategoriesRest, categoryDefinition);
1180 AuditValidationUtils.categoryAuditFailure(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1181 ActionStatus.COMPONENT_ELEMENT_INVALID_NAME_LENGTH, STATUS_CODE_INVALID_CONTENT, AUDIT_SERVICE_TYPE,
1182 "Service", "category");
1186 public void categoryNameValidationMinLengthAfterNormalization() throws Exception { // MinLengthAfterNormalization
1190 categoryDefinition.setName(" At and T ");
1191 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
1192 SERVICE_COMPONENT_TYPE);
1193 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1194 createCategotyRest.getErrorCode().intValue());
1195 categoryDefinition.setName("At & T");
1196 categoryDefinition.setNormalizedName("at & t");
1197 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1198 // Get service category and validate that category added as defined
1199 // (also set catalog uniqeId)
1200 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1201 SERVICE_COMPONENT_TYPE);
1202 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1203 getAllCategoriesRest.getErrorCode().intValue());
1204 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1206 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1207 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1211 public void categoryNameValidationLessThanMinLengthAfterNormalization() throws Exception {
1212 categoryDefinition.setName(" A&&&&&&&&&&&&&&&&&T ");
1213 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
1214 SERVICE_COMPONENT_TYPE);
1215 assertEquals("Check response code after create Category", STATUS_CODE_INVALID_CONTENT,
1216 createCategotyRest.getErrorCode().intValue());
1217 categoryDefinition.setNormalizedName("a&t");
1218 // get service category and validate that category was not added
1219 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1220 SERVICE_COMPONENT_TYPE);
1221 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1222 getAllCategoriesRest.getErrorCode().intValue());
1223 CategoryValidationUtils.verifyCategoryNotExistsInGetResponse(getAllCategoriesRest, categoryDefinition);
1225 AuditValidationUtils.categoryAuditFailure(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1226 ActionStatus.COMPONENT_ELEMENT_INVALID_NAME_LENGTH, STATUS_CODE_INVALID_CONTENT, AUDIT_SERVICE_TYPE,
1227 "Service", "category");
1231 public void categoryNameValidationIsNull() throws Exception {
1232 categoryDefinition.setName(null);
1233 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
1234 SERVICE_COMPONENT_TYPE);
1235 assertEquals("Check response code after create Category", STATUS_CODE_INVALID_CONTENT,
1236 createCategotyRest.getErrorCode().intValue());
1237 // get service category and validate that category was not added
1238 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1239 SERVICE_COMPONENT_TYPE);
1240 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1241 getAllCategoriesRest.getErrorCode().intValue());
1242 CategoryValidationUtils.verifyCategoryNotExistsInGetResponse(getAllCategoriesRest, categoryDefinition);
1244 AuditValidationUtils.categoryAuditFailure(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1245 ActionStatus.COMPONENT_ELEMENT_INVALID_NAME_LENGTH, STATUS_CODE_INVALID_CONTENT, AUDIT_SERVICE_TYPE,
1246 "Service", "category");
1250 public void categoryNameValidationIsEmpty() throws Exception {
1251 categoryDefinition.setName("");
1252 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
1253 SERVICE_COMPONENT_TYPE);
1254 assertEquals("Check response code after create Category", STATUS_CODE_INVALID_CONTENT,
1255 createCategotyRest.getErrorCode().intValue());
1256 categoryDefinition.setNormalizedName("");
1257 // get service category and validate that category was not added
1258 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1259 SERVICE_COMPONENT_TYPE);
1260 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1261 getAllCategoriesRest.getErrorCode().intValue());
1262 CategoryValidationUtils.verifyCategoryNotExistsInGetResponse(getAllCategoriesRest, categoryDefinition);
1264 AuditValidationUtils.categoryAuditFailure(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1265 ActionStatus.COMPONENT_ELEMENT_INVALID_NAME_FORMAT, STATUS_CODE_INVALID_CONTENT, AUDIT_SERVICE_TYPE,
1266 "Service", "category");
1270 public void categoryNameValidationInvalidCharacters() throws Exception {
1271 char invalidChars[] = { '~', '!', '$', '%', '^', '*', '(', ')', '"', '{', '}', '[', ']', '?', '>', '<', '/',
1273 for (int i = 0; i < invalidChars.length; i++) {
1274 DbUtils.deleteFromEsDbByPattern("_all");
1275 // DbUtils.cleanAllAudits();
1276 categoryDefinition.setName("AbcD123" + invalidChars[i]);
1277 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
1278 SERVICE_COMPONENT_TYPE);
1279 assertEquals("Check response code after create Category", STATUS_CODE_INVALID_CONTENT,
1280 createCategotyRest.getErrorCode().intValue());
1281 categoryDefinition.setNormalizedName("");
1282 // get service category and validate that category was not added
1283 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1284 SERVICE_COMPONENT_TYPE);
1285 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1286 getAllCategoriesRest.getErrorCode().intValue());
1287 CategoryValidationUtils.verifyCategoryNotExistsInGetResponse(getAllCategoriesRest, categoryDefinition);
1289 AuditValidationUtils.categoryAuditFailure(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1290 ActionStatus.COMPONENT_ELEMENT_INVALID_NAME_FORMAT, STATUS_CODE_INVALID_CONTENT, AUDIT_SERVICE_TYPE,
1291 "Service", "category");
1296 public void categoryNameValidationSameNameDifferentResourceType() throws Exception { // same
1300 // service/resource/product
1303 String name = ("Abcd");
1304 CategoryDefinition categoryDataDefinition1 = new CategoryDefinition();
1305 CategoryDefinition categoryDataDefinition2 = new CategoryDefinition();
1306 CategoryDefinition categoryDataDefinition3 = new CategoryDefinition();
1307 categoryDataDefinition1.setName(name);
1308 categoryDataDefinition2.setName(name);
1309 categoryDataDefinition3.setName(name);
1310 // CREATE CATEGORY FOR SERVICE
1311 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDataDefinition1,
1312 sdncAdminUserDetails, SERVICE_COMPONENT_TYPE);
1313 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1314 createCategotyRest.getErrorCode().intValue());
1315 categoryDataDefinition1.setNormalizedName("abcd");
1316 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDataDefinition1);
1317 // get service category and validate that category added as defined
1318 // (also set catalog uniqeId)
1319 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1320 SERVICE_COMPONENT_TYPE);
1321 assertEquals("Check response code after get all categories ", STATUS_CODE_SUCCESS,
1322 getAllCategoriesRest.getErrorCode().intValue());
1323 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDataDefinition1); // also
1328 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDataDefinition1, sdncAdminUserDetails,
1329 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1330 // CREATE CATEGORY FOR RESOURCE_COMPONENT_TYPE
1331 DbUtils.deleteFromEsDbByPattern("_all");
1332 createCategotyRest = CategoryRestUtils.createCategory(categoryDataDefinition2, sdncAdminUserDetails,
1333 RESOURCE_COMPONENT_TYPE);
1334 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1335 createCategotyRest.getErrorCode().intValue());
1336 categoryDataDefinition2.setNormalizedName("abcd");
1337 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDataDefinition2);
1339 getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails, RESOURCE_COMPONENT_TYPE);
1340 assertEquals("Check response code after get all categories ", STATUS_CODE_SUCCESS,
1341 getAllCategoriesRest.getErrorCode().intValue());
1342 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDataDefinition2);
1344 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDataDefinition2, sdncAdminUserDetails,
1345 STATUS_CODE_CREATED, AUDIT_RESOURCE_TYPE);
1346 // CREATE CATEGORY FOR PRODUCT
1347 DbUtils.deleteFromEsDbByPattern("_all");
1348 RestResponse addCategotyRest = CategoryRestUtils.createCategory(categoryDataDefinition3,
1349 sdncProductStrategistUserDetails, PRODUCT_COMPONENT_TYPE);
1350 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1351 addCategotyRest.getErrorCode().intValue());
1352 categoryDataDefinition3.setNormalizedName("abcd");
1353 CategoryValidationUtils.validateCreateCategoryResponse(addCategotyRest, categoryDataDefinition3);
1356 getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails, PRODUCT_COMPONENT_TYPE);
1357 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1358 getAllCategoriesRest.getErrorCode().intValue());
1359 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDataDefinition3);
1361 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncProductStrategistUserDetails,
1362 STATUS_CODE_CREATED, AUDIT_PRODUCT_TYPE);
1366 public void categoryNameValidationFirstLetterOfKeyWordsCapitalized() throws Exception { // First
1373 categoryDefinition.setName("beNNy shaY michEl");
1374 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
1375 SERVICE_COMPONENT_TYPE);
1376 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1377 createCategotyRest.getErrorCode().intValue());
1378 categoryDefinition.setName("BeNNy ShaY MichEl");
1379 categoryDefinition.setNormalizedName("benny shay michel");
1380 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1381 // Get service category and validate that category added as defined
1382 // (also set catalog uniqeId)
1383 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1384 SERVICE_COMPONENT_TYPE);
1385 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1386 getAllCategoriesRest.getErrorCode().intValue());
1387 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1389 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1390 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1394 public void categoryNameValidationConjunctions_01() throws Exception { // Normalize
1410 categoryDefinition.setName(" bank OF america ");
1411 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
1412 SERVICE_COMPONENT_TYPE);
1413 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1414 createCategotyRest.getErrorCode().intValue());
1415 categoryDefinition.setName("Bank of America");
1416 categoryDefinition.setNormalizedName("bank of america");
1417 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1418 // Get service category and validate that category added as defined
1419 // (also set catalog uniqeId)
1420 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1421 SERVICE_COMPONENT_TYPE);
1422 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1423 getAllCategoriesRest.getErrorCode().intValue());
1424 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1426 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1427 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1431 public void categoryNameValidationConjunctions_02() throws Exception { // Normalize
1447 categoryDefinition.setName("THE america bank ");
1448 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
1449 SERVICE_COMPONENT_TYPE);
1450 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1451 createCategotyRest.getErrorCode().intValue());
1452 categoryDefinition.setName("THE America Bank");
1453 categoryDefinition.setNormalizedName("the america bank");
1454 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1455 // Get service category and validate that category added as defined
1456 // (also set catalog uniqeId)
1457 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1458 SERVICE_COMPONENT_TYPE);
1459 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1460 getAllCategoriesRest.getErrorCode().intValue());
1461 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1463 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1464 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1468 public void categoryNameValidationConjunctions_03() throws Exception { // Normalize
1484 categoryDefinition.setName(" A bank OF america ");
1485 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
1486 SERVICE_COMPONENT_TYPE);
1487 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1488 createCategotyRest.getErrorCode().intValue());
1489 categoryDefinition.setName("A Bank of America");
1490 categoryDefinition.setNormalizedName("a bank of america");
1491 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1492 // Get service category and validate that category added as defined
1493 // (also set catalog uniqeId)
1494 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1495 SERVICE_COMPONENT_TYPE);
1496 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1497 getAllCategoriesRest.getErrorCode().intValue());
1498 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1500 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1501 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1505 public void categoryNameValidationConjunctions_04() throws Exception { // Normalize
1521 categoryDefinition.setName(" bank america is A big ban ");
1522 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
1523 SERVICE_COMPONENT_TYPE);
1524 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1525 createCategotyRest.getErrorCode().intValue());
1526 categoryDefinition.setName("Bank America Is a Big Ban");
1527 categoryDefinition.setNormalizedName("bank america is a big ban");
1528 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1529 // Get service category and validate that category added as defined
1530 // (also set catalog uniqeId)
1531 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1532 SERVICE_COMPONENT_TYPE);
1533 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1534 getAllCategoriesRest.getErrorCode().intValue());
1535 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1537 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1538 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1542 public void categoryNameValidationConjunctions_05() throws Exception { // Normalize
1558 categoryDefinition.setName(" aN apple comPany inC ");
1559 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
1560 SERVICE_COMPONENT_TYPE);
1561 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1562 createCategotyRest.getErrorCode().intValue());
1563 categoryDefinition.setName("AN Apple ComPany InC");
1564 categoryDefinition.setNormalizedName("an apple company inc");
1565 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1566 // Get service category and validate that category added as defined
1567 // (also set catalog uniqeId)
1568 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1569 SERVICE_COMPONENT_TYPE);
1570 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1571 getAllCategoriesRest.getErrorCode().intValue());
1572 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1574 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1575 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1579 public void categoryNameValidationConjunctions_06() throws Exception { // Normalize
1595 categoryDefinition.setName(" eat AN apple ANAN");
1596 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
1597 SERVICE_COMPONENT_TYPE);
1598 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1599 createCategotyRest.getErrorCode().intValue());
1600 categoryDefinition.setName("Eat an Apple ANAN");
1601 categoryDefinition.setNormalizedName("eat an apple anan");
1602 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1603 // Get service category and validate that category added as defined
1604 // (also set catalog uniqeId)
1605 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1606 SERVICE_COMPONENT_TYPE);
1607 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1608 getAllCategoriesRest.getErrorCode().intValue());
1609 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1611 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1612 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1616 public void categoryNameValidationConjunctions_07() throws Exception { // Normalize
1632 categoryDefinition.setName(" united states OF americA ");
1633 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
1634 SERVICE_COMPONENT_TYPE);
1635 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1636 createCategotyRest.getErrorCode().intValue());
1637 categoryDefinition.setName("United States of AmericA");
1638 categoryDefinition.setNormalizedName("united states of america");
1639 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1640 // Get service category and validate that category added as defined
1641 // (also set catalog uniqeId)
1642 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1643 SERVICE_COMPONENT_TYPE);
1644 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1645 getAllCategoriesRest.getErrorCode().intValue());
1646 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1648 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1649 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1654 public void categoryNameValidationConjunctions_08() throws Exception { // Normalize
1670 categoryDefinition.setName(" oF united states OF amer ");
1671 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
1672 SERVICE_COMPONENT_TYPE);
1673 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1674 createCategotyRest.getErrorCode().intValue());
1675 categoryDefinition.setName("OF United States of Amer");
1676 categoryDefinition.setNormalizedName("of united states of amer");
1677 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1678 // Get service category and validate that category added as defined
1679 // (also set catalog uniqeId)
1680 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1681 SERVICE_COMPONENT_TYPE);
1682 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1683 getAllCategoriesRest.getErrorCode().intValue());
1684 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1686 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1687 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1691 public void categoryNameValidationConjunctions_09() throws Exception { // Normalize
1707 categoryDefinition.setName(" to Apple TO at&T TOO ");
1708 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
1709 SERVICE_COMPONENT_TYPE);
1710 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1711 createCategotyRest.getErrorCode().intValue());
1712 categoryDefinition.setName("To Apple to At&T TOO");
1713 categoryDefinition.setNormalizedName("to apple to at&t too");
1714 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1715 // Get service category and validate that category added as defined
1716 // (also set catalog uniqeId)
1717 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1718 SERVICE_COMPONENT_TYPE);
1719 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1720 getAllCategoriesRest.getErrorCode().intValue());
1721 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1723 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1724 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1728 public void categoryNameValidationConjunctions_10() throws Exception { // Normalize
1744 categoryDefinition.setName(" eat apple AS you liiikeas ");
1745 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
1746 SERVICE_COMPONENT_TYPE);
1747 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1748 createCategotyRest.getErrorCode().intValue());
1749 categoryDefinition.setName("Eat Apple as You Liiikeas");
1750 categoryDefinition.setNormalizedName("eat apple as you liiikeas");
1751 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1752 // Get service category and validate that category added as defined
1753 // (also set catalog uniqeId)
1754 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1755 SERVICE_COMPONENT_TYPE);
1756 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1757 getAllCategoriesRest.getErrorCode().intValue());
1758 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1760 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1761 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1765 public void categoryNameValidationConjunctions_11() throws Exception { // Normalize
1781 categoryDefinition.setName(" as you may want ");
1782 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
1783 SERVICE_COMPONENT_TYPE);
1784 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1785 createCategotyRest.getErrorCode().intValue());
1786 categoryDefinition.setName("As You May Want");
1787 categoryDefinition.setNormalizedName("as you may want");
1788 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1789 // Get service category and validate that category added as defined
1790 // (also set catalog uniqeId)
1791 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1792 SERVICE_COMPONENT_TYPE);
1793 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1794 getAllCategoriesRest.getErrorCode().intValue());
1795 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1797 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1798 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1802 public void categoryNameValidationConjunctions_12() throws Exception { // Normalize
1818 categoryDefinition.setName(" the bank OF america ");
1819 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
1820 SERVICE_COMPONENT_TYPE);
1821 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1822 createCategotyRest.getErrorCode().intValue());
1823 categoryDefinition.setName("The Bank of America");
1824 categoryDefinition.setNormalizedName("the bank of america");
1825 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1826 // Get service category and validate that category added as defined
1827 // (also set catalog uniqeId)
1828 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1829 SERVICE_COMPONENT_TYPE);
1830 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1831 getAllCategoriesRest.getErrorCode().intValue());
1832 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1834 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1835 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1840 public void categoryNameValidationConjunctions_13() throws Exception { // Normalize
1856 categoryDefinition.setName(" To tel-toto ");
1857 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
1858 SERVICE_COMPONENT_TYPE);
1859 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1860 createCategotyRest.getErrorCode().intValue());
1861 categoryDefinition.setName("To Tel-toto");
1862 categoryDefinition.setNormalizedName("to tel-toto");
1863 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1864 // Get service category and validate that category added as defined
1865 // (also set catalog uniqeId)
1866 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1867 SERVICE_COMPONENT_TYPE);
1868 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1869 getAllCategoriesRest.getErrorCode().intValue());
1870 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1872 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1873 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1878 public void categoryNameValidationConjunctions_14() throws Exception { // Normalize
1894 categoryDefinition.setName(" tel-aviv To la ");
1895 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
1896 SERVICE_COMPONENT_TYPE);
1897 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1898 createCategotyRest.getErrorCode().intValue());
1899 categoryDefinition.setName("Tel-aviv to La");
1900 categoryDefinition.setNormalizedName("tel-aviv to la");
1901 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1902 // Get service category and validate that category added as defined
1903 // (also set catalog uniqeId)
1904 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1905 SERVICE_COMPONENT_TYPE);
1906 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1907 getAllCategoriesRest.getErrorCode().intValue());
1908 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1910 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1911 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1915 public void createServiceCategoryHttpCspUserIdIsEmpty() throws Exception {
1916 User sdncAdminUserDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
1917 sdncAdminUserDetails1.setUserId("");
1918 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
1919 SERVICE_COMPONENT_TYPE);
1920 assertEquals("Check response code after create Consumer", STATUS_CODE_MISSING_INFORMATION,
1921 createCategotyRest.getErrorCode().intValue());
1922 categoryDefinition.setName("Abcd");
1923 // get service category and validate that category was not added
1924 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1925 SERVICE_COMPONENT_TYPE);
1926 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1927 getAllCategoriesRest.getErrorCode().intValue());
1928 CategoryValidationUtils.verifyCategoryNotExistsInGetResponse(getAllCategoriesRest, categoryDefinition);
1930 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.MISSING_INFORMATION.name());
1931 ExpectedCategoryAudit expectedCatrgoryAuditJavaObject = new ExpectedCategoryAudit();
1932 expectedCatrgoryAuditJavaObject.setAction(ADD_CATEGORY);
1933 expectedCatrgoryAuditJavaObject.setModifier("");
1934 expectedCatrgoryAuditJavaObject.setCategoryName(categoryDefinition.getName());
1935 expectedCatrgoryAuditJavaObject.setSubCategoryName("");
1936 expectedCatrgoryAuditJavaObject.setGroupingName("");
1937 expectedCatrgoryAuditJavaObject.setResourceType(AUDIT_SERVICE_TYPE);
1938 expectedCatrgoryAuditJavaObject.setStatus(String.valueOf(STATUS_CODE_MISSING_INFORMATION));
1939 expectedCatrgoryAuditJavaObject.setDesc(errorInfo.getAuditDesc());
1940 AuditValidationUtils.validateCategoryAudit(expectedCatrgoryAuditJavaObject, ADD_CATEGORY);
1944 public void createServiceCategorHttpCspUserIdIsNull() throws Exception {
1945 User sdncAdminUserDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
1946 sdncAdminUserDetails1.setUserId(null);
1947 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
1948 SERVICE_COMPONENT_TYPE);
1949 assertEquals("Check response code after create Consumer", STATUS_CODE_MISSING_INFORMATION,
1950 createCategotyRest.getErrorCode().intValue());
1951 categoryDefinition.setName("Abcd");
1952 // get service category and validate that category was not added
1953 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1954 SERVICE_COMPONENT_TYPE);
1955 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1956 getAllCategoriesRest.getErrorCode().intValue());
1957 CategoryValidationUtils.verifyCategoryNotExistsInGetResponse(getAllCategoriesRest, categoryDefinition);
1959 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.MISSING_INFORMATION.name());
1960 ExpectedCategoryAudit expectedCatrgoryAuditJavaObject = new ExpectedCategoryAudit();
1961 expectedCatrgoryAuditJavaObject.setAction(ADD_CATEGORY);
1962 expectedCatrgoryAuditJavaObject.setModifier("");
1963 expectedCatrgoryAuditJavaObject.setCategoryName(categoryDefinition.getName());
1964 expectedCatrgoryAuditJavaObject.setSubCategoryName("");
1965 expectedCatrgoryAuditJavaObject.setGroupingName("");
1966 expectedCatrgoryAuditJavaObject.setResourceType(AUDIT_SERVICE_TYPE);
1967 expectedCatrgoryAuditJavaObject.setStatus(String.valueOf(STATUS_CODE_MISSING_INFORMATION));
1968 expectedCatrgoryAuditJavaObject.setDesc(errorInfo.getAuditDesc());
1969 AuditValidationUtils.validateCategoryAudit(expectedCatrgoryAuditJavaObject, ADD_CATEGORY);
1973 public void createSrvcCategoryHttpCspUserIdHeaderIsMissing() throws Exception {
1974 RestResponse createConsumerRest = CategoryRestUtils
1975 .createServiceCategoryHttpCspAtuUidIsMissing(categoryDefinition, sdncAdminUserDetails);
1976 assertEquals("Check response code after create Consumer", STATUS_CODE_MISSING_INFORMATION,
1977 createConsumerRest.getErrorCode().intValue());
1978 categoryDefinition.setName("Abcd");
1979 // get service category and validate that category was not added
1980 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1981 SERVICE_COMPONENT_TYPE);
1982 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1983 getAllCategoriesRest.getErrorCode().intValue());
1984 CategoryValidationUtils.verifyCategoryNotExistsInGetResponse(getAllCategoriesRest, categoryDefinition);
1986 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.MISSING_INFORMATION.name());
1987 ExpectedCategoryAudit expectedCatrgoryAuditJavaObject = new ExpectedCategoryAudit();
1988 expectedCatrgoryAuditJavaObject.setAction(ADD_CATEGORY);
1989 expectedCatrgoryAuditJavaObject.setModifier("");
1990 expectedCatrgoryAuditJavaObject.setCategoryName(categoryDefinition.getName());
1991 expectedCatrgoryAuditJavaObject.setSubCategoryName("");
1992 expectedCatrgoryAuditJavaObject.setGroupingName("");
1993 expectedCatrgoryAuditJavaObject.setResourceType(AUDIT_SERVICE_TYPE);
1994 expectedCatrgoryAuditJavaObject.setStatus(String.valueOf(STATUS_CODE_MISSING_INFORMATION));
1995 expectedCatrgoryAuditJavaObject.setDesc(errorInfo.getAuditDesc());
1996 AuditValidationUtils.validateCategoryAudit(expectedCatrgoryAuditJavaObject, ADD_CATEGORY);
2000 public void getServiceCategoryHierarchySuccessFlow() throws Exception {
2002 int numOfCategories = 3;
2003 List<CategoryDefinition> categories = new ArrayList<CategoryDefinition>();
2004 RestResponse restResponse;
2005 CategoryDefinition category;
2006 String categoryName = categoryDefinition.getName();
2007 for (int i = 0; i < numOfCategories; i++) {
2008 categoryDefinition.setName(categoryName + i);
2009 restResponse = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
2010 SERVICE_COMPONENT_TYPE);
2011 category = ResponseParser.parseToObject(restResponse.getResponse(), CategoryDefinition.class);
2012 categories.add(category);
2014 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
2015 SERVICE_COMPONENT_TYPE);
2016 assertEquals("Check response code after get all categories ", STATUS_CODE_SUCCESS,
2017 getAllCategoriesRest.getErrorCode().intValue());
2019 AuditValidationUtils.GetCategoryHierarchyAuditSuccess(GET_CATEGORY_HIERARCHY, AUDIT_SERVICE_TYPE,
2020 sdncAdminUserDetails, STATUS_CODE_SUCCESS);
2021 for (CategoryDefinition categoryCurr : categories) {
2022 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryCurr);
2026 ///////////////////////////////// US570520 /////////////////////////////////
2027 private List<CategoryDefinition> defineCategories() throws Exception {
2028 String firstCategory = "FirstCategory";
2029 String secondCategory = "secondCategory";
2030 String thirdCategory = "ThirdCategory";
2031 String forthCategory = "forthCategory";
2032 CategoryDefinition category1 = new CategoryDefinition(categoryDefinition);
2033 category1.setName(firstCategory);
2034 CategoryDefinition category2 = new CategoryDefinition(categoryDefinition);
2035 category2.setName(secondCategory);
2036 CategoryDefinition category3 = new CategoryDefinition(categoryDefinition);
2037 category3.setName(thirdCategory);
2038 CategoryDefinition category4 = new CategoryDefinition(categoryDefinition);
2039 category4.setName(forthCategory);
2040 ArrayList<CategoryDefinition> categoryList = new ArrayList<CategoryDefinition>();
2041 categoryList.add(category1);
2042 categoryList.add(category2);
2043 categoryList.add(category3);
2044 categoryList.add(category4);
2045 return categoryList;
2049 public void getAllResourceCategoriesHirarchy() throws Exception {
2050 createAndValidateCategoriesExist(RESOURCE_COMPONENT_TYPE, categoryList);
2052 for (int i = 0; i < categoryList.size(); i++) {
2053 List<String> subCategorieUniqueIdList = new ArrayList<String>();
2054 for (int j = 0; j < subCategoryList.size(); j++) {
2055 RestResponse createSubCategory = CategoryRestUtils.createSubCategory(subCategoryList.get(j),
2056 categoryList.get(i), sdncAdminUserDetails, RESOURCE_COMPONENT_TYPE);
2057 if (createSubCategory.getErrorCode().intValue() == STATUS_CODE_CREATED) {
2058 String subCategoryUniqeId = ResponseParser.getUniqueIdFromResponse(createSubCategory);
2059 subCategorieUniqueIdList.add(subCategoryUniqeId);
2060 subCategoriesToDeleteMap.put(categoryList.get(i).getUniqueId(), subCategorieUniqueIdList);
2065 DbUtils.deleteFromEsDbByPattern("_all");
2066 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
2067 RESOURCE_COMPONENT_TYPE);
2068 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
2069 getAllCategoriesRest.getErrorCode().intValue());
2071 for (int i = 0; i < categoryList.size(); i++) {
2072 for (int j = 0; j < subCategoryList.size(); j++) {
2073 CategoryValidationUtils.verifySubCategoryExistInGetResponse(getAllCategoriesRest,
2074 categoryList.get(i).getUniqueId(), subCategoryList.get(j));
2078 checkAuditSuccess(RESOURCE_COMPONENT_TYPE);
2081 private List<SubCategoryDefinition> defineSubCategories(int catListSize) {
2082 List<SubCategoryDefinition> subCatList = new ArrayList<SubCategoryDefinition>();
2083 for (int j = 1; j <= catListSize; j++) {
2084 SubCategoryDefinition subCategory = new SubCategoryDefinition();
2085 subCategory.setName("SubCategory" + String.valueOf(j));
2086 subCatList.add(subCategory);
2091 private void createAndValidateCategoriesExist(String comp, List<CategoryDefinition> categoryList) throws Exception {
2092 createCategories(comp, categoryList);
2093 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails, comp);
2094 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
2095 getAllCategoriesRest.getErrorCode().intValue());
2096 verifyCategoriesExist(categoryList, getAllCategoriesRest);
2099 private void verifyCategoriesExist(List<CategoryDefinition> categoryList, RestResponse getAllCategoriesRest) {
2100 for (int i = 0; i < categoryList.size(); i++) {
2101 categoryList.get(i).setName(WordUtils.capitalize(categoryList.get(i).getName()));
2102 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryList.get(i));
2106 private void createCategories(String comp, List<CategoryDefinition> categoryList) throws Exception {
2107 for (int i = 0; i < categoryList.size(); i++) {
2108 CategoryRestUtils.createCategory(categoryList.get(i), sdncAdminUserDetails, comp);
2113 public void getAllServiceCategoriesHirarchy() throws Exception {
2114 // deleteCategories(categoryList, SERVICE_COMPONENT_TYPE);
2115 createAndValidateCategoriesExist(SERVICE_COMPONENT_TYPE, categoryList);
2116 checkAuditSuccess(SERVICE_COMPONENT_TYPE);
2117 // deleteCategories(categoryList, SERVICE_COMPONENT_TYPE);
2121 public void getAllResourceCategories_noAttUserHeader() throws Exception {
2122 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(new User(), RESOURCE_COMPONENT_TYPE);
2123 assertEquals("Check response code after get Category", 403, getAllCategoriesRest.getErrorCode().intValue());
2124 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_INFORMATION.name(), new ArrayList<String>(),
2125 getAllCategoriesRest.getResponse());
2127 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.MISSING_INFORMATION.name());
2128 ExpectedCategoryAudit expectedCatrgoryAuditJavaObject = new ExpectedCategoryAudit();
2129 expectedCatrgoryAuditJavaObject.setAction(GET_CATEGORY_HIERARCHY);
2130 expectedCatrgoryAuditJavaObject.setModifierName("");
2131 expectedCatrgoryAuditJavaObject.setModifierUid("");
2132 expectedCatrgoryAuditJavaObject.setDetails(RESOURCE_COMPONENT_TYPE);
2133 expectedCatrgoryAuditJavaObject.setStatus(String.valueOf(STATUS_CODE_MISSING_INFORMATION));
2134 expectedCatrgoryAuditJavaObject.setDesc(errorInfo.getAuditDesc());
2135 AuditValidationUtils.validateGetCategoryHirarchy(expectedCatrgoryAuditJavaObject, GET_CATEGORY_HIERARCHY);
2139 public void getAllResourceCategories_userNotProvisioned() throws Exception {
2140 User notProvisionedUser = new User();
2141 notProvisionedUser.setUserId("aa0001");
2142 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(notProvisionedUser,
2143 RESOURCE_COMPONENT_TYPE);
2144 assertEquals("Check response code after get Category", 409, getAllCategoriesRest.getErrorCode().intValue());
2145 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(),
2146 getAllCategoriesRest.getResponse());
2148 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name());
2149 ExpectedCategoryAudit expectedCatrgoryAuditJavaObject = new ExpectedCategoryAudit();
2150 expectedCatrgoryAuditJavaObject.setAction(GET_CATEGORY_HIERARCHY);
2151 expectedCatrgoryAuditJavaObject.setModifierName("");
2152 expectedCatrgoryAuditJavaObject.setModifierUid(notProvisionedUser.getUserId());
2153 expectedCatrgoryAuditJavaObject.setDetails(RESOURCE_COMPONENT_TYPE);
2154 expectedCatrgoryAuditJavaObject.setStatus(String.valueOf(STATUS_CODE_RESTRICTED_OPERATION));
2155 expectedCatrgoryAuditJavaObject.setDesc(errorInfo.getAuditDesc());
2156 AuditValidationUtils.validateGetCategoryHirarchy(expectedCatrgoryAuditJavaObject, GET_CATEGORY_HIERARCHY);
2160 public void getAllResourceCategories_unsupportedComponent() throws Exception {
2161 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails, "comp");
2162 assertEquals("Check response code after get all categories hirarchy", 400,
2163 getAllCategoriesRest.getErrorCode().intValue());
2164 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.UNSUPPORTED_ERROR.name(),
2165 new ArrayList<String>(Arrays.asList("component type")), getAllCategoriesRest.getResponse());
2167 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.UNSUPPORTED_ERROR.name());
2168 ExpectedCategoryAudit expectedCatrgoryAuditJavaObject = new ExpectedCategoryAudit();
2169 expectedCatrgoryAuditJavaObject.setAction(GET_CATEGORY_HIERARCHY);
2170 expectedCatrgoryAuditJavaObject.setModifierUid(sdncAdminUserDetails.getUserId());
2171 expectedCatrgoryAuditJavaObject.setModifierName(sdncAdminUserDetails.getFullName());
2172 expectedCatrgoryAuditJavaObject.setDetails("comp");
2173 expectedCatrgoryAuditJavaObject.setStatus(String.valueOf(STATUS_CODE_INVALID_CONTENT));
2174 expectedCatrgoryAuditJavaObject.setDesc(AuditValidationUtils.buildAuditDescription(errorInfo,
2175 new ArrayList<String>(Arrays.asList("component type"))));
2176 AuditValidationUtils.validateGetCategoryHirarchy(expectedCatrgoryAuditJavaObject, GET_CATEGORY_HIERARCHY);
2179 @Test(enabled = false)
2180 public void getAllResourceCategories_emptyList() throws Exception {
2181 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
2182 RESOURCE_COMPONENT_TYPE);
2183 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
2184 getAllCategoriesRest.getErrorCode().intValue());
2185 JSONArray jArr = new JSONArray(getAllCategoriesRest.getResponse());
2186 assertTrue(jArr.length() == 0);
2188 checkAuditSuccess(RESOURCE_COMPONENT_TYPE);
2191 private void checkAuditSuccess(String componentType) throws Exception {
2192 ExpectedCategoryAudit expectedCatrgoryAuditJavaObject = new ExpectedCategoryAudit();
2193 expectedCatrgoryAuditJavaObject.setAction(GET_CATEGORY_HIERARCHY);
2194 expectedCatrgoryAuditJavaObject.setModifierName(sdncAdminUserDetails.getFullName());
2195 expectedCatrgoryAuditJavaObject.setModifierUid(sdncAdminUserDetails.getUserId());
2196 expectedCatrgoryAuditJavaObject.setDetails(componentType);
2197 expectedCatrgoryAuditJavaObject.setStatus("200");
2198 expectedCatrgoryAuditJavaObject.setDesc("OK");
2199 AuditValidationUtils.validateGetCategoryHirarchy(expectedCatrgoryAuditJavaObject, GET_CATEGORY_HIERARCHY);
2202 @Test(enabled = false)
2203 public void getAllServiceCategories_emptyList() throws Exception {
2204 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
2205 SERVICE_COMPONENT_TYPE);
2206 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
2207 getAllCategoriesRest.getErrorCode().intValue());
2208 JSONArray jArr = new JSONArray(getAllCategoriesRest.getResponse());
2209 assertTrue(jArr.length() == 0);
2211 checkAuditSuccess(SERVICE_COMPONENT_TYPE);
2214 @Test(enabled = false)
2215 public void getAllProductCategories_emptyList() throws Exception {
2216 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
2217 PRODUCT_COMPONENT_TYPE);
2218 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
2219 getAllCategoriesRest.getErrorCode().intValue());
2220 JSONArray jArr = new JSONArray(getAllCategoriesRest.getResponse());
2221 assertTrue(jArr.length() == 0);
2223 checkAuditSuccess(PRODUCT_COMPONENT_TYPE);
2227 // public void getAllResourceCategories_generalError() throws Exception
2229 // User user = new User();
2230 // RestResponse getAllCategoriesRest =
2231 // CategoryRestUtils.getAllCategories(user, SERVICE_COMPONENT_TYPE);
2232 // assertEquals("Check response code after get Category", 500,
2233 // getAllCategoriesRest.getErrorCode().intValue());
2234 // Utils.checkBodyResponseOnError(ActionStatus.GENERAL_ERROR.name(), new
2235 // ArrayList<String>(), getAllCategoriesRest.getResponse());
2238 //////////////////////////////////////////////////////////////////////////////
2241 public void importCategories() throws Exception {
2243 String importResourceDir = config.getImportTypesConfigDir() + File.separator + "categoryTypesTest.zip";
2245 MultipartEntityBuilder mpBuilder = MultipartEntityBuilder.create();
2246 mpBuilder.addPart("categoriesZip", new FileBody(new File(importResourceDir)));
2248 RestResponse importResult = CategoryRestUtils.importCategories(mpBuilder, sdncAdminUserDetails.getUserId());
2249 assertEquals("Check response code after Import", BaseRestUtils.STATUS_CODE_CREATED,
2250 importResult.getErrorCode().intValue());
2252 Map<String, Object> map = ResponseParser.parseToObjectUsingMapper(importResult.getResponse(), Map.class);
2253 assertEquals("Check entries count", 2, map.size());
2255 List<Map<String, Object>> resources = (List<Map<String, Object>>) map.get("resources");
2256 assertEquals("Check resource category entries count", 1, resources.size());
2258 List<Map<String, Object>> services = (List<Map<String, Object>>) map.get("services");
2259 assertEquals("Check resource category entries count", 2, services.size());
2261 RestResponse allCategories = CategoryRestUtils.getAllCategories(sdncAdminUserDetails, "resources");
2262 List<CategoryDefinition> resourceCategories = ResponseParser.parseCategories(allCategories);
2263 for (Map<String, Object> resource : resources) {
2264 boolean exist = false;
2266 for (CategoryDefinition categ : resourceCategories) {
2267 if (categ.getName().equals(resource.get("name"))) {
2272 assertTrue("Check existance resource category " + resource.get("name"), exist);
2275 allCategories = CategoryRestUtils.getAllCategories(sdncAdminUserDetails, "services");
2276 List<CategoryDefinition> servicesCategories = ResponseParser.parseCategories(allCategories);
2277 for (Map<String, Object> service : services) {
2278 boolean exist = false;
2280 for (CategoryDefinition categ : servicesCategories) {
2281 if (categ.getName().equals(service.get("name"))) {
2286 assertTrue("Check existance service category " + service.get("name"), exist);