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;
23 import fj.data.Either;
24 import org.junit.Before;
25 import org.junit.Test;
26 import org.junit.runner.RunWith;
27 import org.mockito.Mockito;
28 import org.mockito.junit.MockitoJUnitRunner;
29 import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
30 import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
31 import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
33 import static org.assertj.core.api.Assertions.assertThat;
34 import static org.mockito.ArgumentMatchers.anyMap;
35 import static org.mockito.ArgumentMatchers.eq;
36 import static org.mockito.Mockito.when;
38 @RunWith(MockitoJUnitRunner.class)
39 public class VrfObjectFixHandlerTest {
41 private JanusGraphDao janusGraphDao;
43 private VrfObjectFixHandler vrfObjectFixHandler;
47 janusGraphDao = Mockito.mock(JanusGraphDao.class);
48 vrfObjectFixHandler = new VrfObjectFixHandler(janusGraphDao);
52 public void handleInvalidModeTest(){
53 assertThat(vrfObjectFixHandler.handle("invalid mode", null)).isFalse();
57 public void handleDetectNotFoundTest(){
58 when(janusGraphDao.getByCriteria(eq(VertexTypeEnum.NODE_TYPE), anyMap())).thenReturn(Either.right(
59 JanusGraphOperationStatus.NOT_FOUND));
60 assertThat(vrfObjectFixHandler.handle("detect", null)).isTrue();
64 public void handleDetectJanusGraphNotConnectedTest(){
65 when(janusGraphDao.getByCriteria(eq(VertexTypeEnum.NODE_TYPE), anyMap())).thenReturn(Either.right(
66 JanusGraphOperationStatus.NOT_CONNECTED));
67 assertThat(vrfObjectFixHandler.handle("detect", null)).isFalse();
71 public void handleFixNotFoundTest(){
72 when(janusGraphDao.getByCriteria(eq(VertexTypeEnum.NODE_TYPE), anyMap())).thenReturn(Either.right(
73 JanusGraphOperationStatus.NOT_FOUND));
74 assertThat(vrfObjectFixHandler.handle("fix", null)).isTrue();
78 public void handleFixNotCreatedTest(){
79 when(janusGraphDao.getByCriteria(eq(VertexTypeEnum.NODE_TYPE), anyMap())).thenReturn(Either.right(
80 JanusGraphOperationStatus.NOT_CREATED));
81 assertThat(vrfObjectFixHandler.handle("fix", null)).isFalse();