# abu-sithik/rest_assured-automation-framework architecture

> Architecture diagram of the GitHub repository abu-sithik/rest_assured-automation-framework, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/abu-sithik/rest_assured-automation-framework
- Repository: https://github.com/abu-sithik/rest_assured-automation-framework

## Overview

##### Project type and purpose
- This is an open-source Java/Maven API testing automation framework.
- It leverages RestAssured for HTTP calls, TestNG for test orchestration, and ExtentReports for reporting.

##### Core components
a. Configuration & Resources
- constants.properties (base URL, DB/SSH creds)
- TestNG.xml (test suite definitions)
- pom.xml (dependencies: RestAssured, TestNG, ExtentReports)
b. Utilities Layer
- DBConnection (singleton, MySQL)
- SshConnectionManager / Helper (SSH sessions, remote commands, CSV/JSON helpers)
c. Base API Entities
- One class per endpoint in com.restfulbooker.apitest.baseAPI (e.g., Auth.java)
- Each defines path, headers, body, HTTP method
d. Action & Interface Layer
- HttpOperation & ValidatorOperation (enums for CRUD and assertion types)
- IApi interface (blueprint for API operations)
- API.java (implements IApi, wraps RestAssured core calls)
e. TestNG Orchestration
- Test classes in src/test/java (e.g., LoginTest)
- TestNG runner invokes tests, passes Method references for dynamic reporting
f. Listeners & Reporting
- AnnotationTransformer, Retry, TestStatusListener (hook into TestNG events)
- ExtentManager & ExtentTestManager (manage ExtentReports lifecycle and thread-safe tests)
- ExtentReportResults.html (output)
g. External Systems
- Target RESTful service (e.g., restful-booker API)
- MySQL database (if DBConnection is used)
- SSH servers (if remote setup via SSH)

##### Relationships and data flows
- TestNG Runner triggers a Test case → Test class calls BaseAPI class → BaseAPI uses API.java (RestAssured) with HttpOperation to make HTTP request → Response flows back to API, passed to ValidatorOperation for assertions.
- During the test execution TestNG listeners intercept events (onStart, onTestSuccess, onTestFailure) → Hand off to ExtentManager / ExtentTestManager → Write entries into ExtentReports HTML.
- Utilities (DBConnection, SSH) may be invoked from tests or framework hooks (e.g., to set up data).
- Configuration properties feed into BaseAPI initialization and Utilities.

