diff options
Diffstat (limited to 'vnf-sdk-function-test')
7 files changed, 105 insertions, 9 deletions
diff --git a/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/externalservice/entity/ServiceNode.java b/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/externalservice/entity/ServiceNode.java index ca647d5..3631a17 100644 --- a/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/externalservice/entity/ServiceNode.java +++ b/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/externalservice/entity/ServiceNode.java @@ -17,13 +17,13 @@ package org.onap.vnfsdk.functest.externalservice.entity; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import lombok.AllArgsConstructor; -import lombok.Data; +import lombok.Getter; +import lombok.Setter; import lombok.NoArgsConstructor; -@Data +@Getter +@Setter @NoArgsConstructor -@AllArgsConstructor @JsonIgnoreProperties(ignoreUnknown = true) public class ServiceNode { diff --git a/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/externalservice/entity/ServiceRegisterEntity.java b/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/externalservice/entity/ServiceRegisterEntity.java index d9947a5..8495c4f 100644 --- a/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/externalservice/entity/ServiceRegisterEntity.java +++ b/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/externalservice/entity/ServiceRegisterEntity.java @@ -17,16 +17,16 @@ package org.onap.vnfsdk.functest.externalservice.entity; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import lombok.AllArgsConstructor; -import lombok.Data; +import lombok.Getter; +import lombok.Setter; import lombok.NoArgsConstructor; import java.util.ArrayList; import java.util.List; -@Data +@Getter +@Setter @NoArgsConstructor -@AllArgsConstructor @JsonIgnoreProperties(ignoreUnknown = true) public class ServiceRegisterEntity { diff --git a/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/responsehandler/VnfFuncTestResponseHandler.java b/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/responsehandler/VnfFuncTestResponseHandler.java index 1efced0..6f14626 100644 --- a/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/responsehandler/VnfFuncTestResponseHandler.java +++ b/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/responsehandler/VnfFuncTestResponseHandler.java @@ -68,6 +68,7 @@ public class VnfFuncTestResponseHandler { } } + /* TO DO: check whether getResponseByFuncTestId is still needed */ public Response getResponseByFuncTestId(String funcTestId) { if ((null == mapConfigValues) || (null == mapConfigValues.get(resultPathKey))) { diff --git a/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/FileUtilTest.java b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/FileUtilTest.java index 01e2c0b..67b701c 100644 --- a/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/FileUtilTest.java +++ b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/FileUtilTest.java @@ -16,9 +16,13 @@ package org.onap.vnfsdk.functest; +import org.junit.Before; import org.junit.Test; import java.io.File; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Modifier; import static org.junit.Assert.assertTrue; @@ -30,9 +34,21 @@ public class FileUtilTest { private String zipFileName = "src/test/resources/RobotScript.zip"; + @Before + public void setUp() { + FileUtil.createDirectory(createDirPath); + } + @Test - public void testCreateDirectory() { + public void testConstructorIsPrivate() throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException { + Constructor<FileUtil> constructor = FileUtil.class.getDeclaredConstructor(); + assertTrue(Modifier.isPrivate(constructor.getModifiers())); + constructor.setAccessible(true); + constructor.newInstance(); + } + @Test + public void testCreateDirectory() { assertTrue(FileUtil.createDirectory(createDirPath)); } @@ -47,12 +63,31 @@ public class FileUtilTest { } @Test + public void testUnzip() { + try { + FileUtil.unzip(zipFileName, createDirPath); + } catch (Exception e) { + e.printStackTrace(); + } + } + + @Test public void testGetDirectory() { FileUtil.getDirectory("."); assertTrue(true); } @Test + public void testCheckFileExist() { + assertTrue(FileUtil.checkFileExist(deleteDirPath)); + } + + @Test + public void testDeleteFileWithPath() { + assertTrue(FileUtil.deleteFile(deleteDirPath)); + } + + @Test public void testConvertZipFiletoByteArray() { byte[] byteArrayFile = FileUtil.convertZipFiletoByteArray(zipFileName); // assertNotNull(byteArrayFile); diff --git a/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/common/TestConfig.java b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/common/TestConfig.java index 132fdf8..1732c74 100644 --- a/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/common/TestConfig.java +++ b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/common/TestConfig.java @@ -21,7 +21,12 @@ import org.junit.Before; import org.junit.Test; import org.onap.vnfsdk.functest.VnfSdkFuncTestAppConfiguration; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Modifier; + import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; public class TestConfig { @@ -33,6 +38,14 @@ public class TestConfig { } @Test + public void testConstructorIsPrivate() throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException { + Constructor<Config> constructor = Config.class.getDeclaredConstructor(); + assertTrue(Modifier.isPrivate(constructor.getModifiers())); + constructor.setAccessible(true); + constructor.newInstance(); + } + + @Test public void testVnfSdkConfigBean() { vnfSdkBean.setTemplate(""); vnfSdkBean.setServiceIp("127.0.0.1"); diff --git a/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/externalservice/entity/ServiceRegisterEntityTest.java b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/externalservice/entity/ServiceRegisterEntityTest.java index 493882f..c75308c 100644 --- a/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/externalservice/entity/ServiceRegisterEntityTest.java +++ b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/externalservice/entity/ServiceRegisterEntityTest.java @@ -42,6 +42,7 @@ public class ServiceRegisterEntityTest { serviceRegistry.setServiceName("nfvo"); serviceRegistry.setVersion("5.6"); + serviceRegistry.setUrl("http://localhost:8080"); serviceRegistry.setProtocol("http"); serviceRegistry.setVisualRange("range"); @@ -55,6 +56,7 @@ public class ServiceRegisterEntityTest { assertNotNull(serviceRegistry); assertNotNull(serviceRegistry.getServiceName()); assertNotNull(serviceRegistry.getVersion()); + assertNotNull(serviceRegistry.getUrl()); assertNotNull(serviceRegistry.getProtocol()); assertNotNull(serviceRegistry.getVisualRange()); assertNotNull(serviceRegistry.getNodes()); @@ -65,4 +67,9 @@ public class ServiceRegisterEntityTest { public void testSetSingleNode() { serviceRegistry.setSingleNode("192.168.4.47", "8080", 10); } + + @Test + public void testSetSingleNodeEmptyIp() { + serviceRegistry.setSingleNode("", "8080", 10); + } } diff --git a/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/responsehandler/VnfFuncTestResponseHandlerTest.java b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/responsehandler/VnfFuncTestResponseHandlerTest.java index 26007e3..2cbd48d 100644 --- a/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/responsehandler/VnfFuncTestResponseHandlerTest.java +++ b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/responsehandler/VnfFuncTestResponseHandlerTest.java @@ -18,13 +18,19 @@ package org.onap.vnfsdk.functest.responsehandler; import org.junit.Test; +import javax.ws.rs.core.Response; import java.lang.reflect.Method; +import java.util.Map; +import java.util.UUID; import static org.junit.Assert.assertNotNull; public class VnfFuncTestResponseHandlerTest { private VnfFuncTestResponseHandler vnfSdkFuncHandler; + private Map<String, String> mapConfigValues; + private UUID taskID = UUID.fromString("59d1e651-df9f-4008-902f-e3b377e6ec30"); + private Response response = null; @Test public void testGetInstance() { @@ -33,6 +39,18 @@ public class VnfFuncTestResponseHandlerTest { } @Test + public void testSetConfigMap() { + try { + Object vnfFuncTestResponseHandlerObj = VnfFuncTestResponseHandler.getInstance(); + Method m = vnfFuncTestResponseHandlerObj.getClass().getDeclaredMethod("setConfigMap", new Class[]{Map.class}); + m.setAccessible(true); + m.invoke(vnfFuncTestResponseHandlerObj, mapConfigValues); + } catch (Exception e) { + e.printStackTrace(); + } + } + + @Test public void testLoadConfigurations() { try { Object vnfFuncTestResponseHandlerObj = VnfFuncTestResponseHandler.getInstance(); @@ -43,4 +61,26 @@ public class VnfFuncTestResponseHandlerTest { e.printStackTrace(); } } + + /* TO DO: check whether getResponseByFuncTestId is still needed */ + @Test + public void testGetResponseByFuncTestId() { + try { + vnfSdkFuncHandler = VnfFuncTestResponseHandler.getInstance(); + response = vnfSdkFuncHandler.getResponseByFuncTestId(taskID.toString()); + } catch (Exception e) { + e.printStackTrace(); + } + } + + @Test + public void testDownloadResults() { + try { + vnfSdkFuncHandler = VnfFuncTestResponseHandler.getInstance(); + response = vnfSdkFuncHandler.downloadResults(taskID.toString()); + assertNotNull(response); + } catch (Exception e) { + e.printStackTrace(); + } + } } |