package cucumber.runtime.junit;

import cucumber.runtime.io.Resource;
import cucumber.runtime.model.CucumberFeature;
import cucumber.runtime.model.FeatureParser;
import gherkin.events.PickleEvent;
import gherkin.pickles.Compiler;
import gherkin.pickles.Pickle;

import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;

class TestPickleBuilder {

    private TestPickleBuilder() {
    }

    static List<PickleEvent> pickleEventsFromFeature(final String path, final String source) {
        List<PickleEvent> pickleEvents = new ArrayList<PickleEvent>();
        Compiler compiler = new Compiler();

        CucumberFeature feature = parseFeature(path, source);
        for (Pickle pickle : compiler.compile(feature.getGherkinFeature())) {
            pickleEvents.add(new PickleEvent(feature.getUri().toString(), pickle));
        }

        return pickleEvents;
    }

    static CucumberFeature parseFeature(final String path, final String source) {
        return parseFeature(URI.create(path), source);
    }

    static CucumberFeature parseFeature(final URI path, final String source) {
        return FeatureParser.parseResource(new Resource() {
            @Override
            public URI getPath() {
                return path;
            }

            @Override
            public InputStream getInputStream() {
                return new ByteArrayInputStream(source.getBytes());
            }

        });
    }
}

@@ -341,16 +341,58 @@
 et.URI;%0A
+import java.nio.charset.StandardCharsets;%0A
 import j
@@ -1505,16 +1505,38 @@
 etBytes(
+StandardCharsets.UTF_8
 ));%0A    

Use explicit encoding when getting bytes from String