package org.sejda.core.support.prefix.processor;

import org.junit.Test;
import org.sejda.core.support.prefix.model.NameGenerationRequest;

import java.io.File;
import java.io.IOException;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

public class TextPrefixProcessorTest {

    @Test
    public void producesFilenameFriendlyResults() throws IOException {
        String text = "This is an example\nof\t\f\r\n text;\\// that` is \" '' not filename friendly";
        NameGenerationRequest req = NameGenerationRequest.nameRequest().text(text);
        String actual = new TextPrefixProcessor().process("prefix-[TEXT]-suffix", req);
        assertEquals("prefix-This is an exampleof text that is   not filename friendly-suffix", actual);

        File file = File.createTempFile(actual, ".pdf");
        assertTrue(file.exists());
    }
}

@@ -46,24 +46,31 @@
 or;%0A%0Aimport 
+static 
 org.junit.Te
@@ -71,78 +71,70 @@
 nit.
-Test;%0Aimport org.sejda.core.support.prefix.model.NameGenerationRequest
+Assert.assertEquals;%0Aimport static org.junit.Assert.assertTrue
 ;%0A%0Ai
@@ -181,39 +181,32 @@
 eption;%0A%0Aimport 
-static 
 org.junit.Assert
@@ -203,70 +203,78 @@
 nit.
-Assert.assertEquals;%0Aimport static org.junit.Assert.assertTrue
+Test;%0Aimport org.sejda.core.support.prefix.model.NameGenerationRequest
 ;%0A%0Ap
@@ -866,16 +866,39 @@
 sts());%0A
+        file.delete();%0A
     %7D%0A%7D%0A

Delete test file after creation