aboutsummaryrefslogtreecommitdiffstats
path: root/snmpmapper
diff options
context:
space:
mode:
authorBharathS24 <BS00493532@techmahindra.com>2018-03-28 19:24:29 +0530
committerBharathS24 <BS00493532@techmahindra.com>2018-03-28 19:26:19 +0530
commit7d7d7a09088944d652735ef2ad7b58b81989174e (patch)
tree36884f2825a7834a3d410b8b0fe4ed4bf2f2abec /snmpmapper
parent31e5d676bf784d85d81c11e5e649928616cd7fb0 (diff)
Added test cases for snmpmapper in Mapper
Commiting test cases in Mapper Change-Id: Icd60a8a94400c1b95d26f0bfd7feeb46900a5db7 Issue-ID: DCAEGEN2-338 Signed-off-by: BharathS24 <BS00493532@techmahindra.com>
Diffstat (limited to 'snmpmapper')
-rw-r--r--snmpmapper/src/test/java/org/onap/dcae/mapper/FileUploadControllerTest.java99
-rw-r--r--snmpmapper/src/test/java/org/onap/dcae/mapper/storage/FileSystemStorageServiceTest.java93
2 files changed, 192 insertions, 0 deletions
diff --git a/snmpmapper/src/test/java/org/onap/dcae/mapper/FileUploadControllerTest.java b/snmpmapper/src/test/java/org/onap/dcae/mapper/FileUploadControllerTest.java
new file mode 100644
index 0000000..74b5826
--- /dev/null
+++ b/snmpmapper/src/test/java/org/onap/dcae/mapper/FileUploadControllerTest.java
@@ -0,0 +1,99 @@
+/*
+* ============LICENSE_START=======================================================
+* ONAP : DCAE
+* ================================================================================
+* Copyright 2018 TechMahindra
+*=================================================================================
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+* ============LICENSE_END=========================================================
+*/
+package org.onap.dcae.mapper;
+
+import static org.junit.Assert.*;
+
+import java.io.IOException;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.onap.dcae.mapper.storage.StorageService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.web.servlet.MockMvc;
+import org.springframework.ui.ExtendedModelMap;
+import org.springframework.ui.Model;
+import org.springframework.web.servlet.ModelAndView;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes=SnmpmapperApplication.class)
+@AutoConfigureMockMvc
+
+public class FileUploadControllerTest {
+
+ @Autowired
+ private MockMvc mockMvc;
+
+ @Mock
+ private StorageService storageService;
+
+ @Autowired
+ @InjectMocks
+ private FileUploadController fuc;
+
+ @Before
+ public void init() {
+ MockitoAnnotations.initMocks(this);
+ }
+
+
+ @Test
+ public void test() throws Exception {
+
+ Model map = new ExtendedModelMap();
+
+ Path p1 = Paths.get(".");
+ List<Path> list = new ArrayList<>();
+ list.add(p1);
+
+
+ try {
+ Mockito.when(storageService.loadAll()).thenReturn(list.stream());
+ } catch (Exception e) {
+// eLOGGER.error("Error occurred : " + e.getMessage());
+ }
+
+ try {
+ String listUploadedFiles = fuc.listUploadedFiles(map);
+
+ assertEquals("uploadForm", listUploadedFiles);
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+
+
+
+ }
+
+}
diff --git a/snmpmapper/src/test/java/org/onap/dcae/mapper/storage/FileSystemStorageServiceTest.java b/snmpmapper/src/test/java/org/onap/dcae/mapper/storage/FileSystemStorageServiceTest.java
new file mode 100644
index 0000000..f80ecf7
--- /dev/null
+++ b/snmpmapper/src/test/java/org/onap/dcae/mapper/storage/FileSystemStorageServiceTest.java
@@ -0,0 +1,93 @@
+/*
+* ============LICENSE_START=======================================================
+* ONAP : DCAE
+* ================================================================================
+* Copyright 2018 TechMahindra
+*=================================================================================
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+* ============LICENSE_END=========================================================
+*/
+package org.onap.dcae.mapper.storage;
+
+import static org.junit.Assert.*;
+
+import java.nio.file.Path;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.onap.dcae.mapper.FileUploadController;
+import org.onap.dcae.mapper.SnmpmapperApplication;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.mock.mockito.MockBean;
+import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.web.servlet.MockMvc;
+import org.springframework.web.multipart.MultipartFile;
+
+
+@RunWith(SpringRunner.class)
+@WebMvcTest(value = FileUploadController.class, secure = false)
+public class FileSystemStorageServiceTest {
+
+
+
+ StorageProperties sp = new StorageProperties();
+
+ //FileSystemStorageService service = new FileSystemStorageService(sp);
+
+
+//
+// @Before
+// public void init() {
+// MockitoAnnotations.initMocks(this);
+// }
+//
+
+ @Value("${fileService.rootPath}")
+ private String location;
+
+
+ @Autowired
+ private MockMvc mockMvc;
+
+ @Mock
+ MultipartFile file;
+
+ @MockBean
+ private FileSystemStorageService fileSystemStorageService;
+ String filename;
+
+
+ @Test
+ public void testFileSystemStorageService() {
+
+ fileSystemStorageService.init();
+ fileSystemStorageService.load(filename);
+
+
+ }
+
+ @Test
+ public void test() {
+ Path rootLocation = null;;
+ sp.setLocation(location);
+ FileSystemStorageService fss=new FileSystemStorageService(sp);
+
+}
+
+} \ No newline at end of file