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.be.components.impl;
23 import fj.data.Either;
24 import junit.framework.Assert;
25 import org.junit.Before;
26 import org.junit.Test;
28 import static org.mockito.ArgumentMatchers.any;
29 import static org.mockito.ArgumentMatchers.eq;
30 import static org.mockito.Mockito.when;
31 import org.mockito.Mockito;
32 import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
33 import org.openecomp.sdc.be.impl.ComponentsUtils;
34 import org.openecomp.sdc.be.model.DataTypeDefinition;
35 import org.openecomp.sdc.be.model.cache.ApplicationDataTypeCache;
38 import java.util.HashMap;
41 public class DataTypesServiceTest {
42 ApplicationDataTypeCache applicationDataTypeCache = Mockito.mock(ApplicationDataTypeCache.class);
43 ComponentsUtils componentsUtils = Mockito.mock(ComponentsUtils.class);
45 DataTypesService dataTypesService = new DataTypesService(componentsUtils);
46 Map<String, DataTypeDefinition> mapreturn = new HashMap<>();
47 JanusGraphOperationStatus janusGraphOperationStatus = JanusGraphOperationStatus.NOT_FOUND;
48 Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes;
52 mapreturn.put("Demo",new DataTypeDefinition());
53 allDataTypes = Either.left(mapreturn);
54 when(applicationDataTypeCache.getAll()).thenReturn(allDataTypes);
59 public void getAllDataTypes_success() {
60 Assert.assertEquals(true,dataTypesService.getAllDataTypes(applicationDataTypeCache).isLeft());
64 public void getAllDataTypes_failure() {
65 allDataTypes = Either.right(janusGraphOperationStatus);
66 when(applicationDataTypeCache.getAll()).thenReturn(allDataTypes);
67 Assert.assertEquals(true,dataTypesService.getAllDataTypes(applicationDataTypeCache).isRight());