# anhtester/restassuredtestng2023 architecture

> Architecture diagram of the GitHub repository anhtester/restassuredtestng2023, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/anhtester/restassuredtestng2023
- Repository: https://github.com/anhtester/restassuredtestng2023

## Overview

##### Main Components Identification
a. API Test Suite Layer:
- Test Scripts: All tests are located under src/test. They are organized in different directories (e.g., Bai3_SendRequest_GETmethod, Bai5_POSTmethod, Bai7_Authentication_PUTmethod, etc.), which can be seen as functional modules or experiment labs.
- Test Data & Configuration: The test resources directory contains configurations (configs.properties, demo.properties) and test data (JSON files) for driving data-driven tests.
- TestNG Suites: Located in the “suites” folder, these XML files (e.g., SuiteAllureReport.xml, SuiteDemoListener.xml) define which tests to run and how to organize parallel execution/annotation-driven runs.

b. Core Automation Framework:
- Global Configurations: Found in the “globals” package, these classes (ConfigsGlobal.java, EndPointGlobal.java, TokenGlobal.java) centralize URL endpoints, tokens, and configuration values.
- Helpers: Under the “helpers” package are classes like JsonHelper.java, PropertiesHelper.java, and SystemHelper.java. They manage tasks such as JSON handling, properties file reading, and system-level utilities.
- Keywords and Spec Builder: In the “keywords” package, classes such as ApiKeyword.java and SpecBuilder.java implement the keyword-driven components and API specification builder indicating a more modular approach to writing tests.
- Reporting and Logging: The “reports” package includes AllureManager.java for reporting, and utility classes in “utils” (e.g., LogUtils.java) are used for logging. Additionally, log4j2 configuration files in resources support logging.

c. Supporting Components:
- Listeners and Extensions: The “listeners” package in tests shows additional support for TestNG event handling.
- Data Models: The “model” package includes POJOs that represent request and response structures for API testing.

##### Relationships and Interactions
- TestNG acts as the test runner that executes test classes in src/test. Each test case interacts with the core components.
- The test scripts import and use helper methods, global configurations, and keywords to construct and send HTTP requests with REST Assured.
- Test results are logged using the LogUtils and then reported via the AllureManager integrated in the reporting system.
- Test data is retrieved from the resources directory (properties and JSON files), and these are fed into the tests (often using the helpers).
- The suites (XML files) tie together tests, listeners, and parallel execution settings that determine the overall test workflow.

##### Architectural Patterns and Design Principles
- Layered Architecture: There’s a clear layering—configuration and utility layer (globals, helpers), a business logic layer (keywords, spec builders), and an execution layer (test scripts).
- Keyword-Driven Approach: The keywords package implies that some test steps are abstracted into reusable components.
- Separation of Concerns: Configurations, data models, test code, and utility classes are clearly separated to make maintenance easier.

##### Relevant Technologies and Frameworks
- REST Assured: For building and executing API requests.
- TestNG: For test execution and parallel test management.
- Allure Reporting: For generating friendly and detailed test reports (via the AllureManager).
- Log4j2: For application logging.
- Java: As the primary programming language, with Maven (pom.xml) for project management.

