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 static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.PRODUCT_COMPONENT_TYPE;
24 import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.RESOURCE_COMPONENT_TYPE;
25 import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.SERVICE_COMPONENT_TYPE;
26 import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_ALREADY_EXISTS;
27 import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_CREATED;
28 import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_INVALID_CONTENT;
29 import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_MISSING_INFORMATION;
30 import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_RESTRICTED_OPERATION;
31 import static org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils.STATUS_CODE_SUCCESS;
32 import static org.testng.AssertJUnit.assertEquals;
33 import static org.testng.AssertJUnit.assertTrue;
36 import java.util.ArrayList;
37 import java.util.Arrays;
38 import java.util.HashMap;
39 import java.util.List;
42 import org.apache.commons.lang3.text.WordUtils;
43 import org.apache.http.entity.mime.MultipartEntityBuilder;
44 import org.apache.http.entity.mime.content.FileBody;
45 import org.json.JSONArray;
46 import org.junit.Rule;
47 import org.junit.rules.TestName;
48 import org.openecomp.sdc.be.dao.api.ActionStatus;
49 import org.openecomp.sdc.be.model.User;
50 import org.openecomp.sdc.be.model.category.CategoryDefinition;
51 import org.openecomp.sdc.be.model.category.SubCategoryDefinition;
52 import org.openecomp.sdc.ci.tests.datatypes.enums.ErrorInfo;
53 import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
54 import org.openecomp.sdc.ci.tests.datatypes.expected.ExpectedCategoryAudit;
55 import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
56 import org.openecomp.sdc.ci.tests.utils.DbUtils;
57 import org.openecomp.sdc.ci.tests.utils.Utils;
58 import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
59 import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils;
60 import org.openecomp.sdc.ci.tests.utils.rest.CategoryRestUtils;
61 import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
62 import org.openecomp.sdc.ci.tests.utils.validation.AuditValidationUtils;
63 import org.openecomp.sdc.ci.tests.utils.validation.CategoryValidationUtils;
64 import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils;
65 import org.testng.SkipException;
66 import org.testng.annotations.BeforeMethod;
67 import org.testng.annotations.Test;
69 public class CategoriesTests extends CategoriesBaseTest {
71 private static final String GET_CATEGORY_HIERARCHY = "GetCategoryHierarchy";
72 protected static final String ADD_CATEGORY = "AddCategory";
73 protected static final String DELETE_CATEGORY = "DeleteCategory";
75 public CategoriesTests() {
76 super(name, CategoriesTests.class.getName());
80 public static TestName name = new TestName();
81 private CategoryDefinition categoryDefinition;
82 private List<CategoryDefinition> categoryList;
83 private List<SubCategoryDefinition> subCategoryList;
84 private Map<String, List<String>> subCategoriesToDeleteMap;
87 public void init() throws Exception {
88 subCategoriesToDeleteMap = new HashMap<String, List<String>>();
89 DbUtils.deleteFromEsDbByPattern("_all");
91 categoryDefinition = new CategoryDefinition();
92 categoryDefinition.setName("Abcd");
93 categoryList = defineCategories();
94 subCategoryList = defineSubCategories(categoryList.size());
99 public void createServiceCategorySuccessFlow() throws Exception {
101 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
102 SERVICE_COMPONENT_TYPE);
103 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
104 createCategotyRest.getErrorCode().intValue());
105 categoryDefinition.setNormalizedName("abcd");
106 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
108 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
109 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
110 // get service category and validate that category added as defined
111 // (also set catalog uniqeId)
112 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
113 SERVICE_COMPONENT_TYPE);
114 assertEquals("Check response code after get all categories ", STATUS_CODE_SUCCESS,
115 getAllCategoriesRest.getErrorCode().intValue());
116 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition); // also
125 public void createResourceCategorySuccessFlow() throws Exception {
126 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
127 RESOURCE_COMPONENT_TYPE);
128 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
129 createCategotyRest.getErrorCode().intValue());
130 categoryDefinition.setNormalizedName("abcd");
131 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
133 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
134 RESOURCE_COMPONENT_TYPE);
135 assertEquals("Check response code after get all categories ", STATUS_CODE_SUCCESS,
136 getAllCategoriesRest.getErrorCode().intValue());
137 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
139 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
140 STATUS_CODE_CREATED, AUDIT_RESOURCE_TYPE);
145 public void createProductCategorySuccessFlow() throws Exception {
146 // Add Category by Product-strategist
147 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition,
148 sdncProductStrategistUserDetails, PRODUCT_COMPONENT_TYPE);
149 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
150 createCategotyRest.getErrorCode().intValue());
151 categoryDefinition.setNormalizedName("abcd");
152 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
155 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
156 PRODUCT_COMPONENT_TYPE);
157 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
158 getAllCategoriesRest.getErrorCode().intValue());
159 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
161 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncProductStrategistUserDetails,
162 STATUS_CODE_CREATED, AUDIT_PRODUCT_TYPE);
166 public void CategoryNameValidation_FirstWordStartWithAlphaNumeric_01() throws Exception { // category
169 categoryDefinition.setName("Category14AadE &&&---+++.'''###=:@@@____");
170 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
171 SERVICE_COMPONENT_TYPE);
172 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
173 createCategotyRest.getErrorCode().intValue());
174 categoryDefinition.setName("Category14AadE &-+.'#=:@_");
175 categoryDefinition.setNormalizedName("category14aade &-+.'#=:@_");
176 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
177 // Get service category and validate that category added as defined
178 // (also set catalog uniqeId)
179 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
180 SERVICE_COMPONENT_TYPE);
181 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
182 getAllCategoriesRest.getErrorCode().intValue());
183 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
185 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
186 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
190 public void categoryNameValidation_FirstWordStartWithAlphaNumeric_02() throws Exception { // category
193 categoryDefinition.setName("Category14AadE &&&---+++.'''###=:@@@____");
194 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
195 RESOURCE_COMPONENT_TYPE);
196 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
197 createCategotyRest.getErrorCode().intValue());
198 categoryDefinition.setName("Category14AadE &-+.'#=:@_");
199 categoryDefinition.setNormalizedName("category14aade &-+.'#=:@_");
200 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
201 // Get service category and validate that category added as defined
202 // (also set catalog uniqeId)
203 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
204 RESOURCE_COMPONENT_TYPE);
205 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
206 getAllCategoriesRest.getErrorCode().intValue());
207 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
209 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
210 STATUS_CODE_CREATED, AUDIT_RESOURCE_TYPE);
214 public void categoryNameValidation_FirstWordStartWithAlphaNumeric_03() throws Exception { // category
217 categoryDefinition.setName("Category14AadE &&&---+++.'''###=:@@@____");
218 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition,
219 sdncProductStrategistUserDetails, PRODUCT_COMPONENT_TYPE);
220 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
221 createCategotyRest.getErrorCode().intValue());
222 categoryDefinition.setName("Category14AadE &-+.'#=:@_");
223 categoryDefinition.setNormalizedName("category14aade &-+.'#=:@_");
224 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
225 // Get service category and validate that category added as defined
226 // (also set catalog uniqeId)
227 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
228 PRODUCT_COMPONENT_TYPE);
229 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
230 getAllCategoriesRest.getErrorCode().intValue());
231 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
233 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncProductStrategistUserDetails,
234 STATUS_CODE_CREATED, AUDIT_PRODUCT_TYPE);
239 public void createServiceCategoryByNonAdminUser() throws Exception {
241 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition,
242 sdncProductStrategistUserDetails, SERVICE_COMPONENT_TYPE);
243 assertEquals("Check response code after create Category", STATUS_CODE_RESTRICTED_OPERATION,
244 createCategotyRest.getErrorCode().intValue());
245 // get service category and validate that category was not added
246 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
247 SERVICE_COMPONENT_TYPE);
248 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
249 getAllCategoriesRest.getErrorCode().intValue());
250 CategoryValidationUtils.verifyCategoryNotExistsInGetResponse(getAllCategoriesRest, categoryDefinition);
252 AuditValidationUtils.categoryAuditFailure(ADD_CATEGORY, categoryDefinition, sdncProductStrategistUserDetails,
253 ActionStatus.RESTRICTED_OPERATION, STATUS_CODE_RESTRICTED_OPERATION, AUDIT_SERVICE_TYPE);
258 public void createResourceCategoryByNonAdminUser() throws Exception {
259 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition,
260 sdncProductStrategistUserDetails, RESOURCE_COMPONENT_TYPE);
261 assertEquals("Check response code after create Category", STATUS_CODE_RESTRICTED_OPERATION,
262 createCategotyRest.getErrorCode().intValue());
263 // get service category and validate that category was not added
264 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
265 RESOURCE_COMPONENT_TYPE);
266 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
267 getAllCategoriesRest.getErrorCode().intValue());
268 CategoryValidationUtils.verifyCategoryNotExistsInGetResponse(getAllCategoriesRest, categoryDefinition);
270 AuditValidationUtils.categoryAuditFailure(ADD_CATEGORY, categoryDefinition, sdncProductStrategistUserDetails,
271 ActionStatus.RESTRICTED_OPERATION, STATUS_CODE_RESTRICTED_OPERATION, AUDIT_RESOURCE_TYPE);
276 public void createProductCategoryByNonProductStrategistUser() throws Exception {
277 // Add New product category not by Product-Strategist
278 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
279 PRODUCT_COMPONENT_TYPE);
280 assertEquals("Check response code after create Category", STATUS_CODE_RESTRICTED_OPERATION,
281 createCategotyRest.getErrorCode().intValue());
282 // get service category and validate that category was not added
283 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
284 PRODUCT_COMPONENT_TYPE);
285 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
286 getAllCategoriesRest.getErrorCode().intValue());
287 CategoryValidationUtils.verifyCategoryNotExistsInGetResponse(getAllCategoriesRest, categoryDefinition);
289 AuditValidationUtils.categoryAuditFailure(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
290 ActionStatus.RESTRICTED_OPERATION, STATUS_CODE_RESTRICTED_OPERATION, AUDIT_PRODUCT_TYPE);
296 public void addCategoryByNonExistingUser() throws Exception {
297 User sdncAdminUserDetailsNonExisting = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
298 sdncAdminUserDetailsNonExisting.setUserId("bt555h");
300 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition,
301 sdncAdminUserDetailsNonExisting, SERVICE_COMPONENT_TYPE);
302 assertEquals("Check response code after create Category", STATUS_CODE_RESTRICTED_OPERATION,
303 createCategotyRest.getErrorCode().intValue());
304 // get service category and validate that category was not added
305 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
306 SERVICE_COMPONENT_TYPE);
307 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
308 getAllCategoriesRest.getErrorCode().intValue());
309 CategoryValidationUtils.verifyCategoryNotExistsInGetResponse(getAllCategoriesRest, categoryDefinition);
311 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name());
312 ExpectedCategoryAudit expectedCatrgoryAuditJavaObject = new ExpectedCategoryAudit();
313 expectedCatrgoryAuditJavaObject.setAction(ADD_CATEGORY);
314 expectedCatrgoryAuditJavaObject.setModifier("(" + sdncAdminUserDetailsNonExisting.getUserId() + ")");
315 expectedCatrgoryAuditJavaObject.setCategoryName(categoryDefinition.getName());
316 expectedCatrgoryAuditJavaObject.setSubCategoryName("");
317 expectedCatrgoryAuditJavaObject.setGroupingName("");
318 expectedCatrgoryAuditJavaObject.setResourceType(AUDIT_SERVICE_TYPE);
319 expectedCatrgoryAuditJavaObject.setStatus(String.valueOf(STATUS_CODE_RESTRICTED_OPERATION));
320 expectedCatrgoryAuditJavaObject.setDesc(errorInfo.getAuditDesc());
321 AuditValidationUtils.validateCategoryAudit(expectedCatrgoryAuditJavaObject, ADD_CATEGORY);
325 public void addServiceCategoryAllowedcharacters_01() throws Exception {
326 categoryDefinition.setName("1234AbcdE&");
327 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
328 SERVICE_COMPONENT_TYPE);
329 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
330 createCategotyRest.getErrorCode().intValue());
331 categoryDefinition.setNormalizedName("1234abcde&"); // normalization
332 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
333 // Get service category and validate that category added as defined
334 // (also set catalog uniqeId)
335 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
336 SERVICE_COMPONENT_TYPE);
337 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
338 getAllCategoriesRest.getErrorCode().intValue());
339 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
341 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
342 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
346 public void addServiceCategoryAllowedcharacters_02() throws Exception {
347 categoryDefinition.setName("1234AbcdE-");
348 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
349 SERVICE_COMPONENT_TYPE);
350 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
351 createCategotyRest.getErrorCode().intValue());
352 categoryDefinition.setNormalizedName("1234abcde-"); // normalization
353 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
354 // Get service category and validate that category added as defined
355 // (also set catalog uniqeId)
356 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
357 SERVICE_COMPONENT_TYPE);
358 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
359 getAllCategoriesRest.getErrorCode().intValue());
360 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
362 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
363 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
367 public void addServiceCategoryAllowedcharacters_03() throws Exception {
368 categoryDefinition.setName("1234AbcdE+");
369 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
370 SERVICE_COMPONENT_TYPE);
371 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
372 createCategotyRest.getErrorCode().intValue());
373 categoryDefinition.setNormalizedName("1234abcde+"); // normalization
374 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
375 // Get service category and validate that category added as defined
376 // (also set catalog uniqeId)
377 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
378 SERVICE_COMPONENT_TYPE);
379 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
380 getAllCategoriesRest.getErrorCode().intValue());
381 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
383 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
384 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
388 public void addServiceCategoryAllowedcharacters_04() throws Exception {
389 categoryDefinition.setName("1234AbcdE.");
390 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
391 SERVICE_COMPONENT_TYPE);
392 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
393 createCategotyRest.getErrorCode().intValue());
394 categoryDefinition.setNormalizedName("1234abcde."); // normalization
395 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
396 // Get service category and validate that category added as defined
397 // (also set catalog uniqeId)
398 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
399 SERVICE_COMPONENT_TYPE);
400 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
401 getAllCategoriesRest.getErrorCode().intValue());
402 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
404 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
405 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
409 public void addServiceCategoryAllowedcharacters_05() throws Exception {
410 categoryDefinition.setName("1234AbcdE'");
411 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
412 SERVICE_COMPONENT_TYPE);
413 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
414 createCategotyRest.getErrorCode().intValue());
415 categoryDefinition.setNormalizedName("1234abcde'");
416 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
417 // Get service category and validate that category added as defined
418 // (also set catalog uniqeId)
419 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
420 SERVICE_COMPONENT_TYPE);
421 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
422 getAllCategoriesRest.getErrorCode().intValue());
423 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
425 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
426 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
430 public void addServiceCategoryAllowedcharacters_06() throws Exception {
431 categoryDefinition.setName("1234AbcdE=");
432 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
433 SERVICE_COMPONENT_TYPE);
434 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
435 createCategotyRest.getErrorCode().intValue());
436 categoryDefinition.setNormalizedName("1234abcde="); // normalization
437 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
438 // Get service category and validate that category added as defined
439 // (also set catalog uniqeId)
440 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
441 SERVICE_COMPONENT_TYPE);
442 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
443 getAllCategoriesRest.getErrorCode().intValue());
444 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
446 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
447 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
451 public void addServiceCategoryAllowedcharacters_07() throws Exception {
452 categoryDefinition.setName("1234AbcdE:");
453 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
454 SERVICE_COMPONENT_TYPE);
455 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
456 createCategotyRest.getErrorCode().intValue());
457 categoryDefinition.setNormalizedName("1234abcde:"); // normalization
458 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
459 // Get service category and validate that category added as defined
460 // (also set catalog uniqeId)
461 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
462 SERVICE_COMPONENT_TYPE);
463 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
464 getAllCategoriesRest.getErrorCode().intValue());
465 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
467 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
468 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
472 public void addServiceCategoryAllowedcharacters_08() throws Exception {
473 categoryDefinition.setName("1234AbcdE@");
474 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
475 SERVICE_COMPONENT_TYPE);
476 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
477 createCategotyRest.getErrorCode().intValue());
478 categoryDefinition.setNormalizedName("1234abcde@"); // normalization
479 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
480 // Get service category and validate that category added as defined
481 // (also set catalog uniqeId)
482 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
483 SERVICE_COMPONENT_TYPE);
484 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
485 getAllCategoriesRest.getErrorCode().intValue());
486 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
488 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
489 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
493 public void addServiceCategoryAllowedcharacters_09() throws Exception {
494 categoryDefinition.setName("1234AbcdE_");
495 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
496 SERVICE_COMPONENT_TYPE);
497 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
498 createCategotyRest.getErrorCode().intValue());
499 categoryDefinition.setNormalizedName("1234abcde_"); // normalization
500 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
501 // Get service category and validate that category added as defined
502 // (also set catalog uniqeId)
503 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
504 SERVICE_COMPONENT_TYPE);
505 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
506 getAllCategoriesRest.getErrorCode().intValue());
507 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
509 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
510 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
514 public void addServiceCategoryAllowedcharacters_10() throws Exception {
515 categoryDefinition.setName("1234AbcdE#");
516 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
517 SERVICE_COMPONENT_TYPE);
518 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
519 createCategotyRest.getErrorCode().intValue());
520 categoryDefinition.setNormalizedName("1234abcde#"); // normalization
521 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
522 // Get service category and validate that category added as defined
523 // (also set catalog uniqeId)
524 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
525 SERVICE_COMPONENT_TYPE);
526 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
527 getAllCategoriesRest.getErrorCode().intValue());
528 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
530 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
531 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
535 public void addServiceCategoryAllowedcharacters_11() throws Exception {
536 categoryDefinition.setName("1234AbcdE d");
537 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
538 SERVICE_COMPONENT_TYPE);
539 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
540 createCategotyRest.getErrorCode().intValue());
541 categoryDefinition.setNormalizedName("1234abcde d"); // normalization
542 categoryDefinition.setName("1234AbcdE D");
543 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
544 // Get service category and validate that category added as defined
545 // (also set catalog uniqeId)
546 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
547 SERVICE_COMPONENT_TYPE);
548 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
549 getAllCategoriesRest.getErrorCode().intValue());
550 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
552 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
553 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
557 public void addServiceCategoryAllowedcharacters_12() throws Exception {
558 categoryDefinition.setName("1234AbcdE &_=+.-'#:@ d");
559 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
560 SERVICE_COMPONENT_TYPE);
561 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
562 createCategotyRest.getErrorCode().intValue());
563 categoryDefinition.setNormalizedName("1234abcde &_=+.-'#:@ d"); // normalization
564 categoryDefinition.setName("1234AbcdE &_=+.-'#:@ D");
565 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
566 // Get service category and validate that category added as defined
567 // (also set catalog uniqeId)
568 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
569 SERVICE_COMPONENT_TYPE);
570 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
571 getAllCategoriesRest.getErrorCode().intValue());
572 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
574 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
575 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
579 public void categoryNameValidation_RemoveSpaceFromBeginning() throws Exception {
580 categoryDefinition.setName(" Category01");
581 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
582 SERVICE_COMPONENT_TYPE);
583 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
584 createCategotyRest.getErrorCode().intValue());
585 categoryDefinition.setNormalizedName("category01"); // normalization
586 categoryDefinition.setName("Category01");
587 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
588 // Get service category and validate that category added as defined
589 // (also set catalog uniqeId)
590 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
591 SERVICE_COMPONENT_TYPE);
592 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
593 getAllCategoriesRest.getErrorCode().intValue());
594 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
596 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
597 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
601 public void categoryNameValidation_RemoveSpaceFromEnd() throws Exception {
602 categoryDefinition.setName("Category01 ");
603 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
604 SERVICE_COMPONENT_TYPE);
605 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
606 createCategotyRest.getErrorCode().intValue());
607 categoryDefinition.setNormalizedName("category01"); // normalization
608 categoryDefinition.setName("Category01");
609 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
610 // Get service category and validate that category added as defined
611 // (also set catalog uniqeId)
612 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
613 SERVICE_COMPONENT_TYPE);
614 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
615 getAllCategoriesRest.getErrorCode().intValue());
616 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
618 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
619 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
623 public void categoryNameValidation_RemoveExtraSpace() throws Exception {
624 categoryDefinition.setName("Category 02");
625 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
626 SERVICE_COMPONENT_TYPE);
627 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
628 createCategotyRest.getErrorCode().intValue());
629 categoryDefinition.setNormalizedName("category 02"); // normalization
630 categoryDefinition.setName("Category 02");
631 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
632 // Get service category and validate that category added as defined
633 // (also set catalog uniqeId)
634 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
635 SERVICE_COMPONENT_TYPE);
636 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
637 getAllCategoriesRest.getErrorCode().intValue());
638 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
640 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
641 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
645 public void categoryNameValidation_RemoveExtraAmpersand() throws Exception {
646 categoryDefinition.setName("Category&& &02");
647 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
648 SERVICE_COMPONENT_TYPE);
649 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
650 createCategotyRest.getErrorCode().intValue());
651 categoryDefinition.setNormalizedName("category& &02"); // normalization
652 categoryDefinition.setName("Category& &02");
653 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
654 // Get service category and validate that category added as defined
655 // (also set catalog uniqeId)
656 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
657 SERVICE_COMPONENT_TYPE);
658 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
659 getAllCategoriesRest.getErrorCode().intValue());
660 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
662 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
663 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
667 public void categoryNameValidation_RemoveExtraDash() throws Exception {
668 categoryDefinition.setName("CategorY-- --02");
669 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
670 SERVICE_COMPONENT_TYPE);
671 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
672 createCategotyRest.getErrorCode().intValue());
673 categoryDefinition.setName("CategorY- -02");
674 categoryDefinition.setNormalizedName("category- -02");
675 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
676 // Get service category and validate that category added as defined
677 // (also set catalog uniqeId)
678 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
679 SERVICE_COMPONENT_TYPE);
680 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
681 getAllCategoriesRest.getErrorCode().intValue());
682 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
684 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
685 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
689 public void categoryNameValidation_RemoveExtraPlus() throws Exception {
690 categoryDefinition.setName("CateGory++++ +02");
691 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
692 SERVICE_COMPONENT_TYPE);
693 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
694 createCategotyRest.getErrorCode().intValue());
695 categoryDefinition.setName("CateGory+ +02");
696 categoryDefinition.setNormalizedName("category+ +02");
697 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
698 // Get service category and validate that category added as defined
699 // (also set catalog uniqeId)
700 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
701 SERVICE_COMPONENT_TYPE);
702 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
703 getAllCategoriesRest.getErrorCode().intValue());
704 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
706 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
707 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
711 public void categoryNameValidation_RemoveExtraPeriod() throws Exception {
712 categoryDefinition.setName("Category.... .02");
713 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
714 SERVICE_COMPONENT_TYPE);
715 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
716 createCategotyRest.getErrorCode().intValue());
717 categoryDefinition.setName("Category. .02");
718 categoryDefinition.setNormalizedName("category. .02");
719 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
720 // Get service category and validate that category added as defined
721 // (also set catalog uniqeId)
722 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
723 SERVICE_COMPONENT_TYPE);
724 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
725 getAllCategoriesRest.getErrorCode().intValue());
726 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
728 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
729 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
733 public void categoryNameValidation_RemoveExtraApostrophe() throws Exception {
734 categoryDefinition.setName("CaTegory''' '02");
735 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
736 SERVICE_COMPONENT_TYPE);
737 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
738 createCategotyRest.getErrorCode().intValue());
739 categoryDefinition.setName("CaTegory' '02");
740 categoryDefinition.setNormalizedName("category' '02");
741 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
742 // Get service category and validate that category added as defined
743 // (also set catalog uniqeId)
744 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
745 SERVICE_COMPONENT_TYPE);
746 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
747 getAllCategoriesRest.getErrorCode().intValue());
748 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
750 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
751 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
755 public void categoryNameValidation_RemoveExtraHashtag() throws Exception {
756 categoryDefinition.setName("Category### #02");
757 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
758 SERVICE_COMPONENT_TYPE);
759 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
760 createCategotyRest.getErrorCode().intValue());
761 categoryDefinition.setName("Category# #02");
762 categoryDefinition.setNormalizedName("category# #02");
763 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
764 // Get service category and validate that category added as defined
765 // (also set catalog uniqeId)
766 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
767 SERVICE_COMPONENT_TYPE);
768 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
769 getAllCategoriesRest.getErrorCode().intValue());
770 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
772 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
773 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
777 public void categoryNameValidation_RemoveExtrEequal() throws Exception {
778 categoryDefinition.setName("Category=== =02");
779 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
780 SERVICE_COMPONENT_TYPE);
781 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
782 createCategotyRest.getErrorCode().intValue());
783 categoryDefinition.setName("Category= =02");
784 categoryDefinition.setNormalizedName("category= =02");
785 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
786 // Get service category and validate that category added as defined
787 // (also set catalog uniqeId)
788 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
789 SERVICE_COMPONENT_TYPE);
790 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
791 getAllCategoriesRest.getErrorCode().intValue());
792 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
794 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
795 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
799 public void categoryNameValidation_RemoveExtrColon() throws Exception {
800 categoryDefinition.setName("Category::: :02");
801 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
802 SERVICE_COMPONENT_TYPE);
803 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
804 createCategotyRest.getErrorCode().intValue());
805 categoryDefinition.setName("Category: :02");
806 categoryDefinition.setNormalizedName("category: :02");
807 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
808 // Get service category and validate that category added as defined
809 // (also set catalog uniqeId)
810 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
811 SERVICE_COMPONENT_TYPE);
812 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
813 getAllCategoriesRest.getErrorCode().intValue());
814 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
816 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
817 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
821 public void categoryNameValidation_RemoveExtrAt() throws Exception {
822 categoryDefinition.setName("Category@@@ @a2");
823 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
824 SERVICE_COMPONENT_TYPE);
825 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
826 createCategotyRest.getErrorCode().intValue());
827 categoryDefinition.setName("Category@ @a2");
828 categoryDefinition.setNormalizedName("category@ @a2");
829 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
830 // Get service category and validate that category added as defined
831 // (also set catalog uniqeId)
832 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
833 SERVICE_COMPONENT_TYPE);
834 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
835 getAllCategoriesRest.getErrorCode().intValue());
836 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
838 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
839 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
843 public void categoryNameValidation_RemoveExtraUnderscore() throws Exception {
844 categoryDefinition.setName("Category___ _22");
845 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
846 SERVICE_COMPONENT_TYPE);
847 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
848 createCategotyRest.getErrorCode().intValue());
849 categoryDefinition.setName("Category_ _22");
850 categoryDefinition.setNormalizedName("category_ _22");
851 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
852 // Get service category and validate that category added as defined
853 // (also set catalog uniqeId)
854 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
855 SERVICE_COMPONENT_TYPE);
856 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
857 getAllCategoriesRest.getErrorCode().intValue());
858 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
860 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
861 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
865 public void categoryNameValidation_FirstWordStartWithNumber() throws Exception {
866 categoryDefinition.setName("1Category one");
867 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
868 SERVICE_COMPONENT_TYPE);
869 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
870 createCategotyRest.getErrorCode().intValue());
871 categoryDefinition.setName("1Category One");
872 categoryDefinition.setNormalizedName("1category one");
873 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
874 // Get service category and validate that category added as defined
875 // (also set catalog uniqeId)
876 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
877 SERVICE_COMPONENT_TYPE);
878 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
879 getAllCategoriesRest.getErrorCode().intValue());
880 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
882 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
883 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
887 public void categoryNameValidation_FirstWordStartWithNonAlphaNumeric() throws Exception { // The
899 char invalidChars[] = { '&', '-', '+', '.', '\'', '#', '=', ':', '@', '_' };
900 for (int i = 0; i < invalidChars.length; i++) {
901 DbUtils.deleteFromEsDbByPattern("_all");
902 categoryDefinition.setName(invalidChars[i] + "AbcD123");
903 categoryDefinition.setNormalizedName((invalidChars[i] + "AbcD123").toLowerCase());
904 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition,
905 sdncAdminUserDetails1, SERVICE_COMPONENT_TYPE);
906 assertEquals("Check response code after create Category", STATUS_CODE_INVALID_CONTENT,
907 createCategotyRest.getErrorCode().intValue());
909 // get service category and validate that category was not added
910 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
911 SERVICE_COMPONENT_TYPE);
912 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
913 getAllCategoriesRest.getErrorCode().intValue());
914 CategoryValidationUtils.verifyCategoryNotExistsInGetResponse(getAllCategoriesRest, categoryDefinition);
916 AuditValidationUtils.categoryAuditFailure(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails1,
917 ActionStatus.COMPONENT_ELEMENT_INVALID_NAME_FORMAT, STATUS_CODE_INVALID_CONTENT, AUDIT_SERVICE_TYPE,
918 "Service", "category");
924 public void addServiceCategoryAlreadyExist_uniqueness() throws Exception { // Verify
930 // non-case-sensitive,
941 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
942 SERVICE_COMPONENT_TYPE);
943 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
944 createCategotyRest.getErrorCode().intValue());
945 categoryDefinition.setNormalizedName("abcd");
946 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
947 // get service category and validate that category added as defined
948 // (also set catalog uniqeId)
949 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
950 SERVICE_COMPONENT_TYPE);
951 assertEquals("Check response code after get all categories ", STATUS_CODE_SUCCESS,
952 getAllCategoriesRest.getErrorCode().intValue());
953 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition); // also
958 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
959 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
960 // Create same category name again
961 DbUtils.deleteFromEsDbByPattern("_all");
962 CategoryDefinition categoryDataDefinition2 = new CategoryDefinition();
963 categoryDataDefinition2.setName(categoryDefinition.getName());
964 RestResponse addDuplicateCategoryRest = CategoryRestUtils.createCategory(categoryDataDefinition2,
965 sdncAdminUserDetails, SERVICE_COMPONENT_TYPE);
966 assertEquals("Check response code after create Category", STATUS_CODE_ALREADY_EXISTS,
967 addDuplicateCategoryRest.getErrorCode().intValue());
969 AuditValidationUtils.categoryAuditFailure(ADD_CATEGORY, categoryDataDefinition2, sdncAdminUserDetails,
970 ActionStatus.COMPONENT_CATEGORY_ALREADY_EXISTS, STATUS_CODE_ALREADY_EXISTS, AUDIT_SERVICE_TYPE,
971 "Service", categoryDefinition.getName());
972 // Get Category and verify that category was created is not deleted
973 getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails, SERVICE_COMPONENT_TYPE);
974 assertEquals("Check response code after get all categories ", STATUS_CODE_SUCCESS,
975 getAllCategoriesRest.getErrorCode().intValue());
976 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
981 public void categoryNameValidation_ReplaceAndWithAmpersand_01() throws Exception {
982 categoryDefinition.setName("At and T");
983 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
984 SERVICE_COMPONENT_TYPE);
985 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
986 createCategotyRest.getErrorCode().intValue());
987 categoryDefinition.setName("At & T");
988 categoryDefinition.setNormalizedName("at & t");
989 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
990 // Get service category and validate that category added as defined
991 // (also set catalog uniqeId)
992 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
993 SERVICE_COMPONENT_TYPE);
994 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
995 getAllCategoriesRest.getErrorCode().intValue());
996 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
998 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
999 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1003 public void categoryNameValidation_ReplaceAndWithAmpersand_02() throws Exception {
1004 categoryDefinition.setName("At and t");
1005 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
1006 SERVICE_COMPONENT_TYPE);
1007 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1008 createCategotyRest.getErrorCode().intValue());
1009 categoryDefinition.setName("At & T");
1010 categoryDefinition.setNormalizedName("at & t");
1011 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1012 // Get service category and validate that category added as defined
1013 // (also set catalog uniqeId)
1014 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1015 SERVICE_COMPONENT_TYPE);
1016 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1017 getAllCategoriesRest.getErrorCode().intValue());
1018 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1020 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1021 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1025 public void categoryNameValidation_ReplaceAndWithAmpersand_03() throws Exception {
1026 categoryDefinition.setName("Atand T");
1027 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
1028 SERVICE_COMPONENT_TYPE);
1029 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1030 createCategotyRest.getErrorCode().intValue());
1031 categoryDefinition.setNormalizedName("atand t");
1032 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1033 // Get service category and validate that category added as defined
1034 // (also set catalog uniqeId)
1035 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1036 SERVICE_COMPONENT_TYPE);
1037 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1038 getAllCategoriesRest.getErrorCode().intValue());
1039 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1041 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1042 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1046 public void categoryNameValidation_ReplaceAndWithAmpersand_04() throws Exception {
1047 categoryDefinition.setName("At andT");
1048 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
1049 SERVICE_COMPONENT_TYPE);
1050 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1051 createCategotyRest.getErrorCode().intValue());
1052 categoryDefinition.setNormalizedName("at andt");
1053 categoryDefinition.setName("At AndT");
1054 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1055 // Get service category and validate that category added as defined
1056 // (also set catalog uniqeId)
1057 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1058 SERVICE_COMPONENT_TYPE);
1059 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1060 getAllCategoriesRest.getErrorCode().intValue());
1061 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1063 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1064 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1068 public void categoryNameValidation_ReplaceAndWithAmpersand_05() throws Exception {
1069 categoryDefinition.setName(" and AttT");
1070 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
1071 SERVICE_COMPONENT_TYPE);
1072 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1073 createCategotyRest.getErrorCode().intValue());
1074 categoryDefinition.setNormalizedName("and attt");
1075 categoryDefinition.setName("And AttT");
1076 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1077 // Get service category and validate that category added as defined
1078 // (also set catalog uniqeId)
1079 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1080 SERVICE_COMPONENT_TYPE);
1081 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1082 getAllCategoriesRest.getErrorCode().intValue());
1083 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1085 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1086 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1090 public void categoryNameValidation_ReplaceAndWithAmpersand_06() throws Exception {
1091 categoryDefinition.setName("AttT and ");
1092 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
1093 SERVICE_COMPONENT_TYPE);
1094 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1095 createCategotyRest.getErrorCode().intValue());
1096 categoryDefinition.setNormalizedName("attt and");
1097 categoryDefinition.setName("AttT And");
1098 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1099 // Get service category and validate that category added as defined
1100 // (also set catalog uniqeId)
1101 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1102 SERVICE_COMPONENT_TYPE);
1103 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1104 getAllCategoriesRest.getErrorCode().intValue());
1105 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1107 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1108 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1113 public void categoryNameValidation_ReplaceAndWithAmpersand_07() throws Exception {
1114 categoryDefinition.setName(" and a");
1115 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
1116 SERVICE_COMPONENT_TYPE);
1117 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1118 createCategotyRest.getErrorCode().intValue());
1119 categoryDefinition.setNormalizedName("and a");
1120 categoryDefinition.setName("And a");
1121 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1122 // Get service category and validate that category added as defined
1123 // (also set catalog uniqeId)
1124 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1125 SERVICE_COMPONENT_TYPE);
1126 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1127 getAllCategoriesRest.getErrorCode().intValue());
1128 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1130 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1131 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1135 public void categoryNameValidationMaxLength() throws Exception {
1136 categoryDefinition.setName("AsdfghjQ234567890@#.&:+-_");
1137 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
1138 SERVICE_COMPONENT_TYPE);
1139 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1140 createCategotyRest.getErrorCode().intValue());
1141 categoryDefinition.setNormalizedName("asdfghjq234567890@#.&:+-_");
1142 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1143 // Get service category and validate that category added as defined
1144 // (also set catalog uniqeId)
1145 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1146 SERVICE_COMPONENT_TYPE);
1147 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1148 getAllCategoriesRest.getErrorCode().intValue());
1149 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1151 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1152 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1157 public void categoryNameValidationMaxLengthAfterNormalization() throws Exception {
1158 categoryDefinition.setName(" A jQ234 @@@___ +++ At and T and and ");
1159 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
1160 SERVICE_COMPONENT_TYPE);
1161 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1162 createCategotyRest.getErrorCode().intValue());
1163 categoryDefinition.setName("A JQ234 @_ + At & T & And");
1164 categoryDefinition.setNormalizedName("a jq234 @_ + at & t & and");
1165 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1166 // Get service category and validate that category added as defined
1167 // (also set catalog uniqeId)
1168 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1169 SERVICE_COMPONENT_TYPE);
1170 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1171 getAllCategoriesRest.getErrorCode().intValue());
1172 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1174 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1175 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1180 public void categoryNameValidationExceedMaxLengthAfterNormalization() throws Exception {
1181 categoryDefinition.setName(" AbdfghBCVa jQ234 @@___ +++ At and T ");
1182 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
1183 SERVICE_COMPONENT_TYPE);
1184 assertEquals("Check response code after create Category", STATUS_CODE_INVALID_CONTENT,
1185 createCategotyRest.getErrorCode().intValue());
1186 categoryDefinition.setNormalizedName("abdfghbcva jq234 @_ + at&t");
1187 // get service category and validate that category was not added
1188 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1189 SERVICE_COMPONENT_TYPE);
1190 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1191 getAllCategoriesRest.getErrorCode().intValue());
1192 CategoryValidationUtils.verifyCategoryNotExistsInGetResponse(getAllCategoriesRest, categoryDefinition);
1194 AuditValidationUtils.categoryAuditFailure(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1195 ActionStatus.COMPONENT_ELEMENT_INVALID_NAME_LENGTH, STATUS_CODE_INVALID_CONTENT, AUDIT_SERVICE_TYPE,
1196 "Service", "category");
1200 public void categoryNameValidationMinLengthAfterNormalization() throws Exception { // MinLengthAfterNormalization
1204 categoryDefinition.setName(" At and T ");
1205 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
1206 SERVICE_COMPONENT_TYPE);
1207 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1208 createCategotyRest.getErrorCode().intValue());
1209 categoryDefinition.setName("At & T");
1210 categoryDefinition.setNormalizedName("at & t");
1211 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1212 // Get service category and validate that category added as defined
1213 // (also set catalog uniqeId)
1214 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1215 SERVICE_COMPONENT_TYPE);
1216 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1217 getAllCategoriesRest.getErrorCode().intValue());
1218 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1220 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1221 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1225 public void categoryNameValidationLessThanMinLengthAfterNormalization() throws Exception {
1226 categoryDefinition.setName(" A&&&&&&&&&&&&&&&&&T ");
1227 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
1228 SERVICE_COMPONENT_TYPE);
1229 assertEquals("Check response code after create Category", STATUS_CODE_INVALID_CONTENT,
1230 createCategotyRest.getErrorCode().intValue());
1231 categoryDefinition.setNormalizedName("a&t");
1232 // get service category and validate that category was not added
1233 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1234 SERVICE_COMPONENT_TYPE);
1235 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1236 getAllCategoriesRest.getErrorCode().intValue());
1237 CategoryValidationUtils.verifyCategoryNotExistsInGetResponse(getAllCategoriesRest, categoryDefinition);
1239 AuditValidationUtils.categoryAuditFailure(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1240 ActionStatus.COMPONENT_ELEMENT_INVALID_NAME_LENGTH, STATUS_CODE_INVALID_CONTENT, AUDIT_SERVICE_TYPE,
1241 "Service", "category");
1245 public void categoryNameValidationIsNull() throws Exception {
1246 categoryDefinition.setName(null);
1247 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
1248 SERVICE_COMPONENT_TYPE);
1249 assertEquals("Check response code after create Category", STATUS_CODE_INVALID_CONTENT,
1250 createCategotyRest.getErrorCode().intValue());
1251 // get service category and validate that category was not added
1252 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1253 SERVICE_COMPONENT_TYPE);
1254 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1255 getAllCategoriesRest.getErrorCode().intValue());
1256 CategoryValidationUtils.verifyCategoryNotExistsInGetResponse(getAllCategoriesRest, categoryDefinition);
1258 AuditValidationUtils.categoryAuditFailure(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1259 ActionStatus.COMPONENT_ELEMENT_INVALID_NAME_LENGTH, STATUS_CODE_INVALID_CONTENT, AUDIT_SERVICE_TYPE,
1260 "Service", "category");
1264 public void categoryNameValidationIsEmpty() throws Exception {
1265 categoryDefinition.setName("");
1266 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
1267 SERVICE_COMPONENT_TYPE);
1268 assertEquals("Check response code after create Category", STATUS_CODE_INVALID_CONTENT,
1269 createCategotyRest.getErrorCode().intValue());
1270 categoryDefinition.setNormalizedName("");
1271 // get service category and validate that category was not added
1272 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1273 SERVICE_COMPONENT_TYPE);
1274 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1275 getAllCategoriesRest.getErrorCode().intValue());
1276 CategoryValidationUtils.verifyCategoryNotExistsInGetResponse(getAllCategoriesRest, categoryDefinition);
1278 AuditValidationUtils.categoryAuditFailure(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1279 ActionStatus.COMPONENT_ELEMENT_INVALID_NAME_FORMAT, STATUS_CODE_INVALID_CONTENT, AUDIT_SERVICE_TYPE,
1280 "Service", "category");
1284 public void categoryNameValidationInvalidCharacters() throws Exception {
1285 char invalidChars[] = { '~', '!', '$', '%', '^', '*', '(', ')', '"', '{', '}', '[', ']', '?', '>', '<', '/',
1287 for (int i = 0; i < invalidChars.length; i++) {
1288 DbUtils.deleteFromEsDbByPattern("_all");
1289 // DbUtils.cleanAllAudits();
1290 categoryDefinition.setName("AbcD123" + invalidChars[i]);
1291 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
1292 SERVICE_COMPONENT_TYPE);
1293 assertEquals("Check response code after create Category", STATUS_CODE_INVALID_CONTENT,
1294 createCategotyRest.getErrorCode().intValue());
1295 categoryDefinition.setNormalizedName("");
1296 // get service category and validate that category was not added
1297 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1298 SERVICE_COMPONENT_TYPE);
1299 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1300 getAllCategoriesRest.getErrorCode().intValue());
1301 CategoryValidationUtils.verifyCategoryNotExistsInGetResponse(getAllCategoriesRest, categoryDefinition);
1303 AuditValidationUtils.categoryAuditFailure(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1304 ActionStatus.COMPONENT_ELEMENT_INVALID_NAME_FORMAT, STATUS_CODE_INVALID_CONTENT, AUDIT_SERVICE_TYPE,
1305 "Service", "category");
1310 public void categoryNameValidationSameNameDifferentResourceType() throws Exception { // same
1314 // service/resource/product
1317 String name = ("Abcd");
1318 CategoryDefinition categoryDataDefinition1 = new CategoryDefinition();
1319 CategoryDefinition categoryDataDefinition2 = new CategoryDefinition();
1320 CategoryDefinition categoryDataDefinition3 = new CategoryDefinition();
1321 categoryDataDefinition1.setName(name);
1322 categoryDataDefinition2.setName(name);
1323 categoryDataDefinition3.setName(name);
1324 // CREATE CATEGORY FOR SERVICE
1325 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDataDefinition1,
1326 sdncAdminUserDetails, SERVICE_COMPONENT_TYPE);
1327 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1328 createCategotyRest.getErrorCode().intValue());
1329 categoryDataDefinition1.setNormalizedName("abcd");
1330 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDataDefinition1);
1331 // get service category and validate that category added as defined
1332 // (also set catalog uniqeId)
1333 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1334 SERVICE_COMPONENT_TYPE);
1335 assertEquals("Check response code after get all categories ", STATUS_CODE_SUCCESS,
1336 getAllCategoriesRest.getErrorCode().intValue());
1337 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDataDefinition1); // also
1342 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDataDefinition1, sdncAdminUserDetails,
1343 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1344 // CREATE CATEGORY FOR RESOURCE_COMPONENT_TYPE
1345 DbUtils.deleteFromEsDbByPattern("_all");
1346 createCategotyRest = CategoryRestUtils.createCategory(categoryDataDefinition2, sdncAdminUserDetails,
1347 RESOURCE_COMPONENT_TYPE);
1348 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1349 createCategotyRest.getErrorCode().intValue());
1350 categoryDataDefinition2.setNormalizedName("abcd");
1351 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDataDefinition2);
1353 getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails, RESOURCE_COMPONENT_TYPE);
1354 assertEquals("Check response code after get all categories ", STATUS_CODE_SUCCESS,
1355 getAllCategoriesRest.getErrorCode().intValue());
1356 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDataDefinition2);
1358 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDataDefinition2, sdncAdminUserDetails,
1359 STATUS_CODE_CREATED, AUDIT_RESOURCE_TYPE);
1360 // CREATE CATEGORY FOR PRODUCT
1361 DbUtils.deleteFromEsDbByPattern("_all");
1362 RestResponse addCategotyRest = CategoryRestUtils.createCategory(categoryDataDefinition3,
1363 sdncProductStrategistUserDetails, PRODUCT_COMPONENT_TYPE);
1364 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1365 addCategotyRest.getErrorCode().intValue());
1366 categoryDataDefinition3.setNormalizedName("abcd");
1367 CategoryValidationUtils.validateCreateCategoryResponse(addCategotyRest, categoryDataDefinition3);
1370 getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails, PRODUCT_COMPONENT_TYPE);
1371 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1372 getAllCategoriesRest.getErrorCode().intValue());
1373 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDataDefinition3);
1375 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncProductStrategistUserDetails,
1376 STATUS_CODE_CREATED, AUDIT_PRODUCT_TYPE);
1380 public void categoryNameValidationFirstLetterOfKeyWordsCapitalized() throws Exception { // First
1387 categoryDefinition.setName("beNNy shaY michEl");
1388 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
1389 SERVICE_COMPONENT_TYPE);
1390 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1391 createCategotyRest.getErrorCode().intValue());
1392 categoryDefinition.setName("BeNNy ShaY MichEl");
1393 categoryDefinition.setNormalizedName("benny shay michel");
1394 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1395 // Get service category and validate that category added as defined
1396 // (also set catalog uniqeId)
1397 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1398 SERVICE_COMPONENT_TYPE);
1399 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1400 getAllCategoriesRest.getErrorCode().intValue());
1401 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1403 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1404 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1408 public void categoryNameValidationConjunctions_01() throws Exception { // Normalize
1424 categoryDefinition.setName(" bank OF america ");
1425 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
1426 SERVICE_COMPONENT_TYPE);
1427 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1428 createCategotyRest.getErrorCode().intValue());
1429 categoryDefinition.setName("Bank of America");
1430 categoryDefinition.setNormalizedName("bank of america");
1431 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1432 // Get service category and validate that category added as defined
1433 // (also set catalog uniqeId)
1434 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1435 SERVICE_COMPONENT_TYPE);
1436 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1437 getAllCategoriesRest.getErrorCode().intValue());
1438 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1440 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1441 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1445 public void categoryNameValidationConjunctions_02() throws Exception { // Normalize
1461 categoryDefinition.setName("THE america bank ");
1462 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
1463 SERVICE_COMPONENT_TYPE);
1464 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1465 createCategotyRest.getErrorCode().intValue());
1466 categoryDefinition.setName("THE America Bank");
1467 categoryDefinition.setNormalizedName("the america bank");
1468 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1469 // Get service category and validate that category added as defined
1470 // (also set catalog uniqeId)
1471 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1472 SERVICE_COMPONENT_TYPE);
1473 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1474 getAllCategoriesRest.getErrorCode().intValue());
1475 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1477 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1478 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1482 public void categoryNameValidationConjunctions_03() throws Exception { // Normalize
1498 categoryDefinition.setName(" A bank OF america ");
1499 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
1500 SERVICE_COMPONENT_TYPE);
1501 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1502 createCategotyRest.getErrorCode().intValue());
1503 categoryDefinition.setName("A Bank of America");
1504 categoryDefinition.setNormalizedName("a bank of america");
1505 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1506 // Get service category and validate that category added as defined
1507 // (also set catalog uniqeId)
1508 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1509 SERVICE_COMPONENT_TYPE);
1510 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1511 getAllCategoriesRest.getErrorCode().intValue());
1512 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1514 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1515 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1519 public void categoryNameValidationConjunctions_04() throws Exception { // Normalize
1535 categoryDefinition.setName(" bank america is A big ban ");
1536 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
1537 SERVICE_COMPONENT_TYPE);
1538 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1539 createCategotyRest.getErrorCode().intValue());
1540 categoryDefinition.setName("Bank America Is a Big Ban");
1541 categoryDefinition.setNormalizedName("bank america is a big ban");
1542 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1543 // Get service category and validate that category added as defined
1544 // (also set catalog uniqeId)
1545 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1546 SERVICE_COMPONENT_TYPE);
1547 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1548 getAllCategoriesRest.getErrorCode().intValue());
1549 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1551 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1552 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1556 public void categoryNameValidationConjunctions_05() throws Exception { // Normalize
1572 categoryDefinition.setName(" aN apple comPany inC ");
1573 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
1574 SERVICE_COMPONENT_TYPE);
1575 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1576 createCategotyRest.getErrorCode().intValue());
1577 categoryDefinition.setName("AN Apple ComPany InC");
1578 categoryDefinition.setNormalizedName("an apple company inc");
1579 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1580 // Get service category and validate that category added as defined
1581 // (also set catalog uniqeId)
1582 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1583 SERVICE_COMPONENT_TYPE);
1584 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1585 getAllCategoriesRest.getErrorCode().intValue());
1586 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1588 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1589 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1593 public void categoryNameValidationConjunctions_06() throws Exception { // Normalize
1609 categoryDefinition.setName(" eat AN apple ANAN");
1610 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
1611 SERVICE_COMPONENT_TYPE);
1612 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1613 createCategotyRest.getErrorCode().intValue());
1614 categoryDefinition.setName("Eat an Apple ANAN");
1615 categoryDefinition.setNormalizedName("eat an apple anan");
1616 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1617 // Get service category and validate that category added as defined
1618 // (also set catalog uniqeId)
1619 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1620 SERVICE_COMPONENT_TYPE);
1621 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1622 getAllCategoriesRest.getErrorCode().intValue());
1623 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1625 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1626 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1630 public void categoryNameValidationConjunctions_07() throws Exception { // Normalize
1646 categoryDefinition.setName(" united states OF americA ");
1647 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
1648 SERVICE_COMPONENT_TYPE);
1649 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1650 createCategotyRest.getErrorCode().intValue());
1651 categoryDefinition.setName("United States of AmericA");
1652 categoryDefinition.setNormalizedName("united states of america");
1653 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1654 // Get service category and validate that category added as defined
1655 // (also set catalog uniqeId)
1656 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1657 SERVICE_COMPONENT_TYPE);
1658 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1659 getAllCategoriesRest.getErrorCode().intValue());
1660 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1662 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1663 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1668 public void categoryNameValidationConjunctions_08() throws Exception { // Normalize
1684 categoryDefinition.setName(" oF united states OF amer ");
1685 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
1686 SERVICE_COMPONENT_TYPE);
1687 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1688 createCategotyRest.getErrorCode().intValue());
1689 categoryDefinition.setName("OF United States of Amer");
1690 categoryDefinition.setNormalizedName("of united states of amer");
1691 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1692 // Get service category and validate that category added as defined
1693 // (also set catalog uniqeId)
1694 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1695 SERVICE_COMPONENT_TYPE);
1696 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1697 getAllCategoriesRest.getErrorCode().intValue());
1698 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1700 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1701 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1705 public void categoryNameValidationConjunctions_09() throws Exception { // Normalize
1721 categoryDefinition.setName(" to Apple TO at&T TOO ");
1722 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
1723 SERVICE_COMPONENT_TYPE);
1724 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1725 createCategotyRest.getErrorCode().intValue());
1726 categoryDefinition.setName("To Apple to At&T TOO");
1727 categoryDefinition.setNormalizedName("to apple to at&t too");
1728 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1729 // Get service category and validate that category added as defined
1730 // (also set catalog uniqeId)
1731 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1732 SERVICE_COMPONENT_TYPE);
1733 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1734 getAllCategoriesRest.getErrorCode().intValue());
1735 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1737 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1738 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1742 public void categoryNameValidationConjunctions_10() throws Exception { // Normalize
1758 categoryDefinition.setName(" eat apple AS you liiikeas ");
1759 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
1760 SERVICE_COMPONENT_TYPE);
1761 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1762 createCategotyRest.getErrorCode().intValue());
1763 categoryDefinition.setName("Eat Apple as You Liiikeas");
1764 categoryDefinition.setNormalizedName("eat apple as you liiikeas");
1765 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1766 // Get service category and validate that category added as defined
1767 // (also set catalog uniqeId)
1768 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1769 SERVICE_COMPONENT_TYPE);
1770 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1771 getAllCategoriesRest.getErrorCode().intValue());
1772 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1774 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1775 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1779 public void categoryNameValidationConjunctions_11() throws Exception { // Normalize
1795 categoryDefinition.setName(" as you may want ");
1796 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
1797 SERVICE_COMPONENT_TYPE);
1798 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1799 createCategotyRest.getErrorCode().intValue());
1800 categoryDefinition.setName("As You May Want");
1801 categoryDefinition.setNormalizedName("as you may want");
1802 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1803 // Get service category and validate that category added as defined
1804 // (also set catalog uniqeId)
1805 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1806 SERVICE_COMPONENT_TYPE);
1807 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1808 getAllCategoriesRest.getErrorCode().intValue());
1809 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1811 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1812 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1816 public void categoryNameValidationConjunctions_12() throws Exception { // Normalize
1832 categoryDefinition.setName(" the bank OF america ");
1833 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
1834 SERVICE_COMPONENT_TYPE);
1835 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1836 createCategotyRest.getErrorCode().intValue());
1837 categoryDefinition.setName("The Bank of America");
1838 categoryDefinition.setNormalizedName("the bank of america");
1839 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1840 // Get service category and validate that category added as defined
1841 // (also set catalog uniqeId)
1842 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1843 SERVICE_COMPONENT_TYPE);
1844 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1845 getAllCategoriesRest.getErrorCode().intValue());
1846 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1848 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1849 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1854 public void categoryNameValidationConjunctions_13() throws Exception { // Normalize
1870 categoryDefinition.setName(" To tel-toto ");
1871 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
1872 SERVICE_COMPONENT_TYPE);
1873 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1874 createCategotyRest.getErrorCode().intValue());
1875 categoryDefinition.setName("To Tel-toto");
1876 categoryDefinition.setNormalizedName("to tel-toto");
1877 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1878 // Get service category and validate that category added as defined
1879 // (also set catalog uniqeId)
1880 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1881 SERVICE_COMPONENT_TYPE);
1882 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1883 getAllCategoriesRest.getErrorCode().intValue());
1884 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1886 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1887 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1892 public void categoryNameValidationConjunctions_14() throws Exception { // Normalize
1908 categoryDefinition.setName(" tel-aviv To la ");
1909 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
1910 SERVICE_COMPONENT_TYPE);
1911 assertEquals("Check response code after create Category", STATUS_CODE_CREATED,
1912 createCategotyRest.getErrorCode().intValue());
1913 categoryDefinition.setName("Tel-aviv to La");
1914 categoryDefinition.setNormalizedName("tel-aviv to la");
1915 CategoryValidationUtils.validateCreateCategoryResponse(createCategotyRest, categoryDefinition);
1916 // Get service category and validate that category added as defined
1917 // (also set catalog uniqeId)
1918 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1919 SERVICE_COMPONENT_TYPE);
1920 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1921 getAllCategoriesRest.getErrorCode().intValue());
1922 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryDefinition);
1924 AuditValidationUtils.categoryAuditSuccess(ADD_CATEGORY, categoryDefinition, sdncAdminUserDetails,
1925 STATUS_CODE_CREATED, AUDIT_SERVICE_TYPE);
1929 public void createServiceCategoryHttpCspUserIdIsEmpty() throws Exception {
1930 User sdncAdminUserDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
1931 sdncAdminUserDetails1.setUserId("");
1932 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
1933 SERVICE_COMPONENT_TYPE);
1934 assertEquals("Check response code after create Consumer", STATUS_CODE_MISSING_INFORMATION,
1935 createCategotyRest.getErrorCode().intValue());
1936 categoryDefinition.setName("Abcd");
1937 // get service category and validate that category was not added
1938 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1939 SERVICE_COMPONENT_TYPE);
1940 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1941 getAllCategoriesRest.getErrorCode().intValue());
1942 CategoryValidationUtils.verifyCategoryNotExistsInGetResponse(getAllCategoriesRest, categoryDefinition);
1944 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.MISSING_INFORMATION.name());
1945 ExpectedCategoryAudit expectedCatrgoryAuditJavaObject = new ExpectedCategoryAudit();
1946 expectedCatrgoryAuditJavaObject.setAction(ADD_CATEGORY);
1947 expectedCatrgoryAuditJavaObject.setModifier("");
1948 expectedCatrgoryAuditJavaObject.setCategoryName(categoryDefinition.getName());
1949 expectedCatrgoryAuditJavaObject.setSubCategoryName("");
1950 expectedCatrgoryAuditJavaObject.setGroupingName("");
1951 expectedCatrgoryAuditJavaObject.setResourceType(AUDIT_SERVICE_TYPE);
1952 expectedCatrgoryAuditJavaObject.setStatus(String.valueOf(STATUS_CODE_MISSING_INFORMATION));
1953 expectedCatrgoryAuditJavaObject.setDesc(errorInfo.getAuditDesc());
1954 AuditValidationUtils.validateCategoryAudit(expectedCatrgoryAuditJavaObject, ADD_CATEGORY);
1958 public void createServiceCategorHttpCspUserIdIsNull() throws Exception {
1959 User sdncAdminUserDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
1960 sdncAdminUserDetails1.setUserId(null);
1961 RestResponse createCategotyRest = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails1,
1962 SERVICE_COMPONENT_TYPE);
1963 assertEquals("Check response code after create Consumer", STATUS_CODE_MISSING_INFORMATION,
1964 createCategotyRest.getErrorCode().intValue());
1965 categoryDefinition.setName("Abcd");
1966 // get service category and validate that category was not added
1967 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1968 SERVICE_COMPONENT_TYPE);
1969 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1970 getAllCategoriesRest.getErrorCode().intValue());
1971 CategoryValidationUtils.verifyCategoryNotExistsInGetResponse(getAllCategoriesRest, categoryDefinition);
1973 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.MISSING_INFORMATION.name());
1974 ExpectedCategoryAudit expectedCatrgoryAuditJavaObject = new ExpectedCategoryAudit();
1975 expectedCatrgoryAuditJavaObject.setAction(ADD_CATEGORY);
1976 expectedCatrgoryAuditJavaObject.setModifier("");
1977 expectedCatrgoryAuditJavaObject.setCategoryName(categoryDefinition.getName());
1978 expectedCatrgoryAuditJavaObject.setSubCategoryName("");
1979 expectedCatrgoryAuditJavaObject.setGroupingName("");
1980 expectedCatrgoryAuditJavaObject.setResourceType(AUDIT_SERVICE_TYPE);
1981 expectedCatrgoryAuditJavaObject.setStatus(String.valueOf(STATUS_CODE_MISSING_INFORMATION));
1982 expectedCatrgoryAuditJavaObject.setDesc(errorInfo.getAuditDesc());
1983 AuditValidationUtils.validateCategoryAudit(expectedCatrgoryAuditJavaObject, ADD_CATEGORY);
1987 public void createSrvcCategoryHttpCspUserIdHeaderIsMissing() throws Exception {
1988 RestResponse createConsumerRest = CategoryRestUtils
1989 .createServiceCategoryHttpCspAtuUidIsMissing(categoryDefinition, sdncAdminUserDetails);
1990 assertEquals("Check response code after create Consumer", STATUS_CODE_MISSING_INFORMATION,
1991 createConsumerRest.getErrorCode().intValue());
1992 categoryDefinition.setName("Abcd");
1993 // get service category and validate that category was not added
1994 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
1995 SERVICE_COMPONENT_TYPE);
1996 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
1997 getAllCategoriesRest.getErrorCode().intValue());
1998 CategoryValidationUtils.verifyCategoryNotExistsInGetResponse(getAllCategoriesRest, categoryDefinition);
2000 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.MISSING_INFORMATION.name());
2001 ExpectedCategoryAudit expectedCatrgoryAuditJavaObject = new ExpectedCategoryAudit();
2002 expectedCatrgoryAuditJavaObject.setAction(ADD_CATEGORY);
2003 expectedCatrgoryAuditJavaObject.setModifier("");
2004 expectedCatrgoryAuditJavaObject.setCategoryName(categoryDefinition.getName());
2005 expectedCatrgoryAuditJavaObject.setSubCategoryName("");
2006 expectedCatrgoryAuditJavaObject.setGroupingName("");
2007 expectedCatrgoryAuditJavaObject.setResourceType(AUDIT_SERVICE_TYPE);
2008 expectedCatrgoryAuditJavaObject.setStatus(String.valueOf(STATUS_CODE_MISSING_INFORMATION));
2009 expectedCatrgoryAuditJavaObject.setDesc(errorInfo.getAuditDesc());
2010 AuditValidationUtils.validateCategoryAudit(expectedCatrgoryAuditJavaObject, ADD_CATEGORY);
2014 public void getServiceCategoryHierarchySuccessFlow() throws Exception {
2016 int numOfCategories = 3;
2017 List<CategoryDefinition> categories = new ArrayList<CategoryDefinition>();
2018 RestResponse restResponse;
2019 CategoryDefinition category;
2020 String categoryName = categoryDefinition.getName();
2021 for (int i = 0; i < numOfCategories; i++) {
2022 categoryDefinition.setName(categoryName + i);
2023 restResponse = CategoryRestUtils.createCategory(categoryDefinition, sdncAdminUserDetails,
2024 SERVICE_COMPONENT_TYPE);
2025 category = ResponseParser.parseToObject(restResponse.getResponse(), CategoryDefinition.class);
2026 categories.add(category);
2028 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
2029 SERVICE_COMPONENT_TYPE);
2030 assertEquals("Check response code after get all categories ", STATUS_CODE_SUCCESS,
2031 getAllCategoriesRest.getErrorCode().intValue());
2033 AuditValidationUtils.GetCategoryHierarchyAuditSuccess(GET_CATEGORY_HIERARCHY, AUDIT_SERVICE_TYPE,
2034 sdncAdminUserDetails, STATUS_CODE_SUCCESS);
2035 for (CategoryDefinition categoryCurr : categories) {
2036 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryCurr);
2040 ///////////////////////////////// US570520 /////////////////////////////////
2041 private List<CategoryDefinition> defineCategories() throws Exception {
2042 String firstCategory = "FirstCategory";
2043 String secondCategory = "secondCategory";
2044 String thirdCategory = "ThirdCategory";
2045 String forthCategory = "forthCategory";
2046 CategoryDefinition category1 = new CategoryDefinition(categoryDefinition);
2047 category1.setName(firstCategory);
2048 CategoryDefinition category2 = new CategoryDefinition(categoryDefinition);
2049 category2.setName(secondCategory);
2050 CategoryDefinition category3 = new CategoryDefinition(categoryDefinition);
2051 category3.setName(thirdCategory);
2052 CategoryDefinition category4 = new CategoryDefinition(categoryDefinition);
2053 category4.setName(forthCategory);
2054 ArrayList<CategoryDefinition> categoryList = new ArrayList<CategoryDefinition>();
2055 categoryList.add(category1);
2056 categoryList.add(category2);
2057 categoryList.add(category3);
2058 categoryList.add(category4);
2059 return categoryList;
2063 public void getAllResourceCategoriesHirarchy() throws Exception {
2064 createAndValidateCategoriesExist(RESOURCE_COMPONENT_TYPE, categoryList);
2066 for (int i = 0; i < categoryList.size(); i++) {
2067 List<String> subCategorieUniqueIdList = new ArrayList<String>();
2068 for (int j = 0; j < subCategoryList.size(); j++) {
2069 RestResponse createSubCategory = CategoryRestUtils.createSubCategory(subCategoryList.get(j),
2070 categoryList.get(i), sdncAdminUserDetails, RESOURCE_COMPONENT_TYPE);
2071 if (createSubCategory.getErrorCode().intValue() == STATUS_CODE_CREATED) {
2072 String subCategoryUniqeId = ResponseParser.getUniqueIdFromResponse(createSubCategory);
2073 subCategorieUniqueIdList.add(subCategoryUniqeId);
2074 subCategoriesToDeleteMap.put(categoryList.get(i).getUniqueId(), subCategorieUniqueIdList);
2079 DbUtils.deleteFromEsDbByPattern("_all");
2080 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
2081 RESOURCE_COMPONENT_TYPE);
2082 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
2083 getAllCategoriesRest.getErrorCode().intValue());
2085 for (int i = 0; i < categoryList.size(); i++) {
2086 for (int j = 0; j < subCategoryList.size(); j++) {
2087 CategoryValidationUtils.verifySubCategoryExistInGetResponse(getAllCategoriesRest,
2088 categoryList.get(i).getUniqueId(), subCategoryList.get(j));
2092 checkAuditSuccess(RESOURCE_COMPONENT_TYPE);
2095 private List<SubCategoryDefinition> defineSubCategories(int catListSize) {
2096 List<SubCategoryDefinition> subCatList = new ArrayList<SubCategoryDefinition>();
2097 for (int j = 1; j <= catListSize; j++) {
2098 SubCategoryDefinition subCategory = new SubCategoryDefinition();
2099 subCategory.setName("SubCategory" + String.valueOf(j));
2100 subCatList.add(subCategory);
2105 private void createAndValidateCategoriesExist(String comp, List<CategoryDefinition> categoryList) throws Exception {
2106 createCategories(comp, categoryList);
2107 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails, comp);
2108 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
2109 getAllCategoriesRest.getErrorCode().intValue());
2110 verifyCategoriesExist(categoryList, getAllCategoriesRest);
2113 private void verifyCategoriesExist(List<CategoryDefinition> categoryList, RestResponse getAllCategoriesRest) {
2114 for (int i = 0; i < categoryList.size(); i++) {
2115 categoryList.get(i).setName(WordUtils.capitalize(categoryList.get(i).getName()));
2116 CategoryValidationUtils.verifyCategoryExistInGetResponse(getAllCategoriesRest, categoryList.get(i));
2120 private void createCategories(String comp, List<CategoryDefinition> categoryList) throws Exception {
2121 for (int i = 0; i < categoryList.size(); i++) {
2122 CategoryRestUtils.createCategory(categoryList.get(i), sdncAdminUserDetails, comp);
2127 public void getAllServiceCategoriesHirarchy() throws Exception {
2128 // deleteCategories(categoryList, SERVICE_COMPONENT_TYPE);
2129 createAndValidateCategoriesExist(SERVICE_COMPONENT_TYPE, categoryList);
2130 checkAuditSuccess(SERVICE_COMPONENT_TYPE);
2131 // deleteCategories(categoryList, SERVICE_COMPONENT_TYPE);
2135 public void getAllResourceCategories_noAttUserHeader() throws Exception {
2136 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(new User(), RESOURCE_COMPONENT_TYPE);
2137 assertEquals("Check response code after get Category", 403, getAllCategoriesRest.getErrorCode().intValue());
2138 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.MISSING_INFORMATION.name(), new ArrayList<String>(),
2139 getAllCategoriesRest.getResponse());
2141 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.MISSING_INFORMATION.name());
2142 ExpectedCategoryAudit expectedCatrgoryAuditJavaObject = new ExpectedCategoryAudit();
2143 expectedCatrgoryAuditJavaObject.setAction(GET_CATEGORY_HIERARCHY);
2144 expectedCatrgoryAuditJavaObject.setModifierName("");
2145 expectedCatrgoryAuditJavaObject.setModifierUid("");
2146 expectedCatrgoryAuditJavaObject.setDetails(RESOURCE_COMPONENT_TYPE);
2147 expectedCatrgoryAuditJavaObject.setStatus(String.valueOf(STATUS_CODE_MISSING_INFORMATION));
2148 expectedCatrgoryAuditJavaObject.setDesc(errorInfo.getAuditDesc());
2149 AuditValidationUtils.validateGetCategoryHirarchy(expectedCatrgoryAuditJavaObject, GET_CATEGORY_HIERARCHY);
2153 public void getAllResourceCategories_userNotProvisioned() throws Exception {
2154 User notProvisionedUser = new User();
2155 notProvisionedUser.setUserId("aa0001");
2156 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(notProvisionedUser,
2157 RESOURCE_COMPONENT_TYPE);
2158 assertEquals("Check response code after get Category", 409, getAllCategoriesRest.getErrorCode().intValue());
2159 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.RESTRICTED_OPERATION.name(), new ArrayList<String>(),
2160 getAllCategoriesRest.getResponse());
2162 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.RESTRICTED_OPERATION.name());
2163 ExpectedCategoryAudit expectedCatrgoryAuditJavaObject = new ExpectedCategoryAudit();
2164 expectedCatrgoryAuditJavaObject.setAction(GET_CATEGORY_HIERARCHY);
2165 expectedCatrgoryAuditJavaObject.setModifierName("");
2166 expectedCatrgoryAuditJavaObject.setModifierUid(notProvisionedUser.getUserId());
2167 expectedCatrgoryAuditJavaObject.setDetails(RESOURCE_COMPONENT_TYPE);
2168 expectedCatrgoryAuditJavaObject.setStatus(String.valueOf(STATUS_CODE_RESTRICTED_OPERATION));
2169 expectedCatrgoryAuditJavaObject.setDesc(errorInfo.getAuditDesc());
2170 AuditValidationUtils.validateGetCategoryHirarchy(expectedCatrgoryAuditJavaObject, GET_CATEGORY_HIERARCHY);
2174 public void getAllResourceCategories_unsupportedComponent() throws Exception {
2175 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails, "comp");
2176 assertEquals("Check response code after get all categories hirarchy", 400,
2177 getAllCategoriesRest.getErrorCode().intValue());
2178 ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.UNSUPPORTED_ERROR.name(),
2179 new ArrayList<String>(Arrays.asList("component type")), getAllCategoriesRest.getResponse());
2181 ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.UNSUPPORTED_ERROR.name());
2182 ExpectedCategoryAudit expectedCatrgoryAuditJavaObject = new ExpectedCategoryAudit();
2183 expectedCatrgoryAuditJavaObject.setAction(GET_CATEGORY_HIERARCHY);
2184 expectedCatrgoryAuditJavaObject.setModifierUid(sdncAdminUserDetails.getUserId());
2185 expectedCatrgoryAuditJavaObject.setModifierName(sdncAdminUserDetails.getFullName());
2186 expectedCatrgoryAuditJavaObject.setDetails("comp");
2187 expectedCatrgoryAuditJavaObject.setStatus(String.valueOf(STATUS_CODE_INVALID_CONTENT));
2188 expectedCatrgoryAuditJavaObject.setDesc(AuditValidationUtils.buildAuditDescription(errorInfo,
2189 new ArrayList<String>(Arrays.asList("component type"))));
2190 AuditValidationUtils.validateGetCategoryHirarchy(expectedCatrgoryAuditJavaObject, GET_CATEGORY_HIERARCHY);
2193 @Test(enabled = false)
2194 public void getAllResourceCategories_emptyList() throws Exception {
2195 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
2196 RESOURCE_COMPONENT_TYPE);
2197 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
2198 getAllCategoriesRest.getErrorCode().intValue());
2199 JSONArray jArr = new JSONArray(getAllCategoriesRest.getResponse());
2200 assertTrue(jArr.length() == 0);
2202 checkAuditSuccess(RESOURCE_COMPONENT_TYPE);
2205 private void checkAuditSuccess(String componentType) throws Exception {
2206 ExpectedCategoryAudit expectedCatrgoryAuditJavaObject = new ExpectedCategoryAudit();
2207 expectedCatrgoryAuditJavaObject.setAction(GET_CATEGORY_HIERARCHY);
2208 expectedCatrgoryAuditJavaObject.setModifierName(sdncAdminUserDetails.getFullName());
2209 expectedCatrgoryAuditJavaObject.setModifierUid(sdncAdminUserDetails.getUserId());
2210 expectedCatrgoryAuditJavaObject.setDetails(componentType);
2211 expectedCatrgoryAuditJavaObject.setStatus("200");
2212 expectedCatrgoryAuditJavaObject.setDesc("OK");
2213 AuditValidationUtils.validateGetCategoryHirarchy(expectedCatrgoryAuditJavaObject, GET_CATEGORY_HIERARCHY);
2216 @Test(enabled = false)
2217 public void getAllServiceCategories_emptyList() throws Exception {
2218 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
2219 SERVICE_COMPONENT_TYPE);
2220 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
2221 getAllCategoriesRest.getErrorCode().intValue());
2222 JSONArray jArr = new JSONArray(getAllCategoriesRest.getResponse());
2223 assertTrue(jArr.length() == 0);
2225 checkAuditSuccess(SERVICE_COMPONENT_TYPE);
2228 @Test(enabled = false)
2229 public void getAllProductCategories_emptyList() throws Exception {
2230 RestResponse getAllCategoriesRest = CategoryRestUtils.getAllCategories(sdncAdminUserDetails,
2231 PRODUCT_COMPONENT_TYPE);
2232 assertEquals("Check response code after get Category", STATUS_CODE_SUCCESS,
2233 getAllCategoriesRest.getErrorCode().intValue());
2234 JSONArray jArr = new JSONArray(getAllCategoriesRest.getResponse());
2235 assertTrue(jArr.length() == 0);
2237 checkAuditSuccess(PRODUCT_COMPONENT_TYPE);
2241 // public void getAllResourceCategories_generalError() throws Exception
2243 // User user = new User();
2244 // RestResponse getAllCategoriesRest =
2245 // CategoryRestUtils.getAllCategories(user, SERVICE_COMPONENT_TYPE);
2246 // assertEquals("Check response code after get Category", 500,
2247 // getAllCategoriesRest.getErrorCode().intValue());
2248 // Utils.checkBodyResponseOnError(ActionStatus.GENERAL_ERROR.name(), new
2249 // ArrayList<String>(), getAllCategoriesRest.getResponse());
2252 //////////////////////////////////////////////////////////////////////////////
2255 public void importCategories() throws Exception {
2257 String importResourceDir = config.getImportTypesConfigDir() + File.separator + "categoryTypesTest.zip";
2259 MultipartEntityBuilder mpBuilder = MultipartEntityBuilder.create();
2260 mpBuilder.addPart("categoriesZip", new FileBody(new File(importResourceDir)));
2262 RestResponse importResult = CategoryRestUtils.importCategories(mpBuilder, sdncAdminUserDetails.getUserId());
2263 assertEquals("Check response code after Import", BaseRestUtils.STATUS_CODE_CREATED,
2264 importResult.getErrorCode().intValue());
2266 Map<String, Object> map = ResponseParser.parseToObjectUsingMapper(importResult.getResponse(), Map.class);
2267 assertEquals("Check entries count", 2, map.size());
2269 List<Map<String, Object>> resources = (List<Map<String, Object>>) map.get("resources");
2270 assertEquals("Check resource category entries count", 1, resources.size());
2272 List<Map<String, Object>> services = (List<Map<String, Object>>) map.get("services");
2273 assertEquals("Check resource category entries count", 2, services.size());
2275 RestResponse allCategories = CategoryRestUtils.getAllCategories(sdncAdminUserDetails, "resources");
2276 List<CategoryDefinition> resourceCategories = ResponseParser.parseCategories(allCategories);
2277 for (Map<String, Object> resource : resources) {
2278 boolean exist = false;
2280 for (CategoryDefinition categ : resourceCategories) {
2281 if (categ.getName().equals(resource.get("name"))) {
2286 assertTrue("Check existance resource category " + resource.get("name"), exist);
2289 allCategories = CategoryRestUtils.getAllCategories(sdncAdminUserDetails, "services");
2290 List<CategoryDefinition> servicesCategories = ResponseParser.parseCategories(allCategories);
2291 for (Map<String, Object> service : services) {
2292 boolean exist = false;
2294 for (CategoryDefinition categ : servicesCategories) {
2295 if (categ.getName().equals(service.get("name"))) {
2300 assertTrue("Check existance service category " + service.get("name"), exist);