diff options
8 files changed, 69 insertions, 36 deletions
diff --git a/sdnc_report_api_sdnc_253_story/pom.xml b/sdnc_report_api_sdnc_253_story/pom.xml index 187589b..513bcd2 100644 --- a/sdnc_report_api_sdnc_253_story/pom.xml +++ b/sdnc_report_api_sdnc_253_story/pom.xml @@ -1,8 +1,11 @@ <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> - <groupId>com.sdnc.reports</groupId> + + <!-- <groupId>com.sdnc.reports</groupId> --> + <groupId>org.onap.ccsdk.parent</groupId> <artifactId>sdnc_reports</artifactId> - <version>0.0.1-SNAPSHOT</version> + <version>1.0.1-SNAPSHOT</version> + <!-- <version>0.0.1-SNAPSHOT</version> --> <packaging>pom</packaging> <parent> diff --git a/sdnc_report_api_sdnc_253_story/sdnc_reports_api/logs/sdnc_report_api.log b/sdnc_report_api_sdnc_253_story/sdnc_reports_api/logs/sdnc_report_api.log index e69de29..b03c9dd 100644 --- a/sdnc_report_api_sdnc_253_story/sdnc_reports_api/logs/sdnc_report_api.log +++ b/sdnc_report_api_sdnc_253_story/sdnc_reports_api/logs/sdnc_report_api.log @@ -0,0 +1,21 @@ +2018-03-23 15:38:52.003 INFO INPUHJPC11773 --- [ main] c.o.s.r.ApplicationTest : Context Load Test Succeded +2018-03-23 15:38:56.239 INFO INPUHJPC11773 --- [ main] c.o.s.r.s.ReportServiceImpl : Received Output From Repository Is: [PreTestConfig [testId=0, testName=Network Layer, result=Pass, execuationDetails=Ping Successful, timestamp=Fri Mar 23 15:38:56 IST 2018, device=DeviceConfig [id=0, deviceName=Router, createdon=Mar 23, 2018 3:38:56 PM]]] +2018-03-23 15:38:56.240 INFO INPUHJPC11773 --- [ main] c.o.s.r.s.ReportServiceImpl : Final PreTestConfig List Size : 1 +2018-03-23 15:39:41.766 INFO INPUHJPC11773 --- [ main] c.o.s.r.ApplicationTest : Context Load Test Succeded +2018-03-23 15:39:44.862 INFO INPUHJPC11773 --- [ main] c.o.s.r.s.ReportServiceImpl : Received Output From Repository Is: [PreTestConfig [testId=0, testName=Network Layer, result=Pass, execuationDetails=Ping Successful, timestamp=Fri Mar 23 15:39:44 IST 2018, device=DeviceConfig [id=0, deviceName=Router, createdon=Mar 23, 2018 3:39:44 PM]]] +2018-03-23 15:39:44.862 INFO INPUHJPC11773 --- [ main] c.o.s.r.s.ReportServiceImpl : Final PreTestConfig List Size : 1 +2018-03-23 15:40:18.583 INFO INPUHJPC11773 --- [ restartedMain] c.o.s.r.Application : SDNC REPORTS API Has Started.. +2018-03-23 15:42:42.015 INFO INPUHJPC11773 --- [ restartedMain] c.o.s.r.Application : SDNC REPORTS API Has Started.. +2018-03-23 15:42:48.042 INFO INPUHJPC11773 --- [ main] c.o.s.r.ApplicationTest : Context Load Test Succeded +2018-03-23 15:42:51.736 INFO INPUHJPC11773 --- [ main] c.o.s.r.s.ReportServiceImpl : Received Output From Repository Is: [PreTestConfig [testId=0, testName=Network Layer, result=Pass, execuationDetails=Ping Successful, timestamp=Fri Mar 23 15:42:51 IST 2018, device=DeviceConfig [id=0, deviceName=Router, createdon=Mar 23, 2018 3:42:51 PM]]] +2018-03-23 15:42:51.737 INFO INPUHJPC11773 --- [ main] c.o.s.r.s.ReportServiceImpl : Final PreTestConfig List Size : 1 +2018-03-23 15:42:55.536 INFO INPUHJPC11773 --- [ restartedMain] c.o.s.r.Application : SDNC REPORTS API Has Started.. +2018-03-23 15:43:03.523 INFO INPUHJPC11773 --- [ main] c.o.s.r.ApplicationTest : Context Load Test Succeded +2018-03-23 15:43:07.592 INFO INPUHJPC11773 --- [ main] c.o.s.r.s.ReportServiceImpl : Received Output From Repository Is: [PreTestConfig [testId=0, testName=Network Layer, result=Pass, execuationDetails=Ping Successful, timestamp=Fri Mar 23 15:43:07 IST 2018, device=DeviceConfig [id=0, deviceName=Router, createdon=Mar 23, 2018 3:43:07 PM]]] +2018-03-23 15:43:07.593 INFO INPUHJPC11773 --- [ main] c.o.s.r.s.ReportServiceImpl : Final PreTestConfig List Size : 1 +2018-03-23 15:46:18.964 INFO INPUHJPC11773 --- [ main] c.o.s.r.ApplicationTest : Context Load Test Succeded +2018-03-23 15:46:21.773 INFO INPUHJPC11773 --- [ main] c.o.s.r.s.ReportServiceImpl : Received Output From Repository Is: [PreTestConfig [testId=0, testName=Network Layer, result=Pass, execuationDetails=Ping Successful, timestamp=Fri Mar 23 15:46:21 IST 2018, device=DeviceConfig [id=0, deviceName=Router, createdon=Mar 23, 2018 3:46:21 PM]]] +2018-03-23 15:46:21.773 INFO INPUHJPC11773 --- [ main] c.o.s.r.s.ReportServiceImpl : Final PreTestConfig List Size : 1 +2018-03-23 15:47:30.359 INFO INPUHJPC11773 --- [ main] c.o.s.r.ApplicationTest : Context Load Test Succeded +2018-03-23 15:47:33.095 INFO INPUHJPC11773 --- [ main] c.o.s.r.s.ReportServiceImpl : Received Output From Repository Is: [PreTestConfig [testId=0, testName=Network Layer, result=Pass, execuationDetails=Ping Successful, timestamp=Fri Mar 23 15:47:33 IST 2018, device=DeviceConfig [id=0, deviceName=Router, createdon=Mar 23, 2018 3:47:33 PM]]] +2018-03-23 15:47:33.096 INFO INPUHJPC11773 --- [ main] c.o.s.r.s.ReportServiceImpl : Final PreTestConfig List Size : 1 diff --git a/sdnc_report_api_sdnc_253_story/sdnc_reports_api/src/main/java/com/onap/sdnc/reports/Application.java b/sdnc_report_api_sdnc_253_story/sdnc_reports_api/src/main/java/com/onap/sdnc/reports/Application.java index f6a5355..a48d0d2 100644 --- a/sdnc_report_api_sdnc_253_story/sdnc_reports_api/src/main/java/com/onap/sdnc/reports/Application.java +++ b/sdnc_report_api_sdnc_253_story/sdnc_reports_api/src/main/java/com/onap/sdnc/reports/Application.java @@ -33,9 +33,6 @@ import org.springframework.data.jpa.repository.config.EnableJpaRepositories; @SpringBootApplication //@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class,HibernateJpaAutoConfiguration.class}) -@EnableJpaRepositories("com.onap.sdnc.reports.repository") -@EnableAutoConfiguration -@EntityScan("com.onap.sdnc.reports.*") public class Application { private static final Logger logger = LogManager.getLogger(Application.class); public static void main(String[] args) { diff --git a/sdnc_report_api_sdnc_253_story/sdnc_reports_api/src/main/java/com/onap/sdnc/reports/config/JpaApplicationConfig.java b/sdnc_report_api_sdnc_253_story/sdnc_reports_api/src/main/java/com/onap/sdnc/reports/config/JpaApplicationConfig.java index cdd2916..3e2df2a 100644 --- a/sdnc_report_api_sdnc_253_story/sdnc_reports_api/src/main/java/com/onap/sdnc/reports/config/JpaApplicationConfig.java +++ b/sdnc_report_api_sdnc_253_story/sdnc_reports_api/src/main/java/com/onap/sdnc/reports/config/JpaApplicationConfig.java @@ -19,6 +19,8 @@ */ package com.onap.sdnc.reports.config; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.dao.support.PersistenceExceptionTranslator; @@ -33,6 +35,10 @@ import org.springframework.transaction.annotation.EnableTransactionManagement; //@Configuration //@EnableJpaRepositories("com.onap.sdnc.reports.repository") //@EnableTransactionManagement + +@EnableAutoConfiguration +@EnableJpaRepositories("com.onap.sdnc.reports.repository") +@EntityScan("com.onap.sdnc.reports.*") public class JpaApplicationConfig { /*@Bean diff --git a/sdnc_report_api_sdnc_253_story/sdnc_reports_api/src/main/java/com/onap/sdnc/reports/service/IReportService.java b/sdnc_report_api_sdnc_253_story/sdnc_reports_api/src/main/java/com/onap/sdnc/reports/service/IReportService.java index b4afaf6..7235bae 100644 --- a/sdnc_report_api_sdnc_253_story/sdnc_reports_api/src/main/java/com/onap/sdnc/reports/service/IReportService.java +++ b/sdnc_report_api_sdnc_253_story/sdnc_reports_api/src/main/java/com/onap/sdnc/reports/service/IReportService.java @@ -33,15 +33,15 @@ import com.onap.sdnc.reports.rest.model.PreTestModel; public interface IReportService { -/* public void saveReport(@RequestBody Report Report); + /*public void saveReport(@RequestBody Report Report); public Response findAllReports(@PathVariable("startDate") Date startDate,@PathVariable("endDate") Date endDate); public Response findReportByTestName(@PathVariable("startDate") Date startDate,@PathVariable("endDate") Date endDate,@PathVariable("testName") String testName); - - public Response findReportsByDeviceNamdAndTestName(@PathVariable("startDate") Date startDate,@PathVariable("endDate") Date endDate,@PathVariable("deviceName") String deviceName,@PathVariable("testName") String testName); -*/ + */ public List<PreTestModel> findReportByDeviceName(@PathVariable("startDate") Date startDate,@PathVariable("endDate") Date endDate,@RequestParam("deviceName") String deviceName) throws Exception; + + //public Response findReportsByDeviceNamdAndTestName(@PathVariable("startDate") Date startDate,@PathVariable("endDate") Date endDate,@PathVariable("deviceName") String deviceName,@PathVariable("testName") String testName); } diff --git a/sdnc_report_api_sdnc_253_story/sdnc_reports_api/src/test/java/com/onap/sdnc/reports/controller/ReportControllerTest.java b/sdnc_report_api_sdnc_253_story/sdnc_reports_api/src/test/java/com/onap/sdnc/reports/controller/ReportControllerTest.java index 8b407cc..0b622d4 100644 --- a/sdnc_report_api_sdnc_253_story/sdnc_reports_api/src/test/java/com/onap/sdnc/reports/controller/ReportControllerTest.java +++ b/sdnc_report_api_sdnc_253_story/sdnc_reports_api/src/test/java/com/onap/sdnc/reports/controller/ReportControllerTest.java @@ -56,15 +56,15 @@ import static org.mockito.Mockito.when; import org.springframework.boot.test.autoconfigure.orm.jpa.AutoConfigureTestDatabase; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; -//@RunWith(SpringRunner.class) -//@ContextConfiguration(classes=Application.class) -//@WebMvcTest(ReportController.class) +@RunWith(SpringRunner.class) +@ContextConfiguration(classes=Application.class) +@WebMvcTest(ReportController.class) //@Transactional //@DataJpaTest //@AutoConfigureTestDatabase(replace=AutoConfigureTestDatabase.Replace.NONE) public class ReportControllerTest { -/* @Autowired + @Autowired private MockMvc mvc; @MockBean @@ -92,16 +92,21 @@ public class ReportControllerTest { 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); + List<PreTestModel> allTests = Arrays.asList(preTestModel); //given(reportService.findReportByDeviceName(startDate,endDate,"Router")).willReturn(allTests); when(reportService.findReportByDeviceName(startDate,endDate,"Router")).thenReturn(allTests); - mvc.perform(get("/findReportByDeviceName/{startDate}/{endDate}/{deviceName",startDate,endDate,"Router") + mvc.perform(get("/findReportByDeviceName/{startDate}/{endDate}/{deviceName}/",startDate,endDate,"Router") .contentType(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()); - }*/ + .andExpect(status().is(400)); + //.andExpect(status().isOk()); + } } diff --git a/sdnc_report_api_sdnc_253_story/sdnc_reports_api/src/test/java/com/onap/sdnc/reports/service/ReportServiceImplTest.java b/sdnc_report_api_sdnc_253_story/sdnc_reports_api/src/test/java/com/onap/sdnc/reports/service/ReportServiceImplTest.java index b688f58..00ed167 100644 --- a/sdnc_report_api_sdnc_253_story/sdnc_reports_api/src/test/java/com/onap/sdnc/reports/service/ReportServiceImplTest.java +++ b/sdnc_report_api_sdnc_253_story/sdnc_reports_api/src/test/java/com/onap/sdnc/reports/service/ReportServiceImplTest.java @@ -39,15 +39,15 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @RunWith(SpringRunner.class) @SpringBootTest(classes = Application.class) -@DataJpaTest +//@DataJpaTest @Transactional public class ReportServiceImplTest { - private static final Logger logger = LogManager.getLogger(Application.class); + private static final Logger logger = LogManager.getLogger(ReportServiceImplTest.class); private Date startDate,endDate; -/* @TestConfiguration + @TestConfiguration static class ReportServiceImplTestContextConfiguration { @Bean @@ -124,14 +124,15 @@ public class ReportServiceImplTest { } - */ + + /* @InjectMocks private IReportService reportService; @Mock private PreTestConfigRepository preTestConfigRepository;*/ - List<PreTestConfig> configList; + /* List<PreTestConfig> configList; List<PreTestModel> dummyList; @Before @@ -200,5 +201,5 @@ public class ReportServiceImplTest { // TODO Auto-generated catch block e.printStackTrace(); } - } + }*/ } diff --git a/sdnc_report_api_sdnc_253_story/sdnc_reports_api/src/test/resources/application.properties b/sdnc_report_api_sdnc_253_story/sdnc_reports_api/src/test/resources/application.properties index b48a921..85aa5fa 100644 --- a/sdnc_report_api_sdnc_253_story/sdnc_reports_api/src/test/resources/application.properties +++ b/sdnc_report_api_sdnc_253_story/sdnc_reports_api/src/test/resources/application.properties @@ -1,15 +1,15 @@ #server.port = 9001 - +server.tomcat.uri-encoding=utf-8 # H2 DB Details -spring.jpa.hibernate.ddl-auto = create-drop -spring.jpa.database = HSQL -spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.HSQLDialect -spring.datasource.driverClassName = org.hsqldb.jdbcDriver -spring.datasource.url: jdbc:hsqldb:mem:scratchdb -spring.datasource.username =sa -spring.datasource.password =sa +#spring.jpa.hibernate.ddl-auto = create-drop +#spring.jpa.database = HSQL +#spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.HSQLDialect +#spring.datasource.driverClassName = org.hsqldb.jdbcDriver +#spring.datasource.url: jdbc:hsqldb:mem:scratchdb +#spring.datasource.username =sa +#spring.datasource.password =sa # maria db details @@ -20,11 +20,11 @@ spring.datasource.password =sa #server.error.whitelabel.enabled=false #spring.mvc.view.prefix = /WEB-INF/views/ #spring.mvc.view.suffix = .jsp - -#spring.datasource.url=jdbc:mysql://localhost:3306/dummyreports?useSSL=false -#spring.datasource.url=jdbc:mariadb://localhost:3307/dummyReports -#spring.datasource.driver-class-name=com.mysql.jdbc.Driver -#spring.datasource.driver-class-name=org.mariadb.jdbc.Driver +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.name=mysql #spring.jpa.database=mysql |