2 * ============LICENSE_START=======================================================
 
   4 * ================================================================================
 
   5 * Copyright 2019 China Mobile
 
   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.onap.datalake.feeder.service;
 
  23 import static org.junit.Assert.assertEquals;
 
  24 import static org.junit.Assert.assertNull;
 
  25 import static org.mockito.Mockito.when;
 
  27 import java.util.Optional;
 
  29 import org.junit.Test;
 
  30 import org.junit.runner.RunWith;
 
  31 import org.mockito.InjectMocks;
 
  32 import org.mockito.Mock;
 
  33 import org.mockito.junit.MockitoJUnitRunner;
 
  34 import org.onap.datalake.feeder.domain.Db;
 
  35 import org.onap.datalake.feeder.repository.DbRepository;
 
  38  * Test Service for Dbs 
 
  43 @RunWith(MockitoJUnitRunner.class)
 
  44 public class DbServiceTest {
 
  47         private DbRepository dbRepository;
 
  50         private DbService dbService;
 
  53         public void testGetDb() {
 
  55                 when(dbRepository.findByName(name)).thenReturn(new Db(name));
 
  56                 assertEquals(dbService.getDb(name), new Db(name));
 
  60         public void testGetDbNull() {
 
  62                 when(dbRepository.findByName(name)).thenReturn(null);
 
  63                 assertNull(dbService.getDb(name));
 
  67         public void testGetCouchbase() {
 
  68                 String name = "Couchbase";
 
  69                 when(dbRepository.findByName(name)).thenReturn(new Db(name));
 
  70                 assertEquals(dbService.getCouchbase(), new Db(name));
 
  74         public void testGetElasticsearch() {
 
  75                 String name = "Elasticsearch";
 
  76                 when(dbRepository.findByName(name)).thenReturn(new Db(name));
 
  77                 assertEquals(dbService.getElasticsearch(), new Db(name));
 
  81         public void testGetMongoDB() {
 
  82                 String name = "MongoDB";
 
  83                 when(dbRepository.findByName(name)).thenReturn(new Db(name));
 
  84                 assertEquals(dbService.getMongoDB(), new Db(name));
 
  88         public void testGetDruid() {
 
  89                 String name = "Druid";
 
  90                 when(dbRepository.findByName(name)).thenReturn(new Db(name));
 
  91                 assertEquals(dbService.getDruid(), new Db(name));
 
  95         public void testGetHdfs() {
 
  97                 when(dbRepository.findByName(name)).thenReturn(new Db(name));
 
  98                 assertEquals(dbService.getHdfs(), new Db(name));