[SDC-29] Amdocs OnBoard 1707 initial commit.
[sdc.git] / openecomp-be / backend / openecomp-sdc-vendor-software-product-manager / src / test / java / org / openecomp / sdc / vendorsoftwareproduct / services / QuestionnaireValidatorTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.openecomp.sdc.vendorsoftwareproduct.services;
22
23 public class QuestionnaireValidatorTest {
24 /*
25     public static QuestionnaireValidator validator = new QuestionnaireValidator();
26
27     @Test(expectedExceptions = CoreException.class)
28     public void testAddSubEntityBeforeRoot_negative() {
29         validator.addSubEntity(createComponent("componentId2"), CompositionEntityType.vsp);
30     }
31
32     @Test(dependsOnMethods = "testAddSubEntityBeforeRoot_negative")
33     public void testAddRootEntity() {
34         validator.addRootEntity(createVspQuestionnaireEntity());
35     }
36
37     @Test(dependsOnMethods = "testAddRootEntity", expectedExceptions = CoreException.class)
38     public void testAddRootEntityWhenAlreadyExist_negative() {
39         validator.addRootEntity(createVspQuestionnaireEntity());
40     }
41
42     @Test(dependsOnMethods = "testAddRootEntity")
43     public void testAddSubEntity() {
44         validator.addSubEntity(createComponent("componentId1"), CompositionEntityType.vsp);
45     }
46
47     @Test(dependsOnMethods = "testAddRootEntity", expectedExceptions = CoreException.class)
48     public void testAddSubEntityWithNonExistingParentType() {
49         validator.addSubEntity(new ComponentEntity("vspId1", new Version(0, 1), "componentId2"), CompositionEntityType.nic);
50     }
51
52     @Test(dependsOnMethods = "testAddSubEntity")
53     public void testAddSubEntities() throws Exception {
54         Collection<UnifiedCompositionEntity> nics = new ArrayList<>();
55         nics.add(createNic("nicId1", "componentId1"));
56         nics.add(createNic("nicId2", "componentId1"));
57         nics.add(createNic("nicId3", "componentId1"));
58
59         validator.addSubEntities(nics, CompositionEntityType.component);
60     }
61
62
63     @Test(dependsOnMethods = "testAddSubEntities")
64     public void testValidate() throws Exception {
65         QuestionnaireValidationResult validationResult = validator.validate();
66         Assert.assertTrue(validationResult.isValid());
67     }
68
69     private static VspQuestionnaireEntity createVspQuestionnaireEntity() {
70         VspQuestionnaireEntity vspQuestionnaireEntity = new VspQuestionnaireEntity();
71         vspQuestionnaireEntity.setId("vspId1");
72         vspQuestionnaireEntity.setVersion(new Version(0, 1));
73         vspQuestionnaireEntity.setQuestionnaireData("{\n" +
74                 "  \"name\": \"bla bla\"\n" +
75                 "}");
76         return vspQuestionnaireEntity;
77     }
78
79     private static ComponentEntity createComponent(String componentId) {
80         ComponentEntity component = new ComponentEntity("vspId1", new Version(0, 1), componentId);
81         component.setQuestionnaireData("{\n" +
82                 "  \"name\": \"bla bla\"\n" +
83                 "}");
84         return component;
85     }
86
87     private static UnifiedCompositionEntity createNic(String nicId, String componentId) {
88         NicEntity nic = new NicEntity("vspId1", new Version(0, 1), componentId, nicId);
89         nic.setQuestionnaireData("{\n" +
90                 "  \"name\": \"bla bla\"\n" +
91                 "}");
92         return nic;
93     }*/
94 }