package io.cameleer.server.core.storage;

import org.junit.jupiter.api.Test;
import java.util.UUID;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;

class ArtifactCoordinatesTest {
    @Test
    void rejectsNullsAndNonPositiveVersion() {
        UUID appId = UUID.randomUUID();
        assertThatThrownBy(() -> new ArtifactCoordinates(null, appId, 1))
                .isInstanceOf(IllegalArgumentException.class);
        assertThatThrownBy(() -> new ArtifactCoordinates("default", null, 1))
                .isInstanceOf(IllegalArgumentException.class);
        assertThatThrownBy(() -> new ArtifactCoordinates("default", appId, 0))
                .isInstanceOf(IllegalArgumentException.class);
    }

    @Test
    void filesystemKeyMatchesLegacyLayout() {
        UUID appId = UUID.fromString("11111111-1111-1111-1111-111111111111");
        ArtifactCoordinates c = new ArtifactCoordinates("default", appId, 7);
        assertThat(c.filesystemKey()).isEqualTo("11111111-1111-1111-1111-111111111111/v7/app.jar");
    }

    @Test
    void ociRefIsDeterministic() {
        UUID appId = UUID.fromString("11111111-1111-1111-1111-111111111111");
        ArtifactCoordinates c = new ArtifactCoordinates("acme", appId, 7);
        assertThat(c.ociRef()).isEqualTo("acme/11111111-1111-1111-1111-111111111111:v7");
    }
}
