package dev.dinauer.maven.maven.core.model;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public class ExtensionParserTest
{
    @Test
    void test_01()
    {
        String filename = "test.jar.md5";

        ExtensionParser.Result result = ExtensionParser.parse(filename);

        Assertions.assertEquals("test", result.base());
        Assertions.assertEquals(FileExt.JAR, result.ext());
        Assertions.assertEquals(FileHash.MD5, result.hashExt());
    }

    @Test
    void test_02()
    {
        String filename = "test.pom.sha1";

        ExtensionParser.Result result = ExtensionParser.parse(filename);

        Assertions.assertEquals("test", result.base());
        Assertions.assertEquals(FileExt.POM, result.ext());
        Assertions.assertEquals(FileHash.SHA1, result.hashExt());
    }

    @Test
    void test_03()
    {
        String filename = "test.jar";

        ExtensionParser.Result result = ExtensionParser.parse(filename);

        Assertions.assertEquals("test", result.base());
        Assertions.assertEquals(FileExt.JAR, result.ext());
        Assertions.assertNull(result.hashExt());
    }
}
