diff --git a/metafix/src/test/java/org/metafacture/metafix/MetafixMethodTest.java b/metafix/src/test/java/org/metafacture/metafix/MetafixMethodTest.java index 9f58ecce..8a8b230e 100644 --- a/metafix/src/test/java/org/metafacture/metafix/MetafixMethodTest.java +++ b/metafix/src/test/java/org/metafacture/metafix/MetafixMethodTest.java @@ -19,9 +19,11 @@ import org.metafacture.framework.StreamReceiver; import com.google.common.collect.ImmutableMap; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; +import org.mockito.exceptions.base.MockitoAssertionError; import org.mockito.junit.jupiter.MockitoExtension; import java.util.Arrays; @@ -36,6 +38,9 @@ @ExtendWith(MetafixToDo.Extension.class) public class MetafixMethodTest { + private static final String YOUTUBE_URL = "https://www.youtube.com/watch?v=daLgsPSvD9A"; + + private static final String YOUTUBE_URL_AS_URL_URL_BASE64 = "aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g_dj1kYUxnc1BTdkQ5QQ=="; @Mock private StreamReceiver streamReceiver; @@ -4086,20 +4091,31 @@ public void shouldTransformStringToBase64() { @Test public void shouldTransformUrlToBase64() { + urlToBase64(",url_safe:'true'"); + } + + @Test + public void shouldFailTransformUrlToBase64AsDefault() { + Assertions.assertThrows(MockitoAssertionError.class, () -> { + urlToBase64(""); + }); + } + + private void urlToBase64(final String option) { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "to_base64('data.title', url_safe:'true')" + "to_base64('data.title'" + option + ")" ), i -> { i.startRecord("1"); i.startEntity("data"); - i.literal("title", "https://www.youtube.com/watch?v=daLgsPSvD9A"); + i.literal("title", YOUTUBE_URL); i.endEntity(); i.endRecord(); }, o -> { o.get().startRecord("1"); o.get().startEntity("data"); - o.get().literal("title", "aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g_dj1kYUxnc1BTdkQ5QQ=="); + o.get().literal("title", YOUTUBE_URL_AS_URL_URL_BASE64); o.get().endEntity(); o.get().endRecord(); }