com.github.dreamhead.moco.extractor.XmlExtractorHelper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of moco-core Show documentation
Show all versions of moco-core Show documentation
Moco is an easy setup stub framework, mainly focusing on testing and integration.
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();
}
}