aboutsummaryrefslogtreecommitdiffstats
path: root/snmpmapper/src/test
diff options
context:
space:
mode:
authorBharathS24 <BS00493532@techmahindra.com>2018-08-20 17:47:05 +0530
committerBharathS24 <BS00493532@techmahindra.com>2018-08-20 17:47:05 +0530
commit7cb9a25a7e32bcf141a5ad8f8ab1af0ed6064a99 (patch)
tree2560145d3fc9758c746fa3375ebed122278956ad /snmpmapper/src/test
parent1463aaab6db65130de04d84a68fd9331a1c0caa9 (diff)
Modified snmpmapper
Now snmpmapper is using DB(postgres) to save mapping file Issue-ID: DCAEGEN2-338 Change-Id: Ifdf173f7b405463005a96f76dee2558a291548e6 Signed-off-by: BharathS24 <BS00493532@techmahindra.com>
Diffstat (limited to 'snmpmapper/src/test')
-rw-r--r--snmpmapper/src/test/java/org/onap/dcae/mapper/FileUploadControllerTest.java99
-rw-r--r--snmpmapper/src/test/java/org/onap/dcae/mapper/StorageExceptionTest.java37
-rw-r--r--snmpmapper/src/test/java/org/onap/dcae/mapper/StorageFileNotFoundExceptionTest.java37
-rw-r--r--snmpmapper/src/test/java/org/onap/dcae/mapper/StoragePropertiesTest.java39
-rw-r--r--snmpmapper/src/test/java/org/onap/dcae/mapper/storage/FileSystemStorageServiceTest.java144
-rw-r--r--snmpmapper/src/test/java/org/onap/dcae/snmpmapperApplicationTests.java16
6 files changed, 16 insertions, 356 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
deleted file mode 100644
index d970724..0000000
--- a/snmpmapper/src/test/java/org/onap/dcae/mapper/FileUploadControllerTest.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
-* ============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 listUploadedFilesTest() 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) {
-
- }
-
- try {
- String listUploadedFiles = fuc.listUploadedFiles(map);
-
- assertEquals("uploadForm", listUploadedFiles);
- } catch (IOException e) {
-
- e.printStackTrace();
- }
-
-
-
-
- }
-
-}
diff --git a/snmpmapper/src/test/java/org/onap/dcae/mapper/StorageExceptionTest.java b/snmpmapper/src/test/java/org/onap/dcae/mapper/StorageExceptionTest.java
deleted file mode 100644
index 1f4783d..0000000
--- a/snmpmapper/src/test/java/org/onap/dcae/mapper/StorageExceptionTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
-* ============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 org.junit.Test;
-import org.onap.dcae.mapper.storage.StorageException;
-
-public class StorageExceptionTest {
-
- StorageException se = new StorageException("message");
- StorageException se1 = new StorageException("message", se);
-
- @Test
- public void test() {
-
-
-}
-}
diff --git a/snmpmapper/src/test/java/org/onap/dcae/mapper/StorageFileNotFoundExceptionTest.java b/snmpmapper/src/test/java/org/onap/dcae/mapper/StorageFileNotFoundExceptionTest.java
deleted file mode 100644
index 39fbeac..0000000
--- a/snmpmapper/src/test/java/org/onap/dcae/mapper/StorageFileNotFoundExceptionTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
-* ============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 org.junit.Test;
-import org.onap.dcae.mapper.storage.StorageFileNotFoundException;
-
-public class StorageFileNotFoundExceptionTest {
-
- StorageFileNotFoundException sfnfe = new StorageFileNotFoundException("message");
- StorageFileNotFoundException sfnfe1 = new StorageFileNotFoundException("message", sfnfe);
-
- @Test
- public void test() {
-
- }
-
-}
diff --git a/snmpmapper/src/test/java/org/onap/dcae/mapper/StoragePropertiesTest.java b/snmpmapper/src/test/java/org/onap/dcae/mapper/StoragePropertiesTest.java
deleted file mode 100644
index 64915f5..0000000
--- a/snmpmapper/src/test/java/org/onap/dcae/mapper/StoragePropertiesTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
-* ============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.assertEquals;
-
-import org.junit.Test;
-import org.onap.dcae.mapper.storage.StorageProperties;
-
-public class StoragePropertiesTest {
-
- StorageProperties sp= new StorageProperties();
-
-
-@Test
-public void testStorageProperties() {
-
- sp.setLocation("location");
- assertEquals(sp.getLocation(), "location");
-
-}
-} \ No newline at end of file
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
deleted file mode 100644
index 56fc518..0000000
--- a/snmpmapper/src/test/java/org/onap/dcae/mapper/storage/FileSystemStorageServiceTest.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
-* ============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.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.List;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-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.core.io.Resource;
-import org.springframework.mock.web.MockMultipartFile;
-import org.springframework.test.context.junit4.SpringRunner;
-import org.springframework.test.web.servlet.MockMvc;
-import org.springframework.web.multipart.MultipartFile;
-
-
-
-@RunWith(SpringRunner.class)
-@SpringBootTest(classes=SnmpmapperApplication.class)
-public class FileSystemStorageServiceTest {
-
-
-
- StorageProperties sp = new StorageProperties();
- @Autowired
- FileSystemStorageService fileSystemStorageService ;
-
-
-
- @Value("${fileService.rootPath}")
- private String location;
-
-
-
- byte[] content = null;
-
-
-
-
-
- String filename;
-
-
- @Test
- public void testFileSystemStorageServiceLoadMethod() throws IOException {
- fileSystemStorageService.init();
- saveFile();
-
- Path filePath = fileSystemStorageService.load("TestFile.txt");
-
- assertEquals(Paths.get(location), filePath.getParent());
-
-
- }
-
-
-
- @Test
- public void storeTest() throws IOException
- {
- fileSystemStorageService.init();
- saveFile();
-
- assertEquals(true, Files.exists(Paths.get(location, "TestFile.txt")));
-
-
-
-
-
- }
-
- private void saveFile() throws IOException {
- Files.deleteIfExists(Paths.get(location, "TestFile.txt"));
- content = "randomString".getBytes();
- MultipartFile file=new MockMultipartFile("TestFile.txt","TestFile.txt", "text/plain", content);
-
-
- fileSystemStorageService.store(file);
- }
- @Test
- public void testFileSystemStorageServiceLoadAllMethod() throws IOException {
- fileSystemStorageService.init();
- saveFile();
-
- Stream<Path> filePath = fileSystemStorageService.loadAll();
- List<Path> listOfPaths =filePath.collect(Collectors.toList());
-
- assertEquals(true, listOfPaths.contains(Paths.get("TestFile.txt")));
-
-
- }
-
- @Test
- public void testFileSystemStorageServiceLoadResourceMethod() throws IOException {
- fileSystemStorageService.init();
- saveFile();
-
-
-
- Resource fileResource = fileSystemStorageService.loadAsResource("TestFile.txt");
-
-
- assertEquals(Paths.get(location,"TestFile.txt").getFileName().toString(), fileResource.getFilename());
-
-
- }
-
-} \ No newline at end of file
diff --git a/snmpmapper/src/test/java/org/onap/dcae/snmpmapperApplicationTests.java b/snmpmapper/src/test/java/org/onap/dcae/snmpmapperApplicationTests.java
new file mode 100644
index 0000000..59d1d92
--- /dev/null
+++ b/snmpmapper/src/test/java/org/onap/dcae/snmpmapperApplicationTests.java
@@ -0,0 +1,16 @@
+package org.onap.dcae;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class snmpmapperApplicationTests {
+
+ @Test
+ public void contextLoads() {
+ }
+
+}