Evento Framework
  • Introduction
  • Architecture Overview
    • Distributed Systems & Microservices
    • Recative Manifesto & Reactive Principles
    • State-of-the-art Patterns
      • DDD (Domain Driven Design)
      • CQRS (Command Query Responsability Separation)
      • Event Sourcing
      • Messaging
      • Saga
  • GETTING STARTED
    • Quick Start
    • TodoList - RECQ Tutorial
      • Problem Description and Requirement Gathering
      • RECQ Payload Design
      • RECQ Components Design
      • Set up your Development Environment
      • RECQ Payload Evento Implementation
        • Domain Commands
        • Domain Events
        • Views
        • Queries
      • RECQ Components Evento Implementation with Spring Data
        • TodoListAggregate
        • TodoList Model with Spring Data
        • TodoListProjector
        • TodoListProjection
        • TodoList Invoker
      • Expose the RECQ architecture with Spring Web
      • Test Your App
    • Extend TodoList - Handle Complexity Tutorial
      • Unique identifier generation
      • Extends behaviors with Observer and Services
      • Cross Domain Consistency with Sagas
      • Handle Real time data updates with MQTT and Save-Notify Pattern
  • RECQ Patterns
    • RECQ Patterns
    • RECQ System Pattern
      • Component
      • Message Gateway
      • System State Store
    • RECQ Communication Pattern
      • Component to Component
      • Component to System State Store
      • System State Store to Component
    • RECQ Component Pattern
      • Aggregate
      • Projector
      • Projection
      • Service
      • Invoker
      • Saga
      • Observer
  • Evento Framework
    • Evento Framework Introcution
    • Payload and Messages
      • Command
        • Domain Command
        • Service Command
      • Event
        • Domain and Service Event
      • Query and View
    • @Component
      • @Aggregate
        • Aggregate State
        • @AggregateCommandHandler
        • @EventSourcingHandler
      • @Projector
        • Projector @EventHandler
      • @Projection
        • @QueryHandler
      • @Service
        • @CommandHandler
      • @Invoker
      • @Saga
        • SagaState
        • @SagaEventHandler
      • @Observer
    • Dead Event Queues
    • EventoBundle
      • EventoServerMessageBusConfiguration
      • ConsumerStateStore
        • InMemoryConsumerStateStore
        • PostgresConsumerStateStore
        • MysqlConsumerStateStore
      • Context
      • TracingAgend and @Track
        • SentryTracingAgent
      • Autoscaling Protocol
        • ThreadCountAutoscalingProtocol
      • Injector and @Component
  • Evento Server
    • Evento Server Introduction
    • SetUp Evento Server
      • Advanced Options
      • Evento Event Store Modes: APES and CPES
    • Evento Server Cluster
    • Bundle Deploy Script
  • EVENTO GUI
    • Explore RECQ Systems Visually
    • GUI Auth
    • Payload Catalog
    • Component Catalog
    • Bundle Catalog
    • Cluster Status (Experimental)
    • Flows
      • Performance Evaluation
    • Application Graph
    • System State Store
  • Evento CLI
    • Evento CLI Introduction
    • Update Version
    • Publish
Powered by GitBook
On this page
  1. GETTING STARTED
  2. TodoList - RECQ Tutorial

Test Your App

Testing the TodoList App with Evento and Spring Frameworks

This chapter dives into how to test the TodoList application built using the Evento Framework and Spring Framework. We'll explore writing automated tests to ensure the functionality of your application.

Tools and Technologies

  • Testing Framework: We'll assume you're using a popular testing framework like RestAssured or Spring Boot Test.

  • Evento Framework: This framework provides functionalities for building APIs.

  • Spring Framework: This framework provides dependency injection and other features for building robust applications.

Testing Approach

Our testing strategy focuses on API endpoints related to TodoList management. We'll follow a pattern of:

  1. Sending a request: Simulate an HTTP request (like POST, GET, PUT, or DELETE) with specific headers and body content.

  2. Verifying the response: Assert the expected HTTP status code and potentially validate the response body.

  3. Storing information: Capture relevant information from the response body for use in subsequent tests.

Sample Tests

Here are some examples showcasing how to test different functionalities of the TodoList application:

1. Creating a TodoList:

// Assuming RestAssured is used for testing

// Prepare the request body
String todoListName = "Sample Todo List";
String requestBody = "{\"name\":\"" + todoListName + "\"}";

// Send the request and capture the response
Response response = RestAssured.given()
    .auth().oauth2("user1")
    .header("Content-Type", "application/json")
    .body(requestBody)
.post("http://localhost:8080/todo-list/");

// Verify response status and store ID
response.then().assertThat().statusCode(201);
String todoListId = response.getBody().jsonPath().getString("identifier");

// Store the ID for later use
client.global.set("lastId", todoListId);

2. Creating a Todo Item:

// Assuming you have a stored lastId from previous test

String todoContent = "Simple Todo";
String requestBody = "{\"content\":\"" + todoContent + "\"}";

response = RestAssured.given()
    .auth().oauth2("user1")
    .header("Content-Type", "application/json")
    .body(requestBody)
.post("http://localhost:8080/todo-list/" + client.global.get("lastId") + "/todo/");

response.then().assertThat().statusCode(201);
String todoItemId = response.getBody().jsonPath().getString("identifier");
client.global.set("lastTodoId", todoItemId);

3. Getting a TodoLists

// Assuming you have a stored lastId

response = RestAssured.given()
    .auth().oauth2("user1")
.get("http://localhost:8080/todo-list/" + client.global.get("lastId"));

response.then().assertThat().statusCode(200);
// Assert the retrieved todo list contains the created todo item
// ... (using response.body)

4. Deleting a Todo Item:

// Assuming you have stored lastId and lastTodoId

response = RestAssured.given()
    .auth().oauth2("user1")
.delete("http://localhost:8080/todo-list/" + client.global.get("lastId") + "/todo/" + client.global.get("lastTodoId"));

response.then().assertThat().statusCode(204); // No Content expected

5. Additional Considerations:

  • You can write tests for PUT requests to update existing to-do items.

  • Implement negative test scenarios (e.g., unauthorized access, invalid data).

  • Consider using data providers to create different test cases with varied input data.

Remember:

  • Replace "user1" with the appropriate authentication token for your application.

  • Adapt the assertions (... (using response.body)) in step 3 to validate the specific response structure of your TodoList object.

PreviousExpose the RECQ architecture with Spring WebNextExtend TodoList - Handle Complexity Tutorial

Last updated 1 year ago