UT-enhance ComponentInstanceOperationTest
[sdc.git] / catalog-model / src / test / java / org / openecomp / sdc / be / model / operations / impl / ComponentInstanceOperationTest.java
1 /*
2
3  * Copyright (c) 2018 AT&T Intellectual Property.
4
5  *
6
7  * Licensed under the Apache License, Version 2.0 (the "License");
8
9  * you may not use this file except in compliance with the License.
10
11  * You may obtain a copy of the License at
12
13  *
14
15  *     http://www.apache.org/licenses/LICENSE-2.0
16
17  *
18
19  * Unless required by applicable law or agreed to in writing, software
20
21  * distributed under the License is distributed on an "AS IS" BASIS,
22
23  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24
25  * See the License for the specific language governing permissions and
26
27  * limitations under the License.
28
29  */
30 package org.openecomp.sdc.be.model.operations.impl;
31
32 import com.thinkaurelius.titan.core.TitanVertex;
33 import fj.data.Either;
34 import org.junit.Test;
35 import org.junit.runner.RunWith;
36 import org.mockito.InjectMocks;
37 import org.mockito.Mock;
38 import org.mockito.Mockito;
39 import org.mockito.junit.MockitoJUnitRunner;
40 import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
41 import org.openecomp.sdc.be.dao.titan.TitanGenericDao;
42 import org.openecomp.sdc.be.model.ComponentInstanceInput;
43 import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
44
45 import static org.junit.Assert.assertNull;
46 import static org.junit.Assert.assertEquals;
47 import static org.mockito.Mockito.when;
48
49 @RunWith(MockitoJUnitRunner.class)
50 public class ComponentInstanceOperationTest {
51
52         @InjectMocks
53         private ComponentInstanceOperation componentInstanceOperation;
54
55         @Mock
56         protected TitanGenericDao titanGenericDao;
57
58
59         @Test
60         public void testSetTitanGenericDao() {
61                 componentInstanceOperation.setTitanGenericDao(titanGenericDao);
62         }
63
64         @Test
65         public void testUpdateInputValueInResourceInstance() {
66                 ComponentInstanceInput input = null;
67                 String resourceInstanceId = "";
68                 boolean b = false;
69                 Either<ComponentInstanceInput, StorageOperationStatus> result;
70
71                 result = componentInstanceOperation.updateInputValueInResourceInstance(input, resourceInstanceId, b);
72                 assertNull(result);
73         }
74
75         @Test
76         public void testUpdateCustomizationUUID() {
77                 StorageOperationStatus result;
78                 String componentInstanceId = "instanceId";
79                 TitanVertex titanVertex = Mockito.mock(TitanVertex.class);
80                 when(titanGenericDao.getVertexByProperty(GraphPropertiesDictionary.UNIQUE_ID.getProperty(),componentInstanceId)).thenReturn(Either.left(titanVertex));
81                 result = componentInstanceOperation.updateCustomizationUUID(componentInstanceId);
82                 assertEquals(StorageOperationStatus.OK, result);
83         }
84 }