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
Phase 5: Testing
Tracking issue: #311
Module:
main/agenticCan 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.
AkcesAgentComponentTestStoreMemoryActionTestMemoryStoredEventfrom blackboard contextForgetMemoryActionTestMemoryRevokedEventfrom blackboard contextRecallMemoriesActionTestAgentProcessResultTranslatorTest5.2 Unit Tests (Phase 1, Annotation Extensions)
These unit tests verify the wiring and registration of agent-specific metadata.
AgentPlatformInjectionTestAgentPlatformis correctly wired through factory β runtime; verifies fatal error when absentAgentProducedErrorsRegistrationTestagentProducedErrorsare registered asDomainEventType(error=true)AgentHandledCommandsRegistrationTestagentHandledCommandscreateCommandTypeentries withAgenticCommandHandlerFunctionAdapterAgentHandledEventsRegistrationTestagentHandledEventscreate externalDomainEventTypeentries withAgenticEventHandlerFunctionAdapterDiscoverAggregateServicesActionTestAggregateServiceRecords are correctly exposed on the blackboard5.3 Test Agent Implementation:
TestTradingAdvisorAgentPackage:
org.elasticsoftware.akces.agentic.testfixturesTest Aggregate
TestTradingAdvisorAggregateβ@AgenticAggregateInfowithagentHandledCommands,agentHandledEvents,agentProducedErrors@CommandHandler(TestCreateTradingAdvisorCommandβTestTradingAdvisorCreatedEvent)TestAnalyzeMarketCommand,TestMarketDataUpdatedEventTestMarketUnavailableErrorEventTest State
TestTradingAdvisorStateβ implementsAggregateState+MemoryAwareStateid,memories,analyseswithMemory()andwithoutMemory()Test Commands and Events
TestCreateTradingAdvisorCommand@CommandHandlerTestAnalyzeMarketCommandagentHandledCommandsTestTradingAdvisorCreatedEvent@CommandHandlerTestMarketAnalysisCompletedEvent@EventSourcingHandlerTestMarketDataUpdatedEventagentHandledEventsTestMarketUnavailableErrorEventagentProducedErrorsTest Embabel Agent Component
TestTradingAdvisorAgentComponentβ@EmbabelComponentwith 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
TestTradingAdvisorAgentfixtures from section 5.3.EmbabelAgentLoopIntegrationTestTestAnalyzeMarketCommandβ agent βTestMarketAnalysisCompletedEventapplied to stateMemoryLearningIntegrationTestStoreMemoryActionβMemoryStoredEventemitted and applied to stateAgentErrorEventIntegrationTestTestMarketUnavailableErrorEventβ event emitted, state unchanged, undeclared errors logged with warningAgentExternalEventIntegrationTestTestMarketDataUpdatedEventβ agent βTestMarketAnalysisCompletedEventapplied to stateEventApplicationMechanismTestAgenticCommandHandlerFunctionAdapter.apply()correctly applied viahandleCommand()βprocessDomainEvent()flowChanges from PR #303
AgentTask/AgenticProcessHandlertests β deferred with incremental tick supportEmitDomainEventsActiontests β action was removedManageKnowledgeGoaltests β goal was removedAcceptance Criteria
TestTradingAdvisorAggregateand all test fixtures compile and are correctly annotatedTestTradingAdvisorAgentComponentdemonstrates the full pattern for agent-based command/event handling