package at.procon.dip.embedding.provider.mock;

import static org.assertj.core.api.Assertions.assertThat;

import at.procon.dip.domain.document.DistanceMetric;
import at.procon.dip.embedding.model.EmbeddingModelDescriptor;
import at.procon.dip.embedding.model.EmbeddingRequest;
import at.procon.dip.embedding.model.EmbeddingUseCase;
import at.procon.dip.embedding.model.ResolvedEmbeddingProviderConfig;
import java.util.List;
import org.junit.jupiter.api.Test;

class MockEmbeddingProviderTest {

    private final MockEmbeddingProvider provider = new MockEmbeddingProvider();

    @Test
    void should_produce_deterministic_vectors() {
        EmbeddingModelDescriptor model = new EmbeddingModelDescriptor(
                "mock-search", "mock-default", "mock-search", 8, DistanceMetric.COSINE, true, true, null, true);
        ResolvedEmbeddingProviderConfig config = ResolvedEmbeddingProviderConfig.builder()
                .key("mock-default")
                .providerType("mock")
                .dimensions(8)
                .build();
        EmbeddingRequest request = EmbeddingRequest.builder()
                .modelKey("mock-search")
                .useCase(EmbeddingUseCase.DOCUMENT)
                .texts(List.of("district heating optimization"))
                .build();

        var first = provider.embedDocuments(config, model, request);
        var second = provider.embedDocuments(config, model, request);

        assertThat(first.vectors()).hasSize(1);
        assertThat(second.vectors()).hasSize(1);
        assertThat(first.vectors().getFirst()).containsExactly(second.vectors().getFirst());
    }
}
