package at.procon.dip.embedding.registry;

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

import at.procon.dip.domain.document.DistanceMetric;
import at.procon.dip.embedding.config.EmbeddingProperties;
import org.junit.jupiter.api.Test;

class EmbeddingModelRegistryTest {

    @Test
    void should_resolve_active_model_from_properties() {
        EmbeddingProperties properties = new EmbeddingProperties();
        properties.setDefaultDocumentModel("mock-search");
        EmbeddingProperties.ModelProperties model = new EmbeddingProperties.ModelProperties();
        model.setProviderConfigKey("mock-default");
        model.setProviderModelKey("mock-search");
        model.setDimensions(16);
        model.setDistanceMetric(DistanceMetric.COSINE);
        model.setSupportsQueryEmbeddingMode(true);
        model.setActive(true);
        properties.getModels().put("mock-search", model);

        EmbeddingModelRegistry registry = new EmbeddingModelRegistry(properties);

        assertThat(registry.getRequiredDefaultDocumentModelKey()).isEqualTo("mock-search");
        assertThat(registry.getRequired("mock-search").providerConfigKey()).isEqualTo("mock-default");
    }
}
