diff --git a/com.microsoft.copilot.eclipse.ui.test/src/com/microsoft/copilot/eclipse/ui/chat/services/ByokServiceTests.java b/com.microsoft.copilot.eclipse.ui.test/src/com/microsoft/copilot/eclipse/ui/chat/services/ByokServiceTests.java index a21e7116..93a7c5ac 100644 --- a/com.microsoft.copilot.eclipse.ui.test/src/com/microsoft/copilot/eclipse/ui/chat/services/ByokServiceTests.java +++ b/com.microsoft.copilot.eclipse.ui.test/src/com/microsoft/copilot/eclipse/ui/chat/services/ByokServiceTests.java @@ -8,6 +8,7 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.argThat; import static org.mockito.Mockito.clearInvocations; +import static org.mockito.Mockito.timeout; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -40,6 +41,7 @@ @ExtendWith(MockitoExtension.class) class ByokServiceTests { + private static final long WAIT_TIMEOUT_MS = 5000; private static final String OLLAMA_ENDPOINT = "http://localhost:11434"; private static final String OLLAMA_PROVIDER = ByokModelProvider.OLLAMA.getDisplayName(); @@ -71,7 +73,7 @@ void testConfigureOllama_discoveryFailureKeepsSavedEndpointVisible() { assertThrows(CompletionException.class, () -> byokService.configureOllama(OLLAMA_ENDPOINT).join()); - verify(preferencePage).updateProviderUrlsDisplay(argThat( + verify(preferencePage, timeout(WAIT_TIMEOUT_MS)).updateProviderUrlsDisplay(argThat( providerUrls -> OLLAMA_ENDPOINT.equals(providerUrls.get(OLLAMA_PROVIDER)))); } @@ -86,7 +88,8 @@ void testLoadProviderUrls_ignoresBlankUrlsAndKeepsFirstDuplicate() { byokService.loadProviderUrls().join(); - verify(preferencePage).updateProviderUrlsDisplay(Map.of(OLLAMA_PROVIDER, OLLAMA_ENDPOINT)); + verify(preferencePage, timeout(WAIT_TIMEOUT_MS)) + .updateProviderUrlsDisplay(Map.of(OLLAMA_PROVIDER, OLLAMA_ENDPOINT)); } @Test @@ -126,7 +129,7 @@ void testDeleteOllamaConfig_removesEndpointBeforeRefresh() { byokService.deleteOllamaConfig().join(); - verify(preferencePage).updateProviderUrlsDisplay(argThat(Map::isEmpty)); + verify(preferencePage, timeout(WAIT_TIMEOUT_MS)).updateProviderUrlsDisplay(argThat(Map::isEmpty)); } private void configureRefreshResponses(List discoveredModels) { @@ -147,4 +150,5 @@ private CompletableFuture completedStatus() { response.setSuccess(true); return CompletableFuture.completedFuture(response); } + }