##### Architectural patterns & principles
- Layered architecture: Utilities → Core API library → Actions & Interfaces → Tests → Reports.
- Interface-implementation segregation: IApi defines contract, API.java delivers implementation.
- Singleton pattern: DBConnection ensures single DB connection.
- Enum-based operation definitions: HttpOperation / ValidatorOperation centralize constants.
- Observer/Listener pattern: TestNG listeners observe test events and report accordingly.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Configuration & Resources
    subgraph "Configuration & Resources"
        direction TB
        Constants["Constants.properties"]:::config
        TestNGXML["TestNG.xml"]:::config
        POM["pom.xml"]:::config
    end

    %% Utilities Layer
    subgraph "Utilities" 
        direction TB
        DBConn["DBConnection"]:::utilities
        SSHMgr["SshConnectionManager"]:::utilities
        Helper["Helper"]:::utilities
    end

    %% Framework Core
    subgraph "Framework Core"
        direction TB
        subgraph "Base API Entities"
            Auth["Auth.java – endpoint definition"]:::core
        end
        subgraph "Action & Interface"
            HttpOp["HttpOperation.java"]:::core
            ValOp["ValidatorOperation.java"]:::core
            IApi["IApi.java"]:::core
            APIWrapper["API.java – RestAssured wrapper"]:::core
            RestAssured["RestAssured Engine"]:::core
        end
    end

    %% Test Execution
    subgraph "Test Execution"
        direction TB
        TestNGRunner["TestNG Runner"]:::test
        LoginTest["LoginTest.java"]:::test
    end

    %% Reporting & Listeners
    subgraph "Reporting & Listeners"
        direction TB
        AnnotTrans["AnnotationTransformer"]:::report
        RetryLogic["Retry"]:::report
        TestStatus["TestStatusListener"]:::report
        ExtentBase["ExtentBase.java"]:::report
        ExtentMgr["ExtentManager.java"]:::report
        ExtentTestMgr["ExtentTestManager.java"]:::report
        ExtentReport["ExtentReportResults.html"]:::report
        ExtentConfig["extent-config.xml"]:::report
    end

    %% External Systems
    subgraph "External Systems"
        direction TB
        RESTService["RESTful-service"]:::external
        MySQL["MySQL Database"]:::external
        SSHServer["SSH Server"]:::external
    end

    %% Connections
    TestNGRunner -->|"1 start tests"| LoginTest
    LoginTest -->|"setup data"| DBConn
    LoginTest -->|"setup remote"| SSHMgr
    LoginTest -->|"2 call endpoint"| Auth
    Auth -->|"3 use API"| APIWrapper
    APIWrapper -->|"calls"| RestAssured
    RestAssured -->|"HTTP Request"| RESTService
    RESTService -->|"HTTP Response"| RestAssured
    RestAssured -->|"4 validate"| ValOp
    ValOp -->|"assert results"| LoginTest
    TestNGRunner -->|"events"| TestStatus
    TestStatus -->|"use transformer"| AnnotTrans
    TestStatus -->|"retry logic"| RetryLogic
    TestStatus -->|"5 report update"| ExtentMgr
    ExtentMgr --> ExtentTestMgr
    ExtentTestMgr --> ExtentReport
    ExtentConfig --> ExtentReport

    %% Configuration feeding
    Constants --> Auth
    Constants --> DBConn
    Constants --> SSHMgr
    Constants --> APIWrapper
    TestNGXML --> TestNGRunner
    POM --> APIWrapper
    POM --> LoginTest

    %% Utilities to external
    DBConn --> MySQL
    SSHMgr --> SSHServer

    %% Click Events
    click Constants "https://github.com/abu-sithik/rest_assured-automation-framework/blob/master/src/main/resources/Constants.properties"
    click TestNGXML "https://github.com/abu-sithik/rest_assured-automation-framework/blob/master/src/main/resources/TestNG.xml"
    click POM "https://github.com/abu-sithik/rest_assured-automation-framework/blob/master/pom.xml"
    click DBConn "https://github.com/abu-sithik/rest_assured-automation-framework/blob/master/src/main/java/com/restfulbooker/apitest/utilities/DBConnection.java"
    click SSHMgr "https://github.com/abu-sithik/rest_assured-automation-framework/blob/master/src/main/java/com/restfulbooker/apitest/utilities/SshConnectionManager.java"
    click Helper "https://github.com/abu-sithik/rest_assured-automation-framework/blob/master/src/main/java/com/restfulbooker/apitest/utilities/Helper.java"
    click Auth "https://github.com/abu-sithik/rest_assured-automation-framework/blob/master/src/main/java/com/restfulbooker/apitest/baseAPI/Auth.java"
    click HttpOp "https://github.com/abu-sithik/rest_assured-automation-framework/blob/master/src/main/java/com/restfulbooker/apitest/actions/HttpOperation.java"
    click ValOp "https://github.com/abu-sithik/rest_assured-automation-framework/blob/master/src/main/java/com/restfulbooker/apitest/actions/ValidatorOperation.java"
    click IApi "https://github.com/abu-sithik/rest_assured-automation-framework/blob/master/src/main/java/com/restfulbooker/apitest/interfaces/IApi.java"
    click APIWrapper "https://github.com/abu-sithik/rest_assured-automation-framework/blob/master/src/main/java/com/restfulbooker/apitest/restassuredFuntions/API.java"
    click LoginTest "https://github.com/abu-sithik/rest_assured-automation-framework/blob/master/src/test/java/com/restfulbooker/apitest/businessLogics/LoginTest.java"
    click AnnotTrans "https://github.com/abu-sithik/rest_assured-automation-framework/blob/master/src/main/java/com/restfulbooker/apitest/listeners/AnnotationTransformer.java"
    click RetryLogic "https://github.com/abu-sithik/rest_assured-automation-framework/blob/master/src/main/java/com/restfulbooker/apitest/listeners/Retry.java"
    click TestStatus "https://github.com/abu-sithik/rest_assured-automation-framework/blob/master/src/main/java/com/restfulbooker/apitest/listeners/TestStatusListener.java"
    click ExtentBase "https://github.com/abu-sithik/rest_assured-automation-framework/blob/master/src/main/java/com/restfulbooker/apitest/listeners/ExtentBase.java"
    click ExtentMgr "https://github.com/abu-sithik/rest_assured-automation-framework/blob/master/src/main/java/com/restfulbooker/apitest/listeners/ExtentManager.java"
    click ExtentTestMgr "https://github.com/abu-sithik/rest_assured-automation-framework/blob/master/src/main/java/com/restfulbooker/apitest/listeners/ExtentTestManager.java"

    %% Styles
    classDef config fill:#cccccc,stroke:#333,stroke-width:1px
    classDef utilities fill:#f9e79f,stroke:#333,stroke-width:1px
    classDef core fill:#82e0aa,stroke:#333,stroke-width:1px
    classDef test fill:#85c1e9,stroke:#333,stroke-width:1px
    classDef report fill:#f5b041,stroke:#333,stroke-width:1px
    classDef external fill:#aed6f1,stroke:#333,stroke-width:1px
```
