GithubHelp home page GithubHelp logo

tooniez / restassured-maven-java Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 85 KB

๐Ÿ’จ Maven project using RestAssured and JUnit to chain OpenWeatherAPI for Air Quality testing

License: MIT License

Makefile 3.15% Java 96.85%
apitesting junit maven restassured climate hamcrest surefire surefire-plugin dotenv

restassured-maven-java's Introduction

RestAssured Maven Java Repo

ci runs

This is a Maven project that utilizes RestAssured and JUnit to evaluate how to achieve some tasks in ./.idea/notes.md

The final test script that demonstrates the tasks is in - ./src/test/java/TestAirQuality.java

Prerequisites

Before running this project, make sure you have the following installed:

  • Java Development Kit (JDK)
  • Apache Maven

Installation

  1. Clone this repository to your locally.
  2. Add Open Weather API key into .env
  3. Install/Test the project using the Makefile: make install.

Data Providers

The /src/test/java/providers/CityProvider.java returns a list of cities used.

    public static List<String> getCities() {
        return Arrays.asList("Melbourne", "Manchester");
    }

Endpoints

The /src/test/java/weather/Endpoints.java contains 2 endpoints used in this exercise. The Endpoints extends from Base.java where we store the base url domain and versioning.

    public static String getWeatherEndpoint(String city, String apiKey) {
        return "/weather?q=" + city + "&appid=" + apiKey;
    }

    public static String getAirPollutionEndpoint(double lat, double lon, String apiKey) {
        return "/air_pollution/forecast?lat=" + lat + "&lon=" + lon + "&appid=" + apiKey;
    }

Tests

Test config

A ./src/test/java/BaseTest.java class should be used to extend on all tests. Currently its configured to load api_key stored in .env file using a @BeforeClass decorator.

    protected static Dotenv dotenv;
    protected static String API_KEY;

Test Cases

The ./src/test/java/TestLatlon.java is a simple test script used to explore openweather api and see the shape of data it returns.

The ./src/test/java/TestAirQuality.java contains flow where it:

  1. Uses weatherEndpoint to get lat lon response for each city
  2. Uses airPollutionEndpoint to get air quality (agi) using lat lon
  3. Checks to see if the captured agi is greater or equal to the threshold we check for (2)
[INFO] Running TestAirQuality
Coordinates for Melbourne: 28.0836, -80.6081
AQI for Melbourne: 2
City with AQI 2 or above: Melbourne, AQI: 2
Coordinates for Manchester: 53.4809, -2.2374
AQI for Manchester: 1
City with AQI below 2: Manchester, AQI: 1
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 6.494 s -- in TestAirQuality

Test Reporting

The project is currently configured to use junit with the surefire plugin to save the xml report. Reports are stored under ./reports

A CI workflow is also configured in this project for reporting/triggers

restassured-maven-java's People

Contributors

dependabot[bot] avatar tooniez avatar

Watchers

 avatar  avatar

restassured-maven-java's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.