use of com.google.samples.apps.iosched.server.schedule.input.fetcher.RemoteFilesEntityFetcherFactory.FetcherBuilder in project iosched by google.
the class DataExtractorTest method setUp.
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
fakeFetcher = new EntityFetcher() {
@Override
public JsonElement fetch(Enum<?> entityType, Map<String, String> params) throws IOException {
String filename = "sample_" + entityType.name();
if (params != null && params.get("page") != null && Integer.parseInt(params.get("page")) > 1) {
filename += "_page" + params.get("page");
}
filename += ".json";
InputStream stream = TestHelper.openTestDataFileStream(filename);
JsonReader reader = new JsonReader(new InputStreamReader(stream, Charset.forName("UTF-8")));
return new JsonParser().parse(reader);
}
};
RemoteFilesEntityFetcherFactory.setBuilder(new FetcherBuilder() {
@Override
public FetcherBuilder setSourceFiles(String... filenames) {
return this;
}
@Override
public EntityFetcher build() {
return fakeFetcher;
}
});
sources = new ExtraInput().fetchAllDataSources();
sources.putAll(new VendorDynamicInput(fakeFetcher).fetchAllDataSources());
}
use of com.google.samples.apps.iosched.server.schedule.input.fetcher.RemoteFilesEntityFetcherFactory.FetcherBuilder in project iosched by google.
the class ExtraInputTest method setUp.
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
fakeFetcher = new EntityFetcher() {
@Override
public JsonElement fetch(Enum<?> entityType, Map<String, String> params) throws IOException {
String filename = "sample_" + entityType.name() + ".json";
InputStream stream = TestHelper.openTestDataFileStream(filename);
assertNotNull("open file " + filename, stream);
JsonReader reader = new JsonReader(new InputStreamReader(stream, Charset.forName("UTF-8")));
return new JsonParser().parse(reader);
}
};
RemoteFilesEntityFetcherFactory.setBuilder(new FetcherBuilder() {
@Override
public FetcherBuilder setSourceFiles(String... filenames) {
return this;
}
@Override
public EntityFetcher build() {
return fakeFetcher;
}
});
}
Aggregations