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.controller;
 
  23 import org.junit.Before;
 
  24 import org.junit.Test;
 
  25 import org.junit.runner.RunWith;
 
  26 import org.mockito.InjectMocks;
 
  27 import org.mockito.MockitoAnnotations;
 
  28 import org.mockito.junit.MockitoJUnitRunner;
 
  29 import org.onap.datalake.feeder.domain.DesignType;
 
  30 import org.onap.datalake.feeder.service.DesignTypeService;
 
  32 import java.lang.reflect.Field;
 
  33 import java.util.ArrayList;
 
  34 import java.util.List;
 
  36 import static org.junit.Assert.assertEquals;
 
  38 @RunWith(MockitoJUnitRunner.class)
 
  39 public class DesignTypeControllerTest {
 
  42     private DesignTypeService designTypeService;
 
  45     public void setupTest() {
 
  46         MockitoAnnotations.initMocks(this);
 
  49     @Test(expected = NullPointerException.class)
 
  50     public void getTemplateTypeName() throws NoSuchFieldException, IllegalAccessException {
 
  52         DesignTypeController testDesignTypeController = new DesignTypeController();
 
  53         setAccessPrivateFields(testDesignTypeController);
 
  54         DesignType testDesignType = fillDomain();
 
  55         List<String> designTypeNamesList = new ArrayList<>();
 
  56         designTypeNamesList.add(testDesignType.getName());
 
  57         assertEquals(1, testDesignTypeController.getDesignType().size());
 
  60     public void setAccessPrivateFields(DesignTypeController designTypeController) throws NoSuchFieldException, IllegalAccessException {
 
  62         Field testDesignTypeService = designTypeController.getClass().getDeclaredField("designTypeService");
 
  63         testDesignTypeService.setAccessible(true);
 
  64         testDesignTypeService.set(designTypeController, designTypeService);
 
  68     public DesignType fillDomain(){
 
  69         DesignType designType = new DesignType();
 
  70         designType.setName("Kibana Dashboard");