All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.dreamhead.moco.extractor.XmlExtractorHelper Maven / Gradle / Ivy

Go to download

Moco is an easy setup stub framework, mainly focusing on testing and integration.

There is a newer version: 1.5.0
Show newest version
package com.github.dreamhead.moco.extractor;

import com.github.dreamhead.moco.Request;
import com.github.dreamhead.moco.model.MessageContent;
import com.google.common.base.Optional;
import org.xml.sax.InputSource;

import java.io.ByteArrayInputStream;

import static com.google.common.base.Optional.absent;
import static com.google.common.base.Optional.of;

public class XmlExtractorHelper {
    public final Optional extractAsInputSource(final Request request,
                                                            final ContentRequestExtractor extractor) {
        Optional content = extractor.extract(request);
        if (content.isPresent()) {
            return of(new InputSource(new ByteArrayInputStream(content.get().getContent())));
        }

        return absent();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy