AppDataSnapshotServerPOJO extends AbstractAppDataSnapshotServer<Object> { public void setFieldToGetter(@NotNull Map<String, String> fieldToGetter) { this.fieldToGetter = Preconditions.checkNotNull(fieldToGetter); } AppDataSnapshotServerPOJO(); @Override GPOMutable convert(Object inputEvent); void setFieldToGetter(@NotNull Map<String, String> fieldToGetter); Map<String, String> getFieldToGetter();  }
@Test public void simpleTest() throws Exception { String query = SchemaUtils.jarResourceFileToString("snapshotServerPojoQuery.json"); String schema = SchemaUtils.jarResourceFileToString("snapshotServerPojoSchema.json"); TestObjAllTypes objAllTypes = new TestObjAllTypes(); Map<String, String> fieldToGetter = Maps.newHashMap(); fieldToGetter.put("stringType", "getInnerObj().stringVal"); fieldToGetter.put("charType", "getInnerObj().charVal"); fieldToGetter.put("booleanType", "getInnerObj().boolVal"); fieldToGetter.put("longType", "getInnerObj().longVal"); fieldToGetter.put("integerType", "getInnerObj().intVal"); fieldToGetter.put("shortType", "getInnerObj().shortVal"); fieldToGetter.put("byteType", "getInnerObj().byteVal"); fieldToGetter.put("floatType", "getInnerObj().floatVal"); fieldToGetter.put("doubleType", "getInnerObj().doubleVal"); AppDataSnapshotServerPOJO snapshotServer = new AppDataSnapshotServerPOJO(); snapshotServer.setFieldToGetter(fieldToGetter); snapshotServer.setSnapshotSchemaJSON(schema); CollectorTestSink<String> resultSink = new CollectorTestSink<String>(); TestUtils.setSink(snapshotServer.queryResult, resultSink); List<Object> inputList = Lists.newArrayList(); inputList.add(objAllTypes); snapshotServer.setup(null); snapshotServer.beginWindow(0L); snapshotServer.input.put(inputList); snapshotServer.query.put(query); snapshotServer.endWindow(); Assert.assertEquals(1, resultSink.collectedTuples.size()); String result = resultSink.collectedTuples.get(0); JSONObject data = new JSONObject(result).getJSONArray(DataQuerySnapshot.FIELD_DATA).getJSONObject(0); Assert.assertEquals(objAllTypes.getInnerObj().stringVal, data.get("stringType")); Assert.assertEquals(Character.toString(objAllTypes.getInnerObj().charVal), data.get("charType")); Assert.assertEquals(Boolean.toString(objAllTypes.getInnerObj().boolVal), Boolean.toString((Boolean)data.get("booleanType"))); Assert.assertEquals(Long.toString(objAllTypes.getInnerObj().longVal), data.get("longType")); Assert.assertEquals(Integer.toString(objAllTypes.getInnerObj().intVal), data.get("integerType")); Assert.assertEquals(Short.toString(objAllTypes.getInnerObj().shortVal), data.get("shortType")); Assert.assertEquals(Byte.toString(objAllTypes.getInnerObj().byteVal), data.get("byteType")); Assert.assertEquals(Float.toString(objAllTypes.getInnerObj().floatVal), data.get("floatType")); Assert.assertEquals(Double.toString(objAllTypes.getInnerObj().doubleVal), data.get("doubleType")); }