Implement Attributes/Outputs BE (part 3)
[sdc.git] / catalog-be / src / test / java / org / openecomp / sdc / be / tosca / utils / OutputConverterTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2021, Nordix Foundation. 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 package org.openecomp.sdc.be.tosca.utils;
21
22 import static org.assertj.core.api.Assertions.assertThat;
23 import static org.mockito.ArgumentMatchers.any;
24 import static org.mockito.Mockito.doReturn;
25
26 import java.util.ArrayList;
27 import java.util.HashMap;
28 import java.util.List;
29 import java.util.Map;
30 import org.junit.jupiter.api.Test;
31 import org.junit.jupiter.api.extension.ExtendWith;
32 import org.mockito.InjectMocks;
33 import org.mockito.Mock;
34 import org.mockito.junit.jupiter.MockitoExtension;
35 import org.openecomp.sdc.be.model.OutputDefinition;
36 import org.openecomp.sdc.be.tosca.AttributeConverter;
37 import org.openecomp.sdc.be.tosca.exception.ToscaConversionException;
38 import org.openecomp.sdc.be.tosca.model.ToscaProperty;
39 import org.springframework.beans.factory.ObjectProvider;
40
41 @ExtendWith(MockitoExtension.class)
42 class OutputConverterTest {
43
44     @InjectMocks
45     private OutputConverter testSubject;
46
47     @Mock
48     private ObjectProvider<AttributeConverter> attributeConverterProvider;
49
50     @Test
51     void test_convert_success() throws ToscaConversionException {
52         final List<OutputDefinition> outputDefinitionList = new ArrayList<>();
53         final OutputDefinition outputDefinition = new OutputDefinition();
54         outputDefinitionList.add(outputDefinition);
55
56         doReturn(new AttributeConverter(new HashMap<>())).when(attributeConverterProvider).getObject(any());
57         final Map<String, ToscaProperty> result = testSubject.convert(outputDefinitionList, new HashMap<>());
58         assertThat(result).isNotNull();
59     }
60
61     @Test
62     void test_convert_isEmpty() throws ToscaConversionException {
63         final Map<String, ToscaProperty> result = testSubject.convert(new ArrayList<>(), new HashMap<>());
64         assertThat(result).isNotNull().isEmpty();
65     }
66
67 }