package com.atexpose.dispatcher.channels.webchannel.redirect;

import com.google.common.collect.ImmutableList;
import org.junit.Assert;
import org.junit.Test;

import java.net.URI;

public class RedirectsTest {
    @Test
    public void shouldAndGetRedirect() throws Exception {
        ImmutableList<IRedirect> myList = new ImmutableList.Builder<IRedirect>()
                .add(HttpsRedirect.create())
                .add(HostRedirect.create("example.com", "www.example.com"))
                .add(HostRedirect.create("www.example.com", "www.schinzel.io"))
                .add(FileRedirect.create("a/b/c/source.html", "q/r/s/dest.html"))
                .build();
        Redirects redirects = new Redirects(myList);
        URI uri = new URI("http://example.com/a/b/c/source.html?k1=ŹźŻż&k2=سش&k3=ДЂ");
        Assert.assertTrue(redirects.shouldRedirect(uri));
        Assert.assertEquals("https://www.schinzel.io/q/r/s/dest.html?k1=ŹźŻż&k2=سش&k3=ДЂ", redirects.getRedirects(uri).toString());
    }


}
@@ -999,10 +999,644 @@
 %0A    %7D%0A%0A
+    @Test%0A    public void shouldRedirect_noRedidect() throws Exception %7B%0A        ImmutableList%3CIRedirect%3E myList = new ImmutableList.Builder%3CIRedirect%3E()%0A                .add(HttpsRedirect.create())%0A                .add(HostRedirect.create(%22example.com%22, %22www.example.com%22))%0A                .add(HostRedirect.create(%22www.example.com%22, %22www.schinzel.io%22))%0A                .add(FileRedirect.create(%22a/b/c/source.html%22, %22q/r/s/dest.html%22))%0A                .build();%0A        Redirects redirects = new Redirects(myList);%0A        URI uri = new URI(%22https://www.google.com%22);%0A        Assert.assertFalse(redirects.shouldRedirect(uri));%0A    %7D%0A
 %0A%7D

Test added