Skip to content

feat(embabel): Phase 5 β€” TestingΒ #316

@jwijgerd

Description

@jwijgerd

Phase 5: Testing

Replaces: #309 (please close that issue)
Incorporates changes from: PR #303

Tracking issue: #311
Module: main/agentic
Can start: After Phase 4 (#315) is merged

πŸ“‹ Plan reference: Phase 5: Testing (lines 679–843)


Overview

Comprehensive unit and integration testing of the full Embabel AgentPlatform integration. Tests are now split by phase: Phase 2 unit tests (Actions, Goals, Conditions with mocked Blackboard), Phase 1 wiring tests (annotation registration, factory injection), test fixtures, and Phase 4 integration tests (full agent loop with Kafka).


Tasks

5.1 Unit Tests (Phase 2 β€” Actions, Goals, Conditions)

Phase 2 components are tested at the unit level only β€” no Kafka, no Spring Boot context, no integration test infrastructure. These tests verify the individual building blocks in isolation using mocked Blackboard contexts.

Test Class What to Verify
AkcesAgentComponentTest All Actions, Goals, and Conditions are correctly annotated and discoverable
StoreMemoryActionTest Produces valid MemoryStoredEvent from blackboard context
ForgetMemoryActionTest Produces valid MemoryRevokedEvent from blackboard context
RecallMemoriesActionTest Correctly filters memories by subject/keyword
AgentProcessResultTranslatorTest Correctly extracts events and commands from blackboard

5.2 Unit Tests (Phase 1, Annotation Extensions)

These unit tests verify the wiring and registration of agent-specific metadata.

Test Class What to Verify
AgentPlatformInjectionTest Verifies AgentPlatform is correctly wired through factory β†’ runtime; verifies fatal error when absent
AgentProducedErrorsRegistrationTest Verifies agentProducedErrors are registered as DomainEventType(error=true)
AgentHandledCommandsRegistrationTest Verifies agentHandledCommands create CommandType entries with AgenticCommandHandlerFunctionAdapter
AgentHandledEventsRegistrationTest Verifies agentHandledEvents create external DomainEventType entries with AgenticEventHandlerFunctionAdapter
DiscoverAggregateServicesActionTest Verifies AggregateServiceRecords are correctly exposed on the blackboard

5.3 Test Agent Implementation: TestTradingAdvisorAgent

Package: org.elasticsoftware.akces.agentic.testfixtures

Test Aggregate

  • TestTradingAdvisorAggregate β€” @AgenticAggregateInfo with agentHandledCommands, agentHandledEvents, agentProducedErrors
  • Deterministic creation via @CommandHandler (TestCreateTradingAdvisorCommand β†’ TestTradingAdvisorCreatedEvent)
  • Agent-handled: TestAnalyzeMarketCommand, TestMarketDataUpdatedEvent
  • Agent-produced error: TestMarketUnavailableErrorEvent

Test State

  • TestTradingAdvisorState β€” implements AggregateState + MemoryAwareState
  • Fields: id, memories, analyses
  • Implements withMemory() and withoutMemory()

Test Commands and Events

Type Class Notes
Command TestCreateTradingAdvisorCommand Deterministic creation, has @CommandHandler
Command TestAnalyzeMarketCommand Agent-handled, in agentHandledCommands
Event TestTradingAdvisorCreatedEvent From deterministic @CommandHandler
Event TestMarketAnalysisCompletedEvent Produced by agent, has @EventSourcingHandler
Event (external) TestMarketDataUpdatedEvent Agent-handled, in agentHandledEvents
ErrorEvent TestMarketUnavailableErrorEvent Agent-produced, in agentProducedErrors

Test Embabel Agent Component

  • TestTradingAdvisorAgentComponent β€” @EmbabelComponent with test actions:
    • analyzeMarket() β€” deterministic logic (no LLM), @AchievesGoal("ProcessCommand")
    • reactToMarketData() β€” @AchievesGoal("ReactToExternalEvent")
    • marketUnavailable() β€” produces error event, @AchievesGoal("ProcessCommand")

5.4 Integration Tests (Phase 4 β€” Full Agent Loop)

Integration tests exercise the full agent loop from command/event arrival through Embabel agent invocation to state application. These require the TestTradingAdvisorAgent fixtures from section 5.3.

Test Class What to Verify
EmbabelAgentLoopIntegrationTest Full agent invocation: TestAnalyzeMarketCommand β†’ agent β†’ TestMarketAnalysisCompletedEvent applied to state
MemoryLearningIntegrationTest Agent stores memory via StoreMemoryAction β†’ MemoryStoredEvent emitted and applied to state
AgentErrorEventIntegrationTest Agent produces TestMarketUnavailableErrorEvent β†’ event emitted, state unchanged, undeclared errors logged with warning
AgentExternalEventIntegrationTest TestMarketDataUpdatedEvent β†’ agent β†’ TestMarketAnalysisCompletedEvent applied to state
EventApplicationMechanismTest DomainEvents from AgenticCommandHandlerFunctionAdapter.apply() correctly applied via handleCommand() β†’ processDomainEvent() flow

Changes from PR #303

  • Tests split by phase: 5.1 = Phase 2 unit tests (mocked Blackboard), 5.2 = Phase 1 wiring tests, 5.3 = test fixtures, 5.4 = Phase 4 integration tests
  • Phase 2 tests are purely unit-level β€” no Kafka, no Spring Boot context
  • No AgentTask/AgenticProcessHandler tests β€” deferred with incremental tick support
  • No EmitDomainEventsAction tests β€” action was removed
  • No ManageKnowledgeGoal tests β€” goal was removed

Acceptance Criteria

  • All Phase 2 unit tests pass using mocked Blackboard (no Kafka dependency)
  • All Phase 1 wiring/registration tests pass
  • TestTradingAdvisorAggregate and all test fixtures compile and are correctly annotated
  • TestTradingAdvisorAgentComponent demonstrates the full pattern for agent-based command/event handling
  • Integration tests validate the complete flow: command β†’ Embabel agent β†’ domain events β†’ state transitions
  • Error event handling is tested (emitted without state change, undeclared errors warned)
  • External event handling is tested (subscribed to all partitions, agent processes event)
  • Memory learning flow is tested end-to-end
  • All existing tests still pass
  • Code follows Java 25 conventions with JavaDoc

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions