package com.github.wvengen.maven.proguard;


import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.DefaultArtifact;
import org.apache.maven.artifact.handler.DefaultArtifactHandler;
import org.apache.maven.artifact.versioning.VersionRange;
import org.junit.Assert;
import org.junit.Test;

public class ArtifactFilterTest {

    private ArtifactFilter artifactFilter = new ArtifactFilter();

    @Test
    public void noMatch() {
        artifactFilter.groupId = "com.mahifx";
        artifactFilter.artifactId = "libB";
        Assert.assertFalse(artifactFilter.match(getArtifact()));
    }

    @Test
    public void emptyArtifactDoesNotMatch() {
        artifactFilter.groupId = "com.mahifx";
        artifactFilter.artifactId = "";
        Assert.assertFalse(artifactFilter.match(getArtifact()));
    }

    @Test
    public void wildcardMatch_allArtifact() {
        artifactFilter.groupId = "com.mahifx";
        artifactFilter.artifactId = "*";
        Assert.assertTrue(artifactFilter.match(getArtifact()));
    }

    @Test
    public void wildcardMatch_partOfArtifact() {
        artifactFilter.groupId = "com.mahifx";
        artifactFilter.artifactId = "lib*";
        Assert.assertTrue(artifactFilter.match(getArtifact()));
    }

    @Test
    public void wildcardMatch_escapeArtifactDots() {
        artifactFilter.groupId = "com.mahifx";
        artifactFilter.artifactId = "li.*";
        Artifact artifact = getArtifact();
        artifact.setArtifactId("li.b");
        Assert.assertTrue(artifactFilter.match(artifact));
    }

    @Test
    public void noMatchWithRegexTokens() {
        artifactFilter.groupId = "com.mahifx";
        artifactFilter.artifactId = "libB-utils";
        Assert.assertFalse(artifactFilter.match(getArtifact()));
    }

    private DefaultArtifact getArtifact() {
        return new DefaultArtifact("com.mahifx", "libA", VersionRange.createFromVersion("1.0.0"), "compile", "jar", null, new DefaultArtifactHandler());
    }
}

@@ -1590,303 +1590,1460 @@
 oid 
-noMatchWithRegexTokens() %7B%0A        artifactFilter.groupId = %22com.mahifx%22;%0A        artifactFilter.artifactId = %22libB-utils%22;%0A        Assert.assertFalse(artifactFilter.match(getArtifact()));%0A    %7D%0A%0A    private DefaultArtifact getArtifact() %7B%0A        return new DefaultArtifact(%22com.mahifx%22, %22libA%22
+wildcardNoMatch_escapeArtifactDots() %7B%0A        artifactFilter.groupId = %22com.mahifx%22;%0A        artifactFilter.artifactId = %22li.b%22;%0A        Assert.assertFalse(artifactFilter.match(getArtifact(%22com.mahifx%22, %22liTb%22)));%0A    %7D%0A%0A    @Test%0A    public void noMatchWithRegexTokens() %7B%0A        artifactFilter.groupId = %22com.mahifx%22;%0A        artifactFilter.artifactId = %22libB-utils%22;%0A        Assert.assertFalse(artifactFilter.match(getArtifact()));%0A    %7D%0A%0A    @Test%0A    public void wildcardMatch_partOfGroupId() %7B%0A        artifactFilter.groupId = %22com.ma*%22;%0A        artifactFilter.artifactId = %22libA%22;%0A        Assert.assertTrue(artifactFilter.match(getArtifact()));%0A    %7D%0A%0A    @Test%0A    public void simpleMatch() %7B%0A        artifactFilter.groupId = %22com.mahifx%22;%0A        artifactFilter.artifactId = %22libA%22;%0A        Assert.assertTrue(artifactFilter.match(getArtifact()));%0A    %7D%0A%0A    @Test%0A    public void wildcardMatch_subGroup() %7B%0A        artifactFilter.groupId = %22com.mahifx.*%22;%0A        artifactFilter.artifactId = %22libA%22;%0A        Assert.assertTrue(artifactFilter.match(getArtifact(%22com.mahifx.subgroup%22, %22libA%22)));%0A        Assert.assertTrue(artifactFilter.match(getArtifact(%22com.mahifx.subgroup.subsubgroup%22, %22libA%22)));%0A    %7D%0A%0A    private DefaultArtifact getArtifact() %7B%0A        return getArtifact(%22com.mahifx%22, %22libA%22);%0A    %7D%0A    %0A    private DefaultArtifact getArtifact(String groupId, String artifactId) %7B%0A        return new DefaultArtifact(groupId, artifactId
 , Ve

Add some tests to check group or artifact wildcard support