Catalog alignment
[sdc.git] / asdctool / src / test / java / org / openecomp / sdc / asdctool / impl / validator / executers / ArtifactValidatorExecuterTest.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.asdctool.impl.validator.executers;
22
23 import org.junit.Test;
24 import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
25 import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
26 import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
27 import org.openecomp.sdc.be.model.Component;
28 import org.openecomp.sdc.be.model.Resource;
29 import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
30 import org.testng.Assert;
31
32 import java.util.HashMap;
33 import java.util.LinkedList;
34 import java.util.List;
35 import java.util.Map;
36
37 import static org.mockito.Mockito.mock;
38
39 public class ArtifactValidatorExecuterTest {
40
41         private ArtifactValidatorExecuter createTestSubject() {
42                 JanusGraphDao janusGraphDaoMock = mock(JanusGraphDao.class);
43                 ToscaOperationFacade toscaOperationFacade = mock(ToscaOperationFacade.class);
44
45                 return new ArtifactValidatorExecuter(janusGraphDaoMock, toscaOperationFacade);
46         }
47
48         @Test
49         public void testGetName() throws Exception {
50                 ArtifactValidatorExecuter testSubject;
51                 String result;
52
53                 // default test
54                 testSubject = createTestSubject();
55                 result = testSubject.getName();
56         }
57
58         @Test(expected=NullPointerException.class)
59         public void testGetVerticesToValidate() throws Exception {
60                 ArtifactValidatorExecuter testSubject;
61                 VertexTypeEnum type = null;
62                 Map<GraphPropertyEnum, Object> hasProps = null;
63
64                 // default test
65                 testSubject = createTestSubject();
66                 testSubject.getVerticesToValidate(type, hasProps);
67         }
68
69         @Test
70         public void testSetName() throws Exception {
71                 ArtifactValidatorExecuter testSubject;
72                 String name = "";
73
74                 // default test
75                 testSubject = createTestSubject();
76                 testSubject.setName(name);
77         }
78
79         @Test
80         public void testValidate() {
81                 ArtifactValidatorExecuter testSubject;
82                 Map<String, List<Component>> vertices = new HashMap<>();
83                 LinkedList<Component> linkedList = new LinkedList<Component>();
84                 linkedList.add(new Resource());
85                 vertices.put("stam", linkedList);
86                 boolean result;
87
88                 // default test
89                 testSubject = createTestSubject();
90                 result = testSubject.validate(vertices);
91                 Assert.assertFalse(result);
92         }
93 }