Test Canonical Transform from console


Given a string that represent a row from a Canonical file i.e. string = “field1;field2;field3” … is it possible to test the transform for that canonical at console level ? something like CanonicalExmple.process(string)?


You can do something like this (though @garrynigel will not recommend):

var canonicals = [
    field1: val1,
    . . .
    field1: val1,
    . . .
CanonicalExmple.process(canonicals); // synchronous call

Now your instances are created and stored, you can fetch them with:


I hope that helps.


Thanks Bachir - I’m interested to replicate what the data load does with raw data - providing a string and not building the json manually


I think you’re looking for CanonicalTestRunner:

var testPackage = MetadataStore.current().package("myTenant", true);
var testPath = MetadataPath.make({
  repository: testPackage.repository,
  package: testPackage.package,
  category: MetadataFileCategory.OTHER,
  encodedSubPath: "test/canonical/folder1"
var resStatus = CanonicalTestRunner.generateExpectedResult(testPath, "/path/myTenant/test/canonical/folder1/referenceResults");

I don’t think it will work on strings though, just test data that’s been provisioned.

h/t @jinyanliu

partitionKeyIsRequired error when processing a canonical mixing PhysicalMeasurementSeries