Skip to content

Update e2e tests to use HTTP mocking/Wiremock instead of Mockito mocks #7400

@maff

Description

@maff

What should we do?

The e2e tests in connectors-e2e-test/connectors-e2e-test-agentic-ai/ (the langchain4j/ subtree) currently mock the LLM layer by replacing the ChatModelFactory Spring bean with a Mockito mock and returning a stubbed CloseableChatModel:

@MockitoBean private ChatModelFactory chatModelFactory;
@Mock protected CloseableChatModel chatModel;

@BeforeEach
void setUp() {
  when(chatModelFactory.createChatModel(any())).thenReturn(chatModel);
}

These are LangChain4j-specific implementation details. Once the LangChain4j framework layer is replaced with native provider implementations, both ChatModelFactory and CloseableChatModel will no longer exist, and all tests built on top of this pattern will stop working.

Before any refactoring starts, replace the mock with WireMock stubs that intercept at the HTTP level. The connector should be configured to point at the WireMock server (e.g. via the openai-compatible provider pointing to http://localhost:<wiremock-port>), and the test stubs the expected HTTP endpoint and asserts on the request body instead.

Why?

The refactoring will remove ChatModelFactory and the LangChain4j providers entirely. Tests that mock these classes either disappear along with the code they test or need to be rewritten anyway. Rewriting them first, before the refactoring, means:

  • The new native implementations are covered by the same behavioral tests from day one.
  • Reviewers can verify the refactoring produces the same wire-level behavior rather than taking it on faith.

Metadata

Metadata

Assignees

Labels

kind:taskCategorizes an issue or PR as general maintenance, i.e. cleanup, refactoring, etc.

Type

Urgency

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions