9fb1b12319e6ebdc0fc89d898c31a126a64096ac
[dcaegen2/services/mapper.git] /
1 /*
2 * ============LICENSE_START=======================================================
3 * ONAP : DCAE
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
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.onap.dcaegen2.services.mapper.snmpmapper.controller;
21
22 import static org.junit.Assert.assertEquals;
23 import static org.mockito.Mockito.when;
24
25 import java.util.logging.Logger;
26
27 import javax.servlet.http.HttpServletRequest;
28
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;
34
35
36 public class SnmpmapperControllerTest {
37
38         
39         private Logger logger = Logger.getLogger(SnmpmapperControllerTest.class.toString());
40
41         @BeforeClass
42         public static void setUpBeforeClass() throws Exception {
43
44         }
45
46         private SnmpmapperController createTestSubject() {
47                 return new SnmpmapperController();
48         }
49
50         @Test
51         public void testIndex() throws Exception {
52                 SnmpmapperController testSubject;
53                 String result;
54
55                 // default test
56                 testSubject = createTestSubject();
57                 result = testSubject.index();
58         }
59
60         @Test
61         public void testSaveUploadedFileInDatabase() throws Exception {
62                 SnmpmapperController testSubject;
63                 HttpServletRequest request = null;
64                 MultipartFile[] mapper = new MultipartFile[] { null };
65                 String result;
66
67                 // default test
68                 testSubject = Mockito.mock(SnmpmapperController.class);
69                 when(testSubject.saveUploadedFileInDatabase(request, mapper)).thenReturn("success.html");
70                 
71                 result = testSubject.saveUploadedFileInDatabase(request, mapper);
72                 
73                 assertEquals("success.html", result);
74         }
75 }