##### Final Detailed Suggestions
- Sub-components within each section. For example, under “Framework Core”, list classes like ConfigsGlobal, EndPointGlobal, and TokenGlobal.
- Use of external libraries (REST Assured, TestNG, Allure, Log4j2) and point out their integrations.
- Detail the flow: configuration and test data are read first, tests are executed (invoked by TestNG), tests invoke helper and keyword classes to build API requests, log/monitor the interactions, and finally report results via Allure.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "RestAssuredTestNG2023 Framework"
        %% Test Execution Layer
        subgraph "Test Execution"
            TE1["TestNG Runner"]:::executionLayer
            TE2["TestNG Suites"]:::executionLayer
            TE3["Listeners"]:::executionLayer
        end

        %% API Test Scripts Layer
        subgraph "API Test Scripts"
            TS1["API Test Scripts"]:::testLayer
            TS2["Data Models"]:::testLayer
        end

        %% Framework Core Layer
        subgraph "Framework Core"
            FC1["Global Configurations"]:::coreLayer
            FC2["Helper Utilities"]:::coreLayer
            FC3["Keyword Engine"]:::coreLayer
            FC4["API Client (REST Assured)"]:::coreLayer
        end

        %% Data Management Layer
        subgraph "Data Management"
            DM1["Config Files"]:::dataLayer
            DM2["JSON Test Data"]:::dataLayer
        end

        %% Support Modules Layer
        subgraph "Support Modules"
            SM1["Reporting (Allure)"]:::supportLayer
            SM2["Logging (Log4j2)"]:::supportLayer
            SM3["Log4j2 Config"]:::supportLayer
        end

        %% Build & Dependency Layer
        subgraph "Build & Dependency"
            BD1["Maven (pom.xml)"]:::buildLayer
        end
        
        %% External Service
        ExternalAPI["API Under Test"]:::external
    end

    %% Relationships - Execution Flow
    TE2 -->|"configures"| TE1
    TE3 -->|"monitors"| TE1
    TE1 -->|"executes"| TS1

    %% Data Management supplying test data
    DM1 -->|"supplies"| TS1
    DM2 -->|"supplies"| TS1

    %% Test Scripts using Framework Core components and Data Models
    TS1 -->|"uses"| FC1
    TS1 -->|"uses"| FC2
    TS1 -->|"uses"| FC3
    TS1 -->|"uses"| FC4
    TS1 -->|"uses"| TS2

    %% API Client calls external API
    FC4 -->|"calls"| ExternalAPI

    %% Reporting and Logging feedback from Test Scripts
    TS1 -->|"reports"| SM1
    TS1 -->|"logs"| SM2

    %% Build & Dependency builds the components
    BD1 -->|"builds"| TE1
    BD1 -->|"builds"| TS1
    BD1 -->|"builds"| FC1
    BD1 -->|"builds"| FC2
    BD1 -->|"builds"| FC3
    BD1 -->|"builds"| FC4

    %% Click Events
    click TS1 "https://github.com/anhtester/restassuredtestng2023/tree/main/src/test/java/com/anhtester/"
    click DM1 "https://github.com/anhtester/restassuredtestng2023/tree/main/src/test/resources/config"
    click DM2 "https://github.com/anhtester/restassuredtestng2023/tree/main/src/test/resources/testdata"
    click TE2 "https://github.com/anhtester/restassuredtestng2023/tree/main/suites"
    click FC1 "https://github.com/anhtester/restassuredtestng2023/tree/main/src/main/java/com/anhtester/globals"
    click FC2 "https://github.com/anhtester/restassuredtestng2023/tree/main/src/main/java/com/anhtester/helpers"
    click FC3 "https://github.com/anhtester/restassuredtestng2023/tree/main/src/main/java/com/anhtester/keywords"
    click SM1 "https://github.com/anhtester/restassuredtestng2023/tree/main/src/main/java/com/anhtester/reports"
    click SM2 "https://github.com/anhtester/restassuredtestng2023/tree/main/src/main/java/com/anhtester/utils"
    click SM3 "https://github.com/anhtester/restassuredtestng2023/tree/main/src/main/resources/"
    click TE3 "https://github.com/anhtester/restassuredtestng2023/tree/main/src/test/java/com/anhtester/listeners"
    click TS2 "https://github.com/anhtester/restassuredtestng2023/tree/main/src/test/java/com/anhtester/model"

    %% Styles
    classDef testLayer fill:#b3ffb3,stroke:#008000,stroke-width:2px;
    classDef coreLayer fill:#b3cde0,stroke:#00509e,stroke-width:2px;
    classDef supportLayer fill:#f7d794,stroke:#d35400,stroke-width:2px;
    classDef dataLayer fill:#f9e79f,stroke:#f1c40f,stroke-width:2px;
    classDef executionLayer fill:#e6e6fa,stroke:#6a5acd,stroke-width:2px;
    classDef buildLayer fill:#dcdcdc,stroke:#808080,stroke-width:2px;
    classDef external fill:#eeeeee,stroke:#333,stroke-dasharray: 5 5,stroke-width:2px;
```
