0c34d4b745a5ffc36b0c84fdc9db3ee6ab90b2c1
[sdc.git] / catalog-model / src / test / java / org / openecomp / sdc / be / model / UploadServiceInfoTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.openecomp.sdc.be.model;
22
23
24 import org.junit.Assert;
25 import org.junit.Test;
26 import org.openecomp.sdc.be.model.category.CategoryDefinition;
27 import org.openecomp.sdc.be.model.category.SubCategoryDefinition;
28
29 import java.util.LinkedList;
30 import java.util.List;
31
32
33 public class UploadServiceInfoTest {
34
35     private UploadServiceInfo createTestSubject() {
36         return new UploadServiceInfo();
37     }
38
39     @Test
40     public void testCtor() {
41         new UploadServiceInfo("mock", "mock", "mock", new LinkedList<>(), "mock", "mock", "mock", "mock/mock/mock",
42                 "mock", "mock", "mock", "mock", "mock", "mock", "mock", new LinkedList<>(), "mock", "mock", "mock",
43                 "mock", "mock", "mock", "mock", "mock", "mock", "mock");
44     }
45
46     @Test
47     public void testAddSubCategory() {
48         UploadServiceInfo testSubject;
49         String category = "";
50         String subCategory = "";
51
52         // test 1
53         testSubject = createTestSubject();
54         category = null;
55         subCategory = null;
56         testSubject.addSubCategory(category, subCategory);
57         List<CategoryDefinition> categories = testSubject.getCategories();
58         Assert.assertNull(categories);
59
60         // test 2
61         testSubject = createTestSubject();
62         category = "";
63         subCategory = null;
64         testSubject.addSubCategory(category, subCategory);
65         List<CategoryDefinition> categories2 = testSubject.getCategories();
66         for (CategoryDefinition categoryDefinition : categories2) {
67             Assert.assertEquals("", categoryDefinition.getName());
68         }
69
70         // test 3
71         testSubject = createTestSubject();
72         subCategory = "";
73         category = null;
74         testSubject.addSubCategory(category, subCategory);
75         List<CategoryDefinition> categories3 = testSubject.getCategories();
76         for (CategoryDefinition categoryDefinition : categories3) {
77             List<SubCategoryDefinition> subcategories = categoryDefinition.getSubcategories();
78             for (SubCategoryDefinition subcategory : subcategories) {
79                 Assert.assertEquals("", subcategory.getName());
80             }
81         }
82
83         // test 4
84         testSubject = createTestSubject();
85         subCategory = "mock";
86         category = "mock";
87         testSubject.addSubCategory(category, subCategory);
88         List<CategoryDefinition> categories4 = testSubject.getCategories();
89         for (CategoryDefinition categoryDefinition : categories4) {
90             Assert.assertEquals("mock", categoryDefinition.getName());
91         }
92     }
93 }