This repository contains code on performing basic SQL commands on a web table using Java 8 Lambda and Streams
The idea behind is to fetch the data from a webtable and perform operations (similar to hitting SQL Queries on a database) using Java Streams API. This can significantly help in reducing the LOC. It will also increase the efficiency
- Java 8 Stream APIs
- TestNG or Junit
- Selenium(Optional)
- Java version 8 or higher
- Maven version compatible to JRE 1.8
- IDE of your choice: IntelliJ, Eclipse, Netbeans
- Selenium WebDriver
- TestNG
- WebDriverManager (bonigarcia)
The code is self explanatory and contains the following packages:
- src/main/java object Contains an Object class to hold the data record,here (an Employee)
- src/test/java dbOperationsOnWebtable
Contains two test classes:
- Parent.java : Base Class for invoking selenium webdriver and performing the prerequisites and later terminating the browser session.
- WebTableOperations.java : Test Class which extends Parent and contains only tests that relate to some database operations
(If not from Selenium background, refer to point 6)
- Code execution begins with running the class WebTableOperations.java with the help of TestNG
- As being a superclass of WebTableOperations.java and following the TestNG annotation order, Parent.java class launchs the webdriver instance(headless) and selects the entry dropdown to be 100 entries per page.(This is done to display the whole table data in a single page, #NoPagination)
- The WebTableOperations.java contains @Test annotations which in turn generates the results.
- @AfterTest under Parent class terminates the driver session.
- To run the code, run any of the @Test annotation from WebTableOperations.java and the results will be displayed right in the console window.
- This project contains a table to operate upon. The data values are stored in an ArrayList Object(say Employee). You can go through the code written in the @Test annotation of the class WebTableOperations.java, continue further with step 4.
- This is just a boilerplate code to help you get familiar with the best possible use case of Lambda and Streams.
- The code complexity might stretch from Big Omega(Ω) to Big(O). See here
- TestNG annotations are used just for running the individual tests rather than performing any assertions, Verification can be done manually after getting the results.
- Queries? Feel free to discuss in the Issues section: https://github.com/pcm708/Java_DBOperationsUsingLambdaAndStreams/issues