Initial Python rewrite
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
package com.example.service.llm;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.springframework.data.redis.core.ReactiveRedisTemplate;
|
||||
import org.springframework.data.redis.core.ReactiveValueOperations;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
public class LlmResponseTunerServiceImplTest {
|
||||
|
||||
@Mock
|
||||
private ReactiveRedisTemplate<String, String> reactiveStringRedisTemplate;
|
||||
|
||||
@Mock
|
||||
private ReactiveValueOperations<String, String> reactiveValueOperations;
|
||||
|
||||
@InjectMocks
|
||||
private LlmResponseTunerServiceImpl llmResponseTunerService;
|
||||
|
||||
private final String llmPreResponseCollectionName = "llm-pre-response:";
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
when(reactiveStringRedisTemplate.opsForValue()).thenReturn(reactiveValueOperations);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getValue_shouldReturnValueFromRedis() {
|
||||
String key = "test_key";
|
||||
String expectedValue = "test_value";
|
||||
|
||||
when(reactiveValueOperations.get(llmPreResponseCollectionName + key)).thenReturn(Mono.just(expectedValue));
|
||||
|
||||
StepVerifier.create(llmResponseTunerService.getValue(key))
|
||||
.expectNext(expectedValue)
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@Test
|
||||
void setValue_shouldSetValueInRedis() {
|
||||
String key = "test_key";
|
||||
String value = "test_value";
|
||||
|
||||
when(reactiveValueOperations.set(llmPreResponseCollectionName + key, value)).thenReturn(Mono.just(true));
|
||||
|
||||
StepVerifier.create(llmResponseTunerService.setValue(key, value))
|
||||
.verifyComplete();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user