@Before public void prepareTest() throws Exception { syncConfiguration = MAPPER.readValue( MongoElasticsearchSyncIT.class.getResourceAsStream("/testSync.json"), MongoElasticsearchSyncConfiguration.class); syncConfiguration.getDestination().setClusterName(cluster().getClusterName()); MongoPersistWriter setupWriter = new MongoPersistWriter(syncConfiguration.getSource()); setupWriter.prepare(null); InputStream testActivityFolderStream = MongoElasticsearchSyncIT.class.getClassLoader().getResourceAsStream("activities"); List<String> files = IOUtils.readLines(testActivityFolderStream, Charsets.UTF_8); for (String file : files) { LOGGER.info("File: " + file); InputStream testActivityFileStream = MongoElasticsearchSyncIT.class.getClassLoader().getResourceAsStream("activities/" + file); Activity activity = MAPPER.readValue(testActivityFileStream, Activity.class); activity.getAdditionalProperties().remove("$license"); StreamsDatum datum = new StreamsDatum(activity, activity.getVerb()); setupWriter.write(datum); LOGGER.info("Wrote: " + activity.getVerb()); srcCount++; } setupWriter.cleanUp(); }
@Override public List<Activity> toActivityList(CustomType document) throws ActivityConversionException { Activity customActivity = new Activity(); customActivity.setId(document.getTest()); customActivity.setVerb(document.getTest()); customActivity.setProvider((Provider) new Provider().withId(document.getTest())); return Lists.newArrayList(customActivity); }
public static String asString( String language, Activity activity, ObjectCombination objectCombination) { String template = (String) objectCombination.getTemplates().getAdditionalProperties().get(language); template = template.replace('{', '<'); template = template.replace('}', '>'); ST st = new ST(template); st.add("actor", displayName(activity.getActor())); st.add("provider", displayName(activity.getProvider())); st.add("object", displayName(activity.getObject())); st.add("target", displayName(activity.getTarget())); return st.render(); }