21a931cc8682daefab660c4e08846be787924e6b
[sdc.git] /
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.executor;
22
23 import static org.junit.jupiter.api.Assertions.assertFalse;
24 import static org.mockito.Mockito.mock;
25
26 import java.util.HashMap;
27 import java.util.LinkedList;
28 import java.util.List;
29 import java.util.Map;
30 import org.junit.jupiter.api.Assertions;
31 import org.junit.jupiter.api.Test;
32 import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
33 import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
34 import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
35 import org.openecomp.sdc.be.model.Component;
36 import org.openecomp.sdc.be.model.Resource;
37 import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
38
39 public interface ArtifactValidatorExecutorContract {
40
41     ArtifactValidatorExecutor createTestSubject(
42         JanusGraphDao janusGraphDao,
43         ToscaOperationFacade toscaOperationFacade
44     );
45
46     @Test
47     default void testGetVerticesToValidate() {
48         JanusGraphDao janusGraphDaoMock = mock(JanusGraphDao.class);
49         ToscaOperationFacade toscaOperationFacade = mock(ToscaOperationFacade.class);
50         final ArtifactValidatorExecutor testSubject = createTestSubject(janusGraphDaoMock, toscaOperationFacade);
51
52         VertexTypeEnum type = null;
53         Map<GraphPropertyEnum, Object> hasProps = null;
54         Assertions.assertThrows(NullPointerException.class, () ->
55             testSubject.getVerticesToValidate(type, hasProps)
56         );
57     }
58
59     @Test
60     default void testValidate() {
61         JanusGraphDao janusGraphDaoMock = mock(JanusGraphDao.class);
62         ToscaOperationFacade toscaOperationFacade = mock(ToscaOperationFacade.class);
63         final ArtifactValidatorExecutor testSubject = createTestSubject(janusGraphDaoMock, toscaOperationFacade);
64
65         LinkedList<Component> linkedList = new LinkedList<Component>();
66         linkedList.add(new Resource());
67
68         Map<String, List<Component>> vertices = new HashMap<>();
69         vertices.put("stam", linkedList);
70
71         // Initially no outputFilePath was passed to this function (hence it is set to null)
72         // TODO: Fix this null and see if the argument is used by this function
73         assertFalse(testSubject.validate(vertices, null));
74     }
75 }