test: fix mock initialization and dependency injection in OpenRouterServiceTest

This commit is contained in:
2025-02-15 18:50:24 +03:00
parent bd050c9658
commit 5dc7ab5e59
@@ -1,6 +1,7 @@
package ru.cathub.telegabot.service;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
@@ -25,12 +26,20 @@ class OpenRouterServiceTest {
@Mock
private RestTemplate restTemplate;
@InjectMocks
@Mock
private OpenRouterConfig openRouterConfig;
private OpenRouterServiceImpl openRouterService;
@InjectMocks
private OpenRouterConfig openRouterConfig;
@BeforeEach
void setUp() {
when(openRouterConfig.getKey()).thenReturn("test-key");
when(openRouterConfig.getUrl()).thenReturn("https://test-url");
when(openRouterConfig.getModel()).thenReturn("test-model");
openRouterService = new OpenRouterServiceImpl(openRouterConfig, restTemplate);
}
@Test
void shouldReturnValidResponse() throws OpenRouterException {