forked from Sanders/TelegaBot
test: fix mock initialization and dependency injection in OpenRouterServiceTest
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user