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.
What should we do?
The e2e tests in
connectors-e2e-test/connectors-e2e-test-agentic-ai/(thelangchain4j/subtree) currently mock the LLM layer by replacing theChatModelFactorySpring bean with a Mockito mock and returning a stubbedCloseableChatModel:These are LangChain4j-specific implementation details. Once the LangChain4j framework layer is replaced with native provider implementations, both
ChatModelFactoryandCloseableChatModelwill 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-compatibleprovider pointing tohttp://localhost:<wiremock-port>), and the test stubs the expected HTTP endpoint and asserts on the request body instead.Why?
The refactoring will remove
ChatModelFactoryand 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: