my unit tests failed for a wired reason
the SimpleFunction<PubsubMessage, KV<String, Row>> got PubsubMessage and returns a pipeline containing PCollection<KV<String, Row>>.
I took only the value from KV by: pipeline.apply(Values.create()) so that the metadata contains just the Row.
but when I create an equivalent Row, somehow it's created with an extra quote so that the assertion failed
The code from the test:
Row value = Row.withSchema(XXX.valueSchema())
...
.withFieldValue("Template", ((JSONObject)json.get("template")).get("value").toString())
.build();
The code from the function:
KV<String, Row> result = FUNC({
...
Row item = Row.withSchema(XXX.valueSchema())
...
.withFieldValue("Template", message.template.get("value").toString())
.build();
return KV<"key", item>;
});
Row metadata = result.apply(Values.create())
The Rows content is almost the same except that the template field from the Row in the pipeline came up without a quote while the one that I created was built with an extra quote so that the assertion fails
PAssert.thatSingleton(metadata).isEqualTo(value);

