Skip to content

Commit f182242

Browse files
committed
Integration test
1 parent 05b7f60 commit f182242

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@
3636
<version>${embabel-agent.version}</version>
3737
</dependency>
3838

39+
<dependency>
40+
<groupId>com.embabel.agent</groupId>
41+
<artifactId>embabel-agent-test</artifactId>
42+
<version>${embabel-agent.version}</version>
43+
<scope>test</scope>
44+
</dependency>
45+
3946

4047
<!-- Unit and Integration Testing -->
4148
<dependency>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package com.embabel.template.agent;
2+
3+
import com.embabel.agent.api.common.autonomy.AgentInvocation;
4+
import com.embabel.agent.domain.io.UserInput;
5+
import com.embabel.agent.testing.integration.EmbabelMockitoIntegrationTest;
6+
import org.junit.jupiter.api.Test;
7+
8+
import static org.junit.jupiter.api.Assertions.*;
9+
10+
/**
11+
* Use framework superclass to test the complete workflow of writing and reviewing a story.
12+
* This will run under Spring Boot against an AgentPlatform instance
13+
* that has loaded all our agents.
14+
*/
15+
class WriteAndReviewAgentIntegrationTest extends EmbabelMockitoIntegrationTest {
16+
17+
@Test
18+
void shouldExecuteCompleteWorkflow() {
19+
var input = new UserInput("Write about artificial intelligence");
20+
21+
var story = new Story("AI will transform our world...");
22+
var reviewedStory = new ReviewedStory(story, "Excellent exploration of AI themes.", Personas.REVIEWER);
23+
24+
whenCreateObject(prompt -> prompt.contains("Craft a short story"), Story.class)
25+
.thenReturn(story);
26+
27+
// The second call uses generateText
28+
whenGenerateText(prompt -> prompt.contains("You will be given a short story to review"))
29+
.thenReturn(reviewedStory.review());
30+
31+
var invocation = AgentInvocation.create(agentPlatform, ReviewedStory.class);
32+
var reviewedStoryResult = invocation.invoke(input);
33+
34+
assertNotNull(reviewedStoryResult);
35+
assertTrue(reviewedStoryResult.getContent().contains(story.text()),
36+
"Expected story content to be present: " + reviewedStoryResult.getContent());
37+
assertEquals(reviewedStory, reviewedStoryResult,
38+
"Expected review to match: " + reviewedStoryResult);
39+
40+
verifyCreateObjectMatching(prompt -> prompt.contains("Craft a short story"), Story.class,
41+
llm -> llm.getLlm().getTemperature() == 0.7 && llm.getToolGroups().isEmpty());
42+
verifyGenerateTextMatching(prompt -> prompt.contains("You will be given a short story to review"));
43+
verifyNoMoreInteractions();
44+
}
45+
}

0 commit comments

Comments
 (0)