2 * ============LICENSE_START=======================================================
 
   4 * ================================================================================
 
   5 * Copyright 2018 TechMahindra
 
   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=========================================================
 
  20 package org.onap.dcaegen2.services.mapper.snmpmapper.controller;
 
  22 import static org.junit.Assert.assertEquals;
 
  23 import static org.mockito.Mockito.when;
 
  25 import java.util.logging.Logger;
 
  27 import javax.servlet.http.HttpServletRequest;
 
  29 import org.junit.BeforeClass;
 
  30 import org.junit.Test;
 
  31 import org.mockito.Mockito;
 
  32 import org.mockito.stubbing.Answer;
 
  33 import org.springframework.web.multipart.MultipartFile;
 
  36 public class SnmpmapperControllerTest {
 
  39         private Logger logger = Logger.getLogger(SnmpmapperControllerTest.class.toString());
 
  42         public static void setUpBeforeClass() throws Exception {
 
  46         private SnmpmapperController createTestSubject() {
 
  47                 return new SnmpmapperController();
 
  51         public void testIndex() throws Exception {
 
  52                 SnmpmapperController testSubject;
 
  56                 testSubject = createTestSubject();
 
  57                 result = testSubject.index();
 
  61         public void testSaveUploadedFileInDatabase() throws Exception {
 
  62                 SnmpmapperController testSubject;
 
  63                 HttpServletRequest request = null;
 
  64                 MultipartFile[] mapper = new MultipartFile[] { null };
 
  68                 testSubject = Mockito.mock(SnmpmapperController.class);
 
  69                 when(testSubject.saveUploadedFileInDatabase(request, mapper)).thenReturn("success.html");
 
  71                 result = testSubject.saveUploadedFileInDatabase(request, mapper);
 
  73                 assertEquals("success.html", result);