diff options
author | Soumendu Sekhar Acharya <sa00498080@techmahindra.com> | 2018-08-01 17:21:15 +0530 |
---|---|---|
committer | Soumendu Sekhar Acharya <SA00498080@techmahindra.com> | 2018-08-24 12:55:16 +0000 |
commit | 929c1f13697f338245571694beb73adbd39a5b78 (patch) | |
tree | 4ece0941e34c012407565aa01b34235be93688ad /SdncReports/SdncReportsApi/src/test | |
parent | cc49cb7753ff820dada996ab1d56263243630395 (diff) |
SDN-C support&provide network layer tests Using IP
SDNC-252,SDNC-253,SDNC-264,SDNC-266 are added as part of this story
Change-Id: Ic65ca32c4786fac1be9269dbc6a2162b433f0630
Issue-ID: SDNC-264
Signed-off-by: Soumendu Sekhar Acharya <sa00498080@techmahindra.com>
Former-commit-id: d90280efcad173fd2250b8e2e98cb8f480007657
Diffstat (limited to 'SdncReports/SdncReportsApi/src/test')
17 files changed, 1148 insertions, 0 deletions
diff --git a/SdncReports/SdncReportsApi/src/test/java/com/onap/sdnc/reports/ApplicationTest.java b/SdncReports/SdncReportsApi/src/test/java/com/onap/sdnc/reports/ApplicationTest.java new file mode 100644 index 00000000..58c9cd7b --- /dev/null +++ b/SdncReports/SdncReportsApi/src/test/java/com/onap/sdnc/reports/ApplicationTest.java @@ -0,0 +1,35 @@ +package com.onap.sdnc.reports; + +import static org.junit.Assert.assertNotNull; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +import com.onap.sdnc.reports.controller.ReportController; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = Application.class) +public class ApplicationTest { + + private static final Logger logger = LogManager.getLogger(ApplicationTest.class); + + @Autowired + private ReportController reportController; + + @Test + public void controllerAutoWireTest() + { + assertNotNull("Due to Application Context Fail", reportController); + } + + @Test + public void contextLoads() throws Exception + { + logger.info("Context Load Test Succeded"); + } +} diff --git a/SdncReports/SdncReportsApi/src/test/java/com/onap/sdnc/reports/controller/ReportControllerTest.java b/SdncReports/SdncReportsApi/src/test/java/com/onap/sdnc/reports/controller/ReportControllerTest.java new file mode 100644 index 00000000..7e16e116 --- /dev/null +++ b/SdncReports/SdncReportsApi/src/test/java/com/onap/sdnc/reports/controller/ReportControllerTest.java @@ -0,0 +1,100 @@ +/* +* ============LICENSE_START======================================================= +* ONAP : SDNC-FEATURES +* ================================================================================ +* 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 com.onap.sdnc.reports.controller; + +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +import java.util.Arrays; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.http.MediaType; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; + +import com.onap.sdnc.reports.Application; +import com.onap.sdnc.reports.controller.ReportController; +import com.onap.sdnc.reports.rest.model.PreTestModel; +import com.onap.sdnc.reports.service.IReportService; + +import static org.junit.Assert.assertNotNull; +import static org.mockito.Mockito.when; + +@RunWith(SpringRunner.class) +@ContextConfiguration(classes = { Application.class }) +@WebMvcTest(ReportController.class) + +public class ReportControllerTest { + + @Autowired + private MockMvc mvc; + + @MockBean + private IReportService reportService; + + private Date startDate, endDate; + + @Test + public void reportServiceAutoWireTest() { + assertNotNull("Due to Application Context Fail", reportService); + } + + @Test + public void whenFindReportByDeviceName_thenReturnThis() throws Exception { + Calendar calendar = Calendar.getInstance(); + + calendar.add(Calendar.DATE, -7); + calendar.add(Calendar.HOUR_OF_DAY, 00); + calendar.add(Calendar.MINUTE, 00); + calendar.add(Calendar.SECOND, 00); + calendar.add(Calendar.MILLISECOND, 00); + startDate = calendar.getTime(); + + Calendar endDateCalendar = Calendar.getInstance(); + + endDateCalendar.add(Calendar.HOUR_OF_DAY, 23); + endDateCalendar.add(Calendar.MINUTE, 59); + calendar.add(Calendar.SECOND, 00); + endDateCalendar.add(Calendar.MILLISECOND, 00); + endDate = endDateCalendar.getTime(); + + Date d = new Date(); + startDate = d; + endDate = d; + PreTestModel preTestModel = new PreTestModel(1, 1, "NetWorkTest", "Router", "Ping Got Successful", "Pass", + endDate); + + List<PreTestModel> allTests = Arrays.asList(preTestModel); + + when(reportService.findReportByDeviceIP(startDate, endDate, "0.0.0.0")).thenReturn(allTests); + + mvc.perform(get("/findReportByDeviceIP/{startDate}/{endDate}/{deviceIP}/", startDate, endDate, "0.0.0.0") + .contentType(MediaType.APPLICATION_JSON)).andExpect(status().is(400)); + + } +} diff --git a/SdncReports/SdncReportsApi/src/test/java/com/onap/sdnc/reports/service/CertificationClientServiceTest.java b/SdncReports/SdncReportsApi/src/test/java/com/onap/sdnc/reports/service/CertificationClientServiceTest.java new file mode 100644 index 00000000..6da3921b --- /dev/null +++ b/SdncReports/SdncReportsApi/src/test/java/com/onap/sdnc/reports/service/CertificationClientServiceTest.java @@ -0,0 +1,94 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights + * reserved. + * ================================================================================ + * 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 com.onap.sdnc.reports.service; + +import static org.junit.Assert.assertEquals; +import java.util.ArrayList; +import java.util.List; +import org.junit.Test; +import org.mockito.Mock; +import com.onap.sdnc.reports.model.CertificationInputs; +import com.onap.sdnc.reports.model.Input; +import com.onap.sdnc.reports.model.Output; +import com.onap.sdnc.reports.model.PreTestResponse; + +public class CertificationClientServiceTest { + + @Mock + CertificationClientService cService; + + private String hostname = "host"; + private String ipaddress = "10.53.122.25"; + private String statistics = "0% loss"; + private String avgTime = "Minimum = 0ms"; + private String testType = "network"; + + @Test(expected = NullPointerException.class) + public void TestRestClient() { + + PreTestResponse pretestResponse = new PreTestResponse(); + pretestResponse.setIpaddress(ipaddress); + pretestResponse.setAvgTime(avgTime); + pretestResponse.setHostname(hostname); + pretestResponse.setStatus("successs"); + pretestResponse.setStatistics(statistics); + pretestResponse.setTesttype(testType); + + List<PreTestResponse> preTestNew = new ArrayList<PreTestResponse>(); + preTestNew.add(pretestResponse); + + Input input = new Input(); + input.setIpaddress(ipaddress); + input.setHostname(hostname); + input.setNetwork(testType); + + CertificationInputs certificationInputs = new CertificationInputs(); + certificationInputs.setInput(input); + CertificationClientService certificationClientservice = new CertificationClientService(); + certificationClientservice.restClient(certificationInputs, preTestNew, testType); + + } + + @Test + public void pingServiceTest() { + CertificationInputs vnfinfo = new CertificationInputs(); + Input input = new Input(); + input.setIpaddress("10.53.122.25"); + input.setHostname("hostname"); + vnfinfo.setInput(input); + Output mockOutput = new Output(); + mockOutput.setIpaddress("10.53.122.25"); + Output output = CertificationClientService.pingTest(vnfinfo); + assertEquals(output.getIpaddress(), input.getIpaddress()); + } + + @Test + public void protocolTest() { + CertificationInputs vnfinfo = new CertificationInputs(); + Input input = new Input(); + input.setIpaddress(ipaddress); + input.setHostname("hostname"); + vnfinfo.setInput(input); + Output mockOutput = new Output(); + mockOutput.setIpaddress(ipaddress); + } +} diff --git a/SdncReports/SdncReportsApi/src/test/java/com/onap/sdnc/reports/service/LayerTestServiceImplTest.java b/SdncReports/SdncReportsApi/src/test/java/com/onap/sdnc/reports/service/LayerTestServiceImplTest.java new file mode 100644 index 00000000..c721401f --- /dev/null +++ b/SdncReports/SdncReportsApi/src/test/java/com/onap/sdnc/reports/service/LayerTestServiceImplTest.java @@ -0,0 +1,84 @@ +package com.onap.sdnc.reports.service; + +import static org.junit.Assert.*; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; +import com.onap.sdnc.reports.model.CertificationInputs; +import com.onap.sdnc.reports.model.Input; +import com.onap.sdnc.reports.model.PreTestResponse; +import com.onap.sdnc.reports.model.Request; +import com.onap.sdnc.reports.model.Response; +import com.onap.sdnc.reports.model.ValidationTestType; +import com.onap.sdnc.reports.model.VnfList; + +public class LayerTestServiceImplTest { + + @Mock + CertificationClientService cService; + + @Mock + LayerTestServiceImpl layerTestServiceImpl; + + @Before + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); + } + + @Test + public void networkCertificationTest() { + + Request restReq = new Request(); + Input input = new Input(); + CertificationInputs vnfinfo = new CertificationInputs(); + ValidationTestType vType = new ValidationTestType(); + + List<ValidationTestType> lVtype = new ArrayList<ValidationTestType>(); + vType.setTypeId("1"); + vType.setValidationType("Network Layer"); + lVtype.add(vType); + + ValidationTestType[] validationTestType = new ValidationTestType[lVtype.size()]; + lVtype.toArray(validationTestType); + restReq.setValidationTestType(validationTestType); + + VnfList vnfList = new VnfList(); + vnfList.setHostName("hostname"); + vnfList.setIpAddress("0.0.0.0"); + vnfList.setPortNo("0"); + + List<VnfList> vnfListArray = new ArrayList<VnfList>(); + vnfListArray.add(vnfList); + + VnfList[] vnfInputArray = new VnfList[vnfListArray.size()]; + vnfListArray.toArray(vnfInputArray); + restReq.setVnfList(vnfInputArray); + input.setHostname("hostname"); + input.setIpaddress("10.20.30.50"); + input.setNetwork("network"); + vnfinfo.setInput(input); + + Response res = new Response(); + + PreTestResponse preTestRes = new PreTestResponse(); + preTestRes.setIpaddress("0.0.0.0"); + + List<PreTestResponse> preList = new ArrayList<PreTestResponse>(); + preList.add(preTestRes); + + res.setPreTestResponse(preList); + + Mockito.when(layerTestServiceImpl.networkCertification(restReq)).thenReturn(res); + + Response actualRes = layerTestServiceImpl.networkCertification(restReq); + + assertEquals(actualRes.getPreTestResponse().get(0).getIpaddress(), vnfList.getIpAddress()); + } + +} diff --git a/SdncReports/SdncReportsApi/src/test/java/com/onap/sdnc/reports/service/NetworkCertificationTest.java b/SdncReports/SdncReportsApi/src/test/java/com/onap/sdnc/reports/service/NetworkCertificationTest.java new file mode 100644 index 00000000..c21b6036 --- /dev/null +++ b/SdncReports/SdncReportsApi/src/test/java/com/onap/sdnc/reports/service/NetworkCertificationTest.java @@ -0,0 +1,109 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights + * reserved. + * ================================================================================ + * 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 com.onap.sdnc.reports.service; +import static org.junit.Assert.assertEquals; +import java.util.ArrayList; +import java.util.List; +import org.junit.Before; +import org.junit.Test; +import org.mockito.ArgumentCaptor; +import org.mockito.Captor; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; +/*import com.onap.sdnc.testapi.model.ODLClientResponse; +import com.onap.sdnc.testapi.model.PreTestResponse; +import com.onap.sdnc.testapi.model.Request; +import com.onap.sdnc.testapi.model.Response; +import com.onap.sdnc.testapi.model.ValidationTestType; +import com.onap.sdnc.testapi.model.Vnf; +import com.onap.sdnc.testapi.model.VnfList; +import com.onap.sdnc.testapi.service.LayerTestServiceImpl;*/ + +import com.onap.sdnc.reports.model.ODLClientResponse; +import com.onap.sdnc.reports.model.PreTestResponse; +import com.onap.sdnc.reports.model.Request; +import com.onap.sdnc.reports.model.Response; +import com.onap.sdnc.reports.model.ValidationTestType; +import com.onap.sdnc.reports.model.Vnf; +import com.onap.sdnc.reports.model.VnfList; + +public class NetworkCertificationTest { + + @Mock + LayerTestServiceImpl layerTestServiceImpl; + + @Captor + ArgumentCaptor<LayerTestServiceImpl> captor; + + private String hostname = "host"; + private String ipaddress = "0.0.0.0"; + private String network = "Network Layer"; + private String statistics = "0% loss"; + private String avgTime = "Minimum = 0ms"; + private String testtype = "network"; + private String typeId = "1"; + + Response response = new Response(); + PreTestResponse preTestResponse = new PreTestResponse(); + ODLClientResponse odlClientResponse = new ODLClientResponse(); + Request restReq = new Request(); + + @Before + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); + } + + @Test + public void TestNetworkClient() { + + preTestResponse.setAvgTime(avgTime); + preTestResponse.setIpaddress(ipaddress); + preTestResponse.setStatistics(statistics); + preTestResponse.setStatus("reachable"); + preTestResponse.setTesttype(testtype); + + List<PreTestResponse> listPreTestResponse = new ArrayList<PreTestResponse>(); + listPreTestResponse.add(preTestResponse); + response.setPreTestResponse(listPreTestResponse); + + ValidationTestType validationTestType = new ValidationTestType(); + validationTestType.setTypeId(typeId); + validationTestType.setValidationType(network); + + VnfList<List> vnflistt = new VnfList<List>(); + vnflistt.setHostName(hostname); + vnflistt.setIpAddress(ipaddress); + vnflistt.setPortNo(null); + + VnfList[] vnflist = restReq.getVnfList(); + ValidationTestType[] validationTestTypee = restReq.getValidationTestType(); + + Vnf vnf = new Vnf(); + vnf.setValidationTestType(validationTestTypee); + vnf.setVnfList(vnflist); + Mockito.when(layerTestServiceImpl.networkCertification(restReq)).thenReturn(response); + Response res = layerTestServiceImpl.networkCertification(restReq); + + assertEquals(res.getPreTestResponse(), response.getPreTestResponse()); + } +} diff --git a/SdncReports/SdncReportsApi/src/test/java/com/onap/sdnc/reports/service/ReportServiceImplTest.java b/SdncReports/SdncReportsApi/src/test/java/com/onap/sdnc/reports/service/ReportServiceImplTest.java new file mode 100644 index 00000000..27b88da3 --- /dev/null +++ b/SdncReports/SdncReportsApi/src/test/java/com/onap/sdnc/reports/service/ReportServiceImplTest.java @@ -0,0 +1,127 @@ +package com.onap.sdnc.reports.service; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.Assert.assertNotNull; + +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mockito; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; +import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.TestConfiguration; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.context.annotation.Bean; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringRunner; + +import com.onap.sdnc.reports.Application; +import com.onap.sdnc.reports.config.EmbeddedMariaDbConfig; +import com.onap.sdnc.reports.model.DeviceConfig; +import com.onap.sdnc.reports.model.PreTestConfig; +import com.onap.sdnc.reports.repository.PreTestConfigRepository; +import com.onap.sdnc.reports.rest.model.PreTestModel; + +import org.springframework.test.annotation.DirtiesContext; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = Application.class) +@ContextConfiguration(classes = EmbeddedMariaDbConfig.class) +@DataJpaTest +@AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE) +@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) +public class ReportServiceImplTest { + + private static final Logger logger = LogManager.getLogger(ReportServiceImplTest.class); + + private Date startDate, endDate; + + @TestConfiguration + static class ReportServiceImplTestContextConfiguration { + @Bean + public IReportService reportService() { + return new ReportServiceImpl(); + } + } + + @Autowired + private IReportService reportService; + + @MockBean + private PreTestConfigRepository preTestConfigRepository; + + @Test + public void reportServiceAutoWireTest() { + assertNotNull("Due to Application Context Fail", reportService); + } + + @Test + public void preTestConfigRepositoryAutoWireTest() { + assertNotNull("Due to Application Context Fail", preTestConfigRepository); + } + + @Before + public void setUp() { + DeviceConfig deviceConfig = new DeviceConfig(); + deviceConfig.setDeviceIP("0.0.0.0"); + deviceConfig.setPreTestConfig(null); + deviceConfig.setCreationDate(new Date().toLocaleString()); + + PreTestConfig obj = new PreTestConfig(); + obj.setDevice(deviceConfig); + obj.setExecuationDetails("Ping Successful"); + obj.setResult("Pass"); + + obj.setTestName("Network Layer"); + obj.setTimestamp(new Date()); + + Calendar calendar = Calendar.getInstance(); + + calendar.add(Calendar.DATE, -7); + calendar.add(Calendar.HOUR_OF_DAY, 00); + calendar.add(Calendar.MINUTE, 00); + calendar.add(Calendar.SECOND, 00); + calendar.add(Calendar.MILLISECOND, 00); + startDate = calendar.getTime(); + + Calendar endDateCalendar = Calendar.getInstance(); + + endDateCalendar.add(Calendar.HOUR_OF_DAY, 23); + endDateCalendar.add(Calendar.MINUTE, 59); + calendar.add(Calendar.SECOND, 00); + endDateCalendar.add(Calendar.MILLISECOND, 00); + endDate = endDateCalendar.getTime(); + + System.out.println( + "Before Call : startDate " + startDate.toLocaleString() + " endDate : " + endDate.toLocaleString()); + List<PreTestConfig> configList = new ArrayList<>(); + configList.add(obj); + Mockito.when(preTestConfigRepository.findReportByDeviceIP(startDate, endDate, "0.0.0.0")) + .thenReturn(configList); + } + + @Test + public void whenFindByDeviceName_thenReturPreTest() { + int expectedTestId = 0; + System.out.println( + "Test Call : startDate " + startDate.toLocaleString() + " endDate : " + endDate.toLocaleString()); + + List<PreTestModel> testList; + try { + testList = reportService.findReportByDeviceIP(startDate, endDate, "10.0.0.0"); + assertThat(testList.get(0).getTestid()).isEqualTo(expectedTestId); + } catch (Exception e) { + + e.printStackTrace(); + } + } +} diff --git a/SdncReports/SdncReportsApi/src/test/java/com/onap/sdnc/testapi/model/CertificationInputsTest.java b/SdncReports/SdncReportsApi/src/test/java/com/onap/sdnc/testapi/model/CertificationInputsTest.java new file mode 100644 index 00000000..462f30f7 --- /dev/null +++ b/SdncReports/SdncReportsApi/src/test/java/com/onap/sdnc/testapi/model/CertificationInputsTest.java @@ -0,0 +1,61 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights + * reserved. + * ================================================================================ + * 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 com.onap.sdnc.testapi.model; + +import static org.junit.Assert.assertEquals; +import org.junit.Before; +import org.junit.Test; +import org.mockito.MockitoAnnotations; +import com.onap.sdnc.reports.model.CertificationInputs; + +import com.onap.sdnc.reports.model.Input; + +public class CertificationInputsTest { + + private String hostname = "host"; + private String ipaddress = "0.0.0.0"; + private String network = "Network Layer"; + + Input input = new Input(); + + @Before + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); + } + + @Test + public void TestCertificationInputs() { + + input.setIpaddress(ipaddress); + input.setHostname(hostname); + input.setNetwork(network); + + CertificationInputs certificationInputs=new CertificationInputs(); + certificationInputs.setInput(input); + + assertEquals(certificationInputs.getInput(), input); + assertEquals(input.getHostname(), hostname); + assertEquals(input.getIpaddress(), ipaddress); + assertEquals(input.getNetwork(), network); + + } +}
\ No newline at end of file diff --git a/SdncReports/SdncReportsApi/src/test/java/com/onap/sdnc/testapi/model/InputTest.java b/SdncReports/SdncReportsApi/src/test/java/com/onap/sdnc/testapi/model/InputTest.java new file mode 100644 index 00000000..d0898374 --- /dev/null +++ b/SdncReports/SdncReportsApi/src/test/java/com/onap/sdnc/testapi/model/InputTest.java @@ -0,0 +1,34 @@ +package com.onap.sdnc.testapi.model; + +import static org.junit.Assert.assertEquals; +import org.junit.Before; +import org.junit.Test; +import org.mockito.MockitoAnnotations; +import com.onap.sdnc.reports.model.Input; + +public class InputTest { + + private String hostname = "host"; + private String ipaddress = "0.0.0.0"; + private String network = "Network Layer"; + + Input input = new Input(); + + @Before + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); + } + + @Test + public void TestInput() { + + input.setHostname(hostname); + input.setIpaddress(ipaddress); + input.setNetwork(network); + + assertEquals(input.getHostname(), hostname); + assertEquals(input.getIpaddress(), ipaddress); + assertEquals(input.getNetwork(), network); + + } +}
\ No newline at end of file diff --git a/SdncReports/SdncReportsApi/src/test/java/com/onap/sdnc/testapi/model/OdlResponseTest.java b/SdncReports/SdncReportsApi/src/test/java/com/onap/sdnc/testapi/model/OdlResponseTest.java new file mode 100644 index 00000000..6c9f4568 --- /dev/null +++ b/SdncReports/SdncReportsApi/src/test/java/com/onap/sdnc/testapi/model/OdlResponseTest.java @@ -0,0 +1,60 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights + * reserved. + * ================================================================================ + * 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 com.onap.sdnc.testapi.model; + +import static org.junit.Assert.assertEquals; +import org.junit.Before; +import org.junit.Test; +import org.mockito.MockitoAnnotations; +import com.onap.sdnc.reports.model.ODLClientResponse; +import com.onap.sdnc.reports.model.Output; + +public class OdlResponseTest { + + private String hostname = "host"; + private String ipaddress = "0.0.0.0"; + private String statistics = "0% loss"; + private String avgTime = "Minimum = 0ms"; + private String testresult = "testresult"; + Output output = new Output(); + ODLClientResponse odlClientResponse = new ODLClientResponse(); + + @Before + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); + } + + @Test + public void TestODLClientResponse() { + output.setAvgTime(avgTime); + output.setHostname(hostname); + output.setIpaddress(ipaddress); + output.setTestresult(testresult); + output.setStatistics(statistics); + output.setStatus("unreachable"); + output.setReason("Check your input"); + + odlClientResponse.setOutput(output); + + assertEquals(odlClientResponse.getOutput(), output); + } +}
\ No newline at end of file diff --git a/SdncReports/SdncReportsApi/src/test/java/com/onap/sdnc/testapi/model/OutputTest.java b/SdncReports/SdncReportsApi/src/test/java/com/onap/sdnc/testapi/model/OutputTest.java new file mode 100644 index 00000000..a01049d5 --- /dev/null +++ b/SdncReports/SdncReportsApi/src/test/java/com/onap/sdnc/testapi/model/OutputTest.java @@ -0,0 +1,65 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights + * reserved. + * ================================================================================ + * 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 com.onap.sdnc.testapi.model; + +import static org.junit.Assert.assertEquals; +import org.junit.Before; +import org.junit.Test; +import org.mockito.MockitoAnnotations; +import com.onap.sdnc.reports.model.Output; + +public class OutputTest { + + private String hostname = "host"; + private String ipaddress = "0.0.0.0"; + private String statistics = "0% loss"; + private String avgTime = "Minimum = 0ms"; + private String testresult="testresult"; + + @Before + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); + } + + @Test + public void TestOutput() { + + Output output=new Output(); + + output.setAvgTime(avgTime); + output.setHostname(hostname); + output.setIpaddress(ipaddress); + output.setTestresult(testresult); + output.setStatistics(statistics); + output.setStatus("unreachable"); + output.setReason("Check your input"); + + assertEquals(output.getHostname(), hostname); + assertEquals(output.getIpaddress(), ipaddress); + assertEquals(output.getAvgTime(),avgTime); + assertEquals(output.getStatistics(), statistics); + assertEquals(output.getStatus(), "unreachable"); + assertEquals(output.getReason(), "Check your input"); + assertEquals(output.getTestresult(), testresult); + } + +} diff --git a/SdncReports/SdncReportsApi/src/test/java/com/onap/sdnc/testapi/model/PreTestResponseTest.java b/SdncReports/SdncReportsApi/src/test/java/com/onap/sdnc/testapi/model/PreTestResponseTest.java new file mode 100644 index 00000000..669e43bf --- /dev/null +++ b/SdncReports/SdncReportsApi/src/test/java/com/onap/sdnc/testapi/model/PreTestResponseTest.java @@ -0,0 +1,59 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights + * reserved. + * ================================================================================ + * 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 com.onap.sdnc.testapi.model; + +import static org.junit.Assert.assertEquals; +import org.junit.Before; +import org.junit.Test; +import org.mockito.MockitoAnnotations; +import com.onap.sdnc.reports.model.PreTestResponse; + +public class PreTestResponseTest { + + private String ipaddress = "0.0.0.0"; + private String avgTime = "Minimum = 0ms"; + private String statistics = "0% loss"; + private String testtype = "network"; + + PreTestResponse preTestResponse = new PreTestResponse(); + + @Before + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); + } + + @Test + public void TestPreTestResponse() { + + preTestResponse.setAvgTime(avgTime); + preTestResponse.setIpaddress(ipaddress); + preTestResponse.setStatistics(statistics); + preTestResponse.setStatus("reachable"); + preTestResponse.setTesttype(testtype); + + assertEquals(preTestResponse.getAvgTime(), avgTime); + assertEquals(preTestResponse.getIpaddress(), ipaddress); + assertEquals(preTestResponse.getStatistics(), statistics); + assertEquals(preTestResponse.getStatus(), "reachable"); + assertEquals(preTestResponse.getTesttype(), testtype); + } +}
\ No newline at end of file diff --git a/SdncReports/SdncReportsApi/src/test/java/com/onap/sdnc/testapi/model/RequestTest.java b/SdncReports/SdncReportsApi/src/test/java/com/onap/sdnc/testapi/model/RequestTest.java new file mode 100644 index 00000000..65154100 --- /dev/null +++ b/SdncReports/SdncReportsApi/src/test/java/com/onap/sdnc/testapi/model/RequestTest.java @@ -0,0 +1,75 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights + * reserved. + * ================================================================================ + * 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 com.onap.sdnc.testapi.model; + +import static org.junit.Assert.assertEquals; +import java.util.List; +import org.junit.Before; +import org.junit.Test; +import org.mockito.MockitoAnnotations; +import com.onap.sdnc.reports.model.Request; +import com.onap.sdnc.reports.model.ValidationTestType; +import com.onap.sdnc.reports.model.Vnf; +import com.onap.sdnc.reports.model.VnfList; + +public class RequestTest { + + private String hostname = "host"; + private String ipaddress = "0.0.0.0"; + private String network = "Network Layer"; + private String typeId="1"; + + private ValidationTestType[] validationTestTypee; + Request restReq= new Request(); + + @Before + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); + } + + @SuppressWarnings("deprecation") + @Test + public void TestRequest() { + ValidationTestType validationTestType = new ValidationTestType(); + validationTestType.setTypeId(typeId); + validationTestType.setValidationType(network); + + VnfList<List> vnflistt = new VnfList<List>(); + vnflistt.setHostName(hostname); + vnflistt.setIpAddress(ipaddress); + vnflistt.setPortNo(null); + + VnfList[] vnflist = restReq.getVnfList(); + restReq.setValidationTestType(validationTestTypee); + restReq.setVnfList(vnflist); + + ValidationTestType[] validationTestTypee = restReq.getValidationTestType(); + + Vnf vnf = new Vnf(); + vnf.setValidationTestType(validationTestTypee); + vnf.setVnfList(vnflist); + + assertEquals(restReq.getValidationTestType(), validationTestTypee); + assertEquals(restReq.getVnfList(), vnflist); + } + +} diff --git a/SdncReports/SdncReportsApi/src/test/java/com/onap/sdnc/testapi/model/ResponseTest.java b/SdncReports/SdncReportsApi/src/test/java/com/onap/sdnc/testapi/model/ResponseTest.java new file mode 100644 index 00000000..c802f092 --- /dev/null +++ b/SdncReports/SdncReportsApi/src/test/java/com/onap/sdnc/testapi/model/ResponseTest.java @@ -0,0 +1,66 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights + * reserved. + * ================================================================================ + * 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 com.onap.sdnc.testapi.model; + +import static org.junit.Assert.assertEquals; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.MockitoAnnotations; +import com.onap.sdnc.reports.model.PreTestResponse; +import com.onap.sdnc.reports.model.Response; + + +public class ResponseTest { + + private String ipaddress = "0.0.0.0"; + private String statistics = "0% loss"; + private String avgTime = "Minimum = 0ms"; + private String testtype = "network"; + + PreTestResponse preTestResponse=new PreTestResponse(); + Response response= new Response(); + + @Before + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); + } + + @Test + public void TestResponse() { + preTestResponse.setAvgTime(avgTime); + preTestResponse.setIpaddress(ipaddress); + preTestResponse.setStatistics(statistics); + preTestResponse.setStatus("reachable"); + preTestResponse.setTesttype(testtype); + + List<PreTestResponse> listPreTestResponse=new ArrayList<PreTestResponse>(); + listPreTestResponse.add(preTestResponse); + response.setPreTestResponse(listPreTestResponse); + + assertEquals(response.getPreTestResponse(), listPreTestResponse); + } + +}
\ No newline at end of file diff --git a/SdncReports/SdncReportsApi/src/test/java/com/onap/sdnc/testapi/model/ValidationTest.java b/SdncReports/SdncReportsApi/src/test/java/com/onap/sdnc/testapi/model/ValidationTest.java new file mode 100644 index 00000000..37dc750a --- /dev/null +++ b/SdncReports/SdncReportsApi/src/test/java/com/onap/sdnc/testapi/model/ValidationTest.java @@ -0,0 +1,48 @@ +/* ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights + * reserved. + * ================================================================================ + * 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 com.onap.sdnc.testapi.model; + +import static org.junit.Assert.assertEquals; +import org.junit.Before; +import org.junit.Test; +import org.mockito.MockitoAnnotations; +import com.onap.sdnc.reports.model.ValidationTestType; + + +public class ValidationTest { + + private String validationType="network"; + private String typeId="1"; + @Before + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); + } + + @Test + public void TestValidation() { + ValidationTestType validationTestType=new ValidationTestType(); + validationTestType.setTypeId(typeId); + validationTestType.setValidationType(validationType); + + assertEquals(validationTestType.getTypeId(), "1"); + assertEquals(validationTestType.getValidationType(), "network"); + } +} diff --git a/SdncReports/SdncReportsApi/src/test/java/com/onap/sdnc/testapi/model/VnfListTest.java b/SdncReports/SdncReportsApi/src/test/java/com/onap/sdnc/testapi/model/VnfListTest.java new file mode 100644 index 00000000..6a24e46f --- /dev/null +++ b/SdncReports/SdncReportsApi/src/test/java/com/onap/sdnc/testapi/model/VnfListTest.java @@ -0,0 +1,53 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights + * reserved. + * ================================================================================ + * 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 com.onap.sdnc.testapi.model; + +import static org.junit.Assert.assertEquals; +import java.util.List; +import org.junit.Before; +import org.junit.Test; +import org.mockito.MockitoAnnotations; +import com.onap.sdnc.reports.model.VnfList; + +public class VnfListTest { + + private String hostname = "host"; + private String ipaddress = "0.0.0.0"; + private String portnumber = null; + + @Before + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); + } + + @Test + public void TestVnfList() { + VnfList<List> vnfListt = new VnfList<List>(); + vnfListt.setHostName(hostname); + vnfListt.setIpAddress(ipaddress); + vnfListt.setPortNo(null); + + assertEquals(vnfListt.getHostName(), hostname); + assertEquals(vnfListt.getIpAddress(), ipaddress); + assertEquals(vnfListt.getPortNo(), portnumber); + } +}
\ No newline at end of file diff --git a/SdncReports/SdncReportsApi/src/test/java/com/onap/sdnc/testapi/model/VnfTest.java b/SdncReports/SdncReportsApi/src/test/java/com/onap/sdnc/testapi/model/VnfTest.java new file mode 100644 index 00000000..0b7ac506 --- /dev/null +++ b/SdncReports/SdncReportsApi/src/test/java/com/onap/sdnc/testapi/model/VnfTest.java @@ -0,0 +1,61 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights + * reserved. + * ================================================================================ + * 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 com.onap.sdnc.testapi.model; + +import static org.junit.Assert.assertEquals; +import java.util.List; +import org.junit.Test; +import com.onap.sdnc.reports.model.Request; +import com.onap.sdnc.reports.model.ValidationTestType; +import com.onap.sdnc.reports.model.Vnf; +import com.onap.sdnc.reports.model.VnfList; + + +public class VnfTest { + + private String hostname = "host"; + private String ipaddress = "0.0.0.0"; + private ValidationTestType[] validationTestType; + + Request restReq = new Request(); + + @SuppressWarnings("deprecation") + @Test + public void TestVnf() { + + VnfList<List> vnfListt = new VnfList<List>(); + vnfListt.setHostName(hostname); + vnfListt.setIpAddress(ipaddress); + vnfListt.setPortNo(null); + + VnfList[] vnflist = restReq.getVnfList(); + Vnf testvnf = new Vnf(); + testvnf.setVnfList(vnflist); + testvnf.setValidationTestType(validationTestType); + + ValidationTestType[] validationTestTypee = restReq.getValidationTestType(); + testvnf.setValidationTestType(validationTestTypee); + + assertEquals(testvnf.getVnfList(), vnflist); + assertEquals(testvnf.getValidationTestType(), validationTestTypee); + } +}
\ No newline at end of file diff --git a/SdncReports/SdncReportsApi/src/test/resources/application.properties b/SdncReports/SdncReportsApi/src/test/resources/application.properties new file mode 100644 index 00000000..a17b6c9a --- /dev/null +++ b/SdncReports/SdncReportsApi/src/test/resources/application.properties @@ -0,0 +1,17 @@ +server.tomcat.uri-encoding=utf-8 + +# maria db details + +spring.datasource.url=jdbc:mariadb://localhost:3307/testreports +spring.datasource.username=root +spring.datasource.password=root +spring.datasource.driver-class-name=org.mariadb.jdbc.Driver +spring.jpa.database-platform=org.hibernate.dialect.MySQLDialect + + +spring.datasource.tomcat.max-wait=20000 +spring.datasource.tomcat.max-active=50 +spring.datasource.tomcat.max-idle=20 +spring.datasource.tomcat.min-idle=15 + +spring.jpa.show-sql=true |