2 * ============LICENSE_START=======================================================
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
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.asdctool.impl.validator.executor;
23 import static org.junit.jupiter.api.Assertions.assertFalse;
24 import static org.mockito.Mockito.mock;
26 import java.util.HashMap;
27 import java.util.LinkedList;
28 import java.util.List;
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;
39 public interface ArtifactValidatorExecutorContract {
41 ArtifactValidatorExecutor createTestSubject(
42 JanusGraphDao janusGraphDao,
43 ToscaOperationFacade toscaOperationFacade
47 default void testGetVerticesToValidate() {
48 JanusGraphDao janusGraphDaoMock = mock(JanusGraphDao.class);
49 ToscaOperationFacade toscaOperationFacade = mock(ToscaOperationFacade.class);
50 final ArtifactValidatorExecutor testSubject = createTestSubject(janusGraphDaoMock, toscaOperationFacade);
52 VertexTypeEnum type = null;
53 Map<GraphPropertyEnum, Object> hasProps = null;
54 Assertions.assertThrows(NullPointerException.class, () ->
55 testSubject.getVerticesToValidate(type, hasProps)
60 default void testValidate() {
61 JanusGraphDao janusGraphDaoMock = mock(JanusGraphDao.class);
62 ToscaOperationFacade toscaOperationFacade = mock(ToscaOperationFacade.class);
63 final ArtifactValidatorExecutor testSubject = createTestSubject(janusGraphDaoMock, toscaOperationFacade);
65 LinkedList<Component> linkedList = new LinkedList<Component>();
66 linkedList.add(new Resource());
68 Map<String, List<Component>> vertices = new HashMap<>();
69 vertices.put("stam", linkedList);
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));