Search in sources :

Example 1 with JsonStreamToJsonDefaultSerializer

use of org.finos.legend.engine.plan.execution.result.json.JsonStreamToJsonDefaultSerializer in project legend-engine by finos.

the class TestPlanExecutionWithGraphFetchEqualityCache method testUnUtilizedCache.

@Test
public void testUnUtilizedCache() throws IOException, JavaCompileException {
    String expectedRes = "{\"builder\":{\"_type\":\"json\"},\"values\":{\"legalName\":\"FirmA\",\"employees\":[{\"firstName\":\"Peter\",\"lastName\":\"Smith\"},{\"firstName\":\"John\",\"lastName\":\"Johnson\"},{\"firstName\":\"John\",\"lastName\":\"Hill\"},{\"firstName\":\"Anthony\",\"lastName\":\"Allen\"}]}}";
    SingleExecutionPlan plan = readPlan("org/finos/legend/engine/plan/execution/stores/relational/test/cache/graphFetch//equalityCachePlanWithToManyComplexProperties.json");
    GraphFetchCacheByEqualityKeys personCache = ExecutionCacheBuilder.buildGraphFetchCacheByEqualityKeysFromGuavaCache(CacheBuilder.newBuilder().recordStats().expireAfterWrite(10, TimeUnit.MINUTES).build(), "meta::relational::tests::simpleRelationalMappingInc", "meta_pure_tests_model_simple_Person");
    PlanExecutionContext planExecutionContext = new PlanExecutionContext(plan, personCache);
    JsonStreamingResult result = (JsonStreamingResult) planExecutor.execute(plan, Collections.emptyMap(), null, planExecutionContext);
    String res = result.flush(new JsonStreamToJsonDefaultSerializer(result));
    Assert.assertEquals(expectedRes, res);
    Assert.assertFalse(personCache.isCacheUtilized());
    Assert.assertEquals(0, personCache.getExecutionCache().estimatedSize());
    Assert.assertEquals(0, personCache.getExecutionCache().stats().requestCount());
    Assert.assertEquals(0, personCache.getExecutionCache().stats().hitCount());
    Assert.assertEquals(0, personCache.getExecutionCache().stats().missCount());
}
Also used : JsonStreamingResult(org.finos.legend.engine.plan.execution.result.json.JsonStreamingResult) GraphFetchCacheByEqualityKeys(org.finos.legend.engine.plan.execution.cache.graphFetch.GraphFetchCacheByEqualityKeys) SingleExecutionPlan(org.finos.legend.engine.protocol.pure.v1.model.executionPlan.SingleExecutionPlan) PlanExecutionContext(org.finos.legend.engine.plan.execution.PlanExecutionContext) JsonStreamToJsonDefaultSerializer(org.finos.legend.engine.plan.execution.result.json.JsonStreamToJsonDefaultSerializer) Test(org.junit.Test)

Example 2 with JsonStreamToJsonDefaultSerializer

use of org.finos.legend.engine.plan.execution.result.json.JsonStreamToJsonDefaultSerializer in project legend-engine by finos.

the class TestPlanExecutor method testGraphFetchPlanExecutionWithMemoryLimits.

@Test
public void testGraphFetchPlanExecutionWithMemoryLimits() throws IOException {
    String json = "{\"_type\":\"simple\",\"authDependent\":false,\"globalImplementationSupport\":{\"_type\":\"java\",\"classes\":[{\"name\":\"JsonDataRecord\",\"package\":\"_pure.app.meta.pure.mapping.modelToModel\",\"source\":\"package _pure.app.meta.pure.mapping.modelToModel;\\n\\nimport java.math.*;\\nimport java.util.*;\\nimport org.finos.legend.engine.plan.dependencies.domain.date.PureDate;\\n\\npublic interface JsonDataRecord {\\n\\n    long getNumber();\\n\\n    String getRecord();\\n}\\n\"},{\"name\":\"Person\",\"package\":\"_pure.app.test\",\"source\":\"package _pure.app.test;\\n\\nimport java.math.*;\\nimport java.util.*;\\nimport org.finos.legend.engine.plan.dependencies.domain.date.PureDate;\\n\\npublic interface Person extends org.finos.legend.engine.plan.dependencies.store.shared.IReferencedObject {\\n\\n    String getFullName();\\n\\n    String getAlloyStoreObjectReference$();\\n}\\n\"},{\"name\":\"S_Person\",\"package\":\"_pure.app.test\",\"source\":\"package _pure.app.test;\\n\\nimport java.math.*;\\nimport java.util.*;\\nimport org.finos.legend.engine.plan.dependencies.domain.date.PureDate;\\n\\npublic interface S_Person extends org.finos.legend.engine.plan.dependencies.store.shared.IReferencedObject {\\n\\n    String getFirstName();\\n\\n    String getLastName();\\n\\n    String getAlloyStoreObjectReference$();\\n}\\n\"},{\"name\":\"Serialize\",\"package\":\"_pure.plan.root\",\"source\":\"package _pure.plan.root;\\n\\nimport _pure.plan.root.Serializer;\\nimport org.finos.legend.engine.plan.dependencies.store.platform.IGraphSerializer;\\nimport org.finos.legend.engine.plan.dependencies.store.platform.IPlatformPureExpressionExecutionNodeSerializeSpecifics;\\nimport org.finos.legend.engine.plan.dependencies.store.platform.ISerializationWriter;\\nimport org.finos.legend.engine.plan.dependencies.store.shared.IExecutionNodeContext;\\n\\npublic class Serialize implements IPlatformPureExpressionExecutionNodeSerializeSpecifics {\\n\\n    public IGraphSerializer<?> serializer(ISerializationWriter writer, IExecutionNodeContext context) {\\n        return new Serializer(writer, context);\\n    }\\n}\\n\"},{\"name\":\"Serializer\",\"package\":\"_pure.plan.root\",\"source\":\"package _pure.plan.root;\\n\\nimport _pure.app.test.Person;\\nimport org.finos.legend.engine.plan.dependencies.store.platform.IGraphSerializer;\\nimport org.finos.legend.engine.plan.dependencies.store.platform.ISerializationWriter;\\nimport org.finos.legend.engine.plan.dependencies.store.shared.IExecutionNodeContext;\\nimport org.finos.legend.engine.plan.dependencies.store.shared.IReferencedObject;\\n\\npublic class Serializer implements IGraphSerializer<Person> {\\n\\n    private ISerializationWriter writer;\\n\\n    private IExecutionNodeContext context;\\n\\n    Serializer(ISerializationWriter writer,IExecutionNodeContext context) {\\n        this.writer = writer;\\n        this.context = context;\\n    }\\n\\n    public void serialize(Person value) {\\n        if (value instanceof IReferencedObject)\\n        {\\n            this.writer.startObject(\\\"test::Person\\\", ((IReferencedObject) value).getAlloyStoreObjectReference$());\\n        }\\n        else\\n        {\\n            this.writer.startObject(\\\"test::Person\\\");\\n        }\\n        this.writer.writeStringProperty(\\\"fullName\\\", value.getFullName());\\n        this.writer.endObject();\\n    }\\n}\\n\"},{\"name\":\"Execute\",\"package\":\"_pure.plan.root.n1.localGraph\",\"source\":\"package _pure.plan.root.n1.localGraph;\\n\\nimport java.math.*;\\nimport java.util.*;\\nimport java.util.function.*;\\nimport java.util.stream.*;\\nimport org.finos.legend.engine.plan.dependencies.domain.date.DayOfWeek;\\nimport org.finos.legend.engine.plan.dependencies.domain.date.DurationUnit;\\nimport org.finos.legend.engine.plan.dependencies.domain.date.PureDate;\\nimport org.finos.legend.engine.plan.dependencies.domain.graphFetch.IGraphInstance;\\nimport org.finos.legend.engine.plan.dependencies.store.inMemory.IStoreStreamReadingExecutionNodeContext;\\nimport org.finos.legend.engine.plan.dependencies.store.inMemory.graphFetch.IInMemoryRootGraphFetchExecutionNodeSpecifics;\\nimport org.finos.legend.engine.plan.dependencies.store.shared.IReferencedObject;\\nimport org.finos.legend.engine.plan.dependencies.util.Library;\\n\\npublic class Execute implements IInMemoryRootGraphFetchExecutionNodeSpecifics {\\n\\n    public Object transform(Object input) {\\n        _pure.app.test.S_Person src = (_pure.app.test.S_Person) input;\\n        GraphFetch_Node0_Person_Impl result = new GraphFetch_Node0_Person_Impl();\\n        result.setSrc$(src);\\n        result.setSetId$(\\\"test_Person\\\");\\n        result.setFullName(Arrays.asList(src.getFirstName(), \\\" \\\", src.getLastName()).stream().collect(Collectors.joining(\\\"\\\")));\\n        return new IGraphInstance<GraphFetch_Node0_Person_Impl>()\\n        {\\n            public GraphFetch_Node0_Person_Impl getValue()\\n            {\\n                return result;\\n            }\\n            public long instanceSize()\\n            {\\n                return result.getInstanceSize$();\\n            }\\n        };\\n    }\\n}\\n\"},{\"name\":\"GraphFetch_Node0_Person_Impl\",\"package\":\"_pure.plan.root.n1.localGraph\",\"source\":\"package _pure.plan.root.n1.localGraph;\\n\\nimport java.math.*;\\nimport java.util.*;\\nimport java.util.function.*;\\nimport java.util.stream.*;\\nimport org.finos.legend.engine.plan.dependencies.domain.date.DayOfWeek;\\nimport org.finos.legend.engine.plan.dependencies.domain.date.DurationUnit;\\nimport org.finos.legend.engine.plan.dependencies.domain.date.PureDate;\\nimport org.finos.legend.engine.plan.dependencies.util.Library;\\n\\npublic class GraphFetch_Node0_Person_Impl implements _pure.app.test.Person, org.finos.legend.engine.plan.dependencies.domain.dataQuality.Constrained<_pure.app.test.Person> {\\n\\n    private String fullName;\\n\\n    private String setId$;\\n\\n    private Object src$;\\n\\n    private String alloyStoreObjectReference$;\\n\\n    public String getFullName() {\\n        return this.fullName;\\n    }\\n\\n    public void setFullName(String fullName) {\\n        this.fullName = fullName;\\n    }\\n\\n    public void addFullName(String object) {\\n        if ((Object) this.fullName != null)\\n        {\\n            throw new IllegalStateException(\\\"Found multiple objects for property 'fullName' of multiplicity with bound 1\\\");\\n        }\\n        this.fullName = object;\\n    }\\n\\n    public List<org.finos.legend.engine.plan.dependencies.domain.dataQuality.IDefect> allConstraints() {\\n        return allConstraints(new org.finos.legend.engine.plan.dependencies.domain.dataQuality.GraphContext());\\n    }\\n\\n    public List<org.finos.legend.engine.plan.dependencies.domain.dataQuality.IDefect> allConstraints(org.finos.legend.engine.plan.dependencies.domain.dataQuality.GraphContext context) {\\n        List<org.finos.legend.engine.plan.dependencies.domain.dataQuality.IDefect> result = new ArrayList<>();\\n        if (!context.visited.contains(this))\\n        {\\n            context.visited.add(this);\\n        }\\n        return result;\\n    }\\n\\n    public _pure.app.test.Person withConstraintsApplied() {\\n        List<org.finos.legend.engine.plan.dependencies.domain.dataQuality.IDefect> defects = allConstraints();\\n        if (!defects.isEmpty())\\n        {\\n            throw new IllegalStateException(defects.stream().map(org.finos.legend.engine.plan.dependencies.domain.dataQuality.IDefect::getMessage).collect(Collectors.joining(\\\"\\\\n\\\")));\\n        }\\n        return this;\\n    }\\n\\n    public org.finos.legend.engine.plan.dependencies.domain.dataQuality.IChecked<_pure.app.test.Person> toChecked() {\\n        return this.toChecked(null, true);\\n    }\\n\\n    public org.finos.legend.engine.plan.dependencies.domain.dataQuality.IChecked<_pure.app.test.Person> toChecked(boolean applyConstraints) {\\n        return this.toChecked(null, applyConstraints);\\n    }\\n\\n    public org.finos.legend.engine.plan.dependencies.domain.dataQuality.IChecked<_pure.app.test.Person> toChecked(Object source) {\\n        return this.toChecked(source, true);\\n    }\\n\\n    public org.finos.legend.engine.plan.dependencies.domain.dataQuality.IChecked<_pure.app.test.Person> toChecked(Object source, boolean applyConstraints) {\\n        List<org.finos.legend.engine.plan.dependencies.domain.dataQuality.IDefect> defects = applyConstraints ? allConstraints() : Collections.emptyList();\\n        return new org.finos.legend.engine.plan.dependencies.domain.dataQuality.IChecked<_pure.app.test.Person>() {\\n            public List<org.finos.legend.engine.plan.dependencies.domain.dataQuality.IDefect> getDefects() { return defects; }\\n            public Object getSource() { return source; }\\n            public _pure.app.test.Person getValue() { return GraphFetch_Node0_Person_Impl.this; }\\n        };\\n    }\\n\\n    public String getSetId$() {\\n        return this.setId$;\\n    }\\n\\n    public void setSetId$(String setId$) {\\n        this.setId$ = setId$;\\n    }\\n\\n    public Object getSrc$() {\\n        return this.src$;\\n    }\\n\\n    public void setSrc$(Object src$) {\\n        this.src$ = src$;\\n    }\\n\\n    public String getAlloyStoreObjectReference$() {\\n        return this.alloyStoreObjectReference$;\\n    }\\n\\n    public void setAlloyStoreObjectReference$(String alloyStoreObjectReference$) {\\n        this.alloyStoreObjectReference$ = alloyStoreObjectReference$;\\n    }\\n\\n    private static long getClassSize$() {\\n        return 108L;\\n    }\\n\\n    public long getInstanceSize$() {\\n        long size = GraphFetch_Node0_Person_Impl.getClassSize$();\\n        if (this.fullName != null)\\n        {\\n            size = size + this.fullName.length();\\n        }\\n        if (this.setId$ != null)\\n        {\\n            size = size + this.setId$.length();\\n        }\\n        if (this.alloyStoreObjectReference$ != null)\\n        {\\n            size = size + this.alloyStoreObjectReference$.length();\\n        }\\n        return size;\\n    }\\n}\\n\"},{\"name\":\"Execute\",\"package\":\"_pure.plan.root.n1.localGraph.n1\",\"source\":\"package _pure.plan.root.n1.localGraph.n1;\\n\\nimport java.math.*;\\nimport java.util.*;\\nimport java.util.function.*;\\nimport java.util.stream.*;\\nimport org.finos.legend.engine.plan.dependencies.domain.date.DayOfWeek;\\nimport org.finos.legend.engine.plan.dependencies.domain.date.DurationUnit;\\nimport org.finos.legend.engine.plan.dependencies.domain.date.PureDate;\\nimport org.finos.legend.engine.plan.dependencies.store.inMemory.IStoreStreamReader;\\nimport org.finos.legend.engine.plan.dependencies.store.inMemory.IStoreStreamReadingExecutionNodeContext;\\nimport org.finos.legend.engine.plan.dependencies.store.inMemory.graphFetch.IStoreStreamReadingExecutionNodeSpecifics;\\nimport org.finos.legend.engine.plan.dependencies.util.Library;\\n\\npublic class Execute implements IStoreStreamReadingExecutionNodeSpecifics {\\n\\n    public IStoreStreamReader streamReader(IStoreStreamReadingExecutionNodeContext context) {\\n        try\\n        {\\n            return new JsonDataReader_test_S_Person(context.createUrl(\\\"data:application/json,{\\\\\\\"firstName\\\\\\\":\\\\\\\"Jane\\\\\\\",\\\\\\\"lastName\\\\\\\":\\\\\\\"Doe\\\\\\\"}\\\").openStream());\\n        }\\n        catch (java.io.IOException e)\\n        {\\n            throw new RuntimeException(e);\\n        }\\n    }\\n}\\n\"},{\"name\":\"JsonDataReader_test_S_Person\",\"package\":\"_pure.plan.root.n1.localGraph.n1\",\"source\":\"package _pure.plan.root.n1.localGraph.n1;\\n\\nimport _pure.app.test.S_Person;\\nimport com.fasterxml.jackson.core.JsonFactory;\\nimport com.fasterxml.jackson.core.JsonParser;\\nimport com.fasterxml.jackson.core.JsonToken;\\nimport com.fasterxml.jackson.databind.JsonNode;\\nimport com.fasterxml.jackson.databind.ObjectMapper;\\nimport com.fasterxml.jackson.databind.node.JsonNodeType;\\nimport java.io.*;\\nimport java.lang.reflect.InvocationTargetException;\\nimport java.lang.reflect.Method;\\nimport java.math.*;\\nimport java.net.*;\\nimport java.util.*;\\nimport java.util.function.*;\\nimport java.util.stream.*;\\nimport org.finos.legend.engine.plan.dependencies.domain.dataQuality.Constrained;\\nimport org.finos.legend.engine.plan.dependencies.domain.dataQuality.EnforcementLevel;\\nimport org.finos.legend.engine.plan.dependencies.domain.dataQuality.GraphContext;\\nimport org.finos.legend.engine.plan.dependencies.domain.dataQuality.IChecked;\\nimport org.finos.legend.engine.plan.dependencies.domain.dataQuality.IDefect;\\nimport org.finos.legend.engine.plan.dependencies.domain.dataQuality.RelativePathNode;\\nimport org.finos.legend.engine.plan.dependencies.domain.dataQuality.RuleType;\\nimport org.finos.legend.engine.plan.dependencies.domain.date.DayOfWeek;\\nimport org.finos.legend.engine.plan.dependencies.domain.date.DurationUnit;\\nimport org.finos.legend.engine.plan.dependencies.domain.date.PureDate;\\nimport org.finos.legend.engine.plan.dependencies.util.Library;\\n\\npublic class JsonDataReader_test_S_Person implements org.finos.legend.engine.plan.dependencies.store.inMemory.IStoreStreamReader {\\n\\n    private boolean finishedReading = false;\\n\\n    private Stack<Object> stack = new Stack<Object>();\\n\\n    private JsonParser parser;\\n\\n    private ObjectMapper objectMapper;\\n\\n    private boolean inArray = false;\\n\\n    private long recordCount = 0;\\n\\n    private InputStream in;\\n\\n    JsonDataReader_test_S_Person(InputStream in) {\\n        this.in = in;\\n    }\\n\\n    public void initReading() {\\n        try\\n        {\\n            this.parser = new JsonFactory().createParser(this.in);\\n            this.objectMapper = new ObjectMapper();\\n        }\\n        catch (IOException e)\\n        {\\n            throw new RuntimeException(e);\\n        }\\n    }\\n\\n    private boolean readMethodExists(String name) {\\n        Method[] methods = this.getClass().getDeclaredMethods();\\n        for (int i = 0; i < methods.length; i++) {\\n           if (methods[i].getName().equals(name)) return true;\\n        };\\n        return false;\\n    }\\n\\n    private Object readMethodInvoke(String name, JsonNode node) {\\n        Method m = null;\\n        try{\\n           m = this.getClass().getMethod(name, JsonNode.class);\\n        }\\n        catch (NoSuchMethodException e){throw new RuntimeException(e.getMessage());}\\n        try{\\n           return m.invoke(this, node);\\n        }\\n        catch (IllegalAccessException e){throw new RuntimeException(e.getMessage());}catch (InvocationTargetException e){throw new RuntimeException(e.getMessage());}\\n    }\\n\\n    public void destroyReading() {\\n        if (this.parser.isClosed())\\n        {\\n           return;\\n        }\\n        try\\n        {\\n            this.parser.close();\\n        }\\n        catch (IOException e)\\n        {\\n            throw new RuntimeException(e);\\n        }\\n    }\\n\\n    public boolean isFinished() {\\n        nextToken();\\n        if (!this.finishedReading && getCurrentToken() == JsonToken.START_ARRAY && !inArray)\\n        {\\n            nextToken();\\n            inArray = true;\\n        }\\n        if (!this.finishedReading && getCurrentToken() == JsonToken.END_ARRAY && inArray)\\n        {\\n            nextToken();\\n            inArray = false;\\n            this.finishedReading = true;\\n        }\\n        this.finishedReading |= getCurrentToken() == null;\\n        return this.finishedReading ;\\n    }\\n\\n    public void nextToken() {\\n            try\\n            {\\n                this.parser.nextToken();\\n            }\\n            catch (IOException e)\\n            {\\n                throw new RuntimeException(e);\\n            }\\n    }\\n\\n    public IChecked<S_Person> read_test_S_Person(JsonNode node) {\\n        if (!node.path(\\\"@type\\\").getNodeType().equals(JsonNodeType.MISSING) && !node.path(\\\"@type\\\").textValue().equals(\\\"test::S_Person\\\")){\\n           String methodName = \\\"read_\\\" + node.path(\\\"@type\\\").textValue().replace(\\\"::\\\", \\\"_\\\");\\n           if (readMethodExists(methodName)){\\n              return (IChecked) readMethodInvoke(methodName, node);\\n           }\\n        }\\n        List<IDefect> defects = new ArrayList<>();\\n        \\n        List<String> _firstName = new ArrayList<>();\\n        List<String> _lastName = new ArrayList<>();\\n        \\n        this.stack.push(new _pure.plan.root.n1.localGraph.n1.test_S_Person_Impl());\\n        \\n        if (node.path(\\\"firstName\\\").getNodeType() != JsonNodeType.MISSING){\\n        _firstName = acceptMany(node.path(\\\"firstName\\\"), this::acceptString,m -> defects.add(org.finos.legend.engine.plan.dependencies.domain.dataQuality.BasicDefect.newInvalidInputErrorDefect(\\\"firstName\\\"+\\\": \\\"+m,\\\"test::S_Person\\\")));\\n        }\\n        if (node.path(\\\"lastName\\\").getNodeType() != JsonNodeType.MISSING){\\n        _lastName = acceptMany(node.path(\\\"lastName\\\"), this::acceptString,m -> defects.add(org.finos.legend.engine.plan.dependencies.domain.dataQuality.BasicDefect.newInvalidInputErrorDefect(\\\"lastName\\\"+\\\": \\\"+m,\\\"test::S_Person\\\")));\\n        }\\n        if (_firstName.size() != 1)\\n        {\\n          defects.add(org.finos.legend.engine.plan.dependencies.domain.dataQuality.BasicDefect.newClassStructureDefect(\\\"Invalid multiplicity for firstName: expected [1] found [\\\" + _firstName.size() + \\\"]\\\", \\\"test::S_Person\\\"));\\n        }\\n        if (_lastName.size() != 1)\\n        {\\n          defects.add(org.finos.legend.engine.plan.dependencies.domain.dataQuality.BasicDefect.newClassStructureDefect(\\\"Invalid multiplicity for lastName: expected [1] found [\\\" + _lastName.size() + \\\"]\\\", \\\"test::S_Person\\\"));\\n        }\\n        \\n        if (defects.stream().anyMatch(d -> d.getEnforcementLevel() == EnforcementLevel.Critical))\\n        {\\n            return new IChecked<S_Person>() {\\n            public List<IDefect> getDefects() { return defects; }\\n            public Object getSource() { return null; }\\n            public S_Person getValue() { return null; }\\n        };\\n        }\\n        else\\n        {\\n        ((_pure.plan.root.n1.localGraph.n1.test_S_Person_Impl) this.stack.peek()).firstName = _firstName.get(0);\\n        ((_pure.plan.root.n1.localGraph.n1.test_S_Person_Impl) this.stack.peek()).lastName = _lastName.get(0);\\n            S_Person value = (S_Person) this.stack.pop();\\n            return new IChecked<S_Person>() {\\n            public List<IDefect> getDefects() { return defects; }\\n            public Object getSource() { return null; }\\n            public S_Person getValue() { return value; }\\n        };\\n        }\\n    }\\n\\n    private String acceptString(JsonNode node) {\\n        try\\n        {\\n            String errorMessage = \\\"Unexpected node type:\\\" + node.getNodeType() + \\\" for PURE String\\\";\\n            this.check(Arrays.asList(JsonNodeType.valueOf(\\\"STRING\\\")), node.getNodeType(), errorMessage);\\n            return node.textValue();\\n        }\\n        catch (IllegalArgumentException ex)\\n        {\\n            throw new org.finos.legend.engine.plan.dependencies.store.inMemory.DataParsingException(ex.getMessage());\\n        }\\n    }\\n\\n    private boolean acceptBoolean(JsonNode node) {\\n        try\\n        {\\n            String errorMessage = \\\"Unexpected node type:\\\" + node.getNodeType() + \\\" for PURE Boolean\\\";\\n            this.check(Arrays.asList(JsonNodeType.valueOf(\\\"BOOLEAN\\\")), node.getNodeType(), errorMessage);\\n            return node.booleanValue();\\n        }\\n        catch (IllegalArgumentException ex)\\n        {\\n            throw new org.finos.legend.engine.plan.dependencies.store.inMemory.DataParsingException(ex.getMessage());\\n        }\\n    }\\n\\n    private long acceptInteger(JsonNode node) {\\n        try\\n        {\\n            String errorMessage = \\\"Unexpected node type:\\\" + node.getNodeType() + \\\" for PURE Integer\\\";\\n            this.check(Arrays.asList(JsonNodeType.valueOf(\\\"NUMBER\\\")), node.getNodeType(), errorMessage);\\n            return node.longValue();\\n        }\\n        catch (IllegalArgumentException ex)\\n        {\\n            throw new org.finos.legend.engine.plan.dependencies.store.inMemory.DataParsingException(ex.getMessage());\\n        }\\n    }\\n\\n    private double acceptFloat(JsonNode node) {\\n        try\\n        {\\n            String errorMessage = \\\"Unexpected node type:\\\" + node.getNodeType() + \\\" for PURE Float\\\";\\n            this.check(Arrays.asList(JsonNodeType.valueOf(\\\"NUMBER\\\")), node.getNodeType(), errorMessage);\\n            return node.doubleValue();\\n        }\\n        catch (IllegalArgumentException ex)\\n        {\\n            throw new org.finos.legend.engine.plan.dependencies.store.inMemory.DataParsingException(ex.getMessage());\\n        }\\n    }\\n\\n    private BigDecimal acceptDecimal(JsonNode node) {\\n        try\\n        {\\n            String errorMessage = \\\"Unexpected node type:\\\" + node.getNodeType() + \\\" for PURE Decimal\\\";\\n            this.check(Arrays.asList(JsonNodeType.valueOf(\\\"STRING\\\"), JsonNodeType.valueOf(\\\"NUMBER\\\")), node.getNodeType(), errorMessage);\\n            return node.getNodeType().equals(JsonNodeType.STRING) ? new BigDecimal(node.textValue()) : node.decimalValue();\\n        }\\n        catch (IllegalArgumentException ex)\\n        {\\n            throw new org.finos.legend.engine.plan.dependencies.store.inMemory.DataParsingException(ex.getMessage());\\n        }\\n    }\\n\\n    private Number acceptNumber(JsonNode node) {\\n        try\\n        {\\n            String errorMessage = \\\"Unexpected node type:\\\" + node.getNodeType() + \\\" for PURE Number\\\";\\n            this.check(Arrays.asList(JsonNodeType.valueOf(\\\"STRING\\\"), JsonNodeType.valueOf(\\\"NUMBER\\\")), node.getNodeType(), errorMessage);\\n            return node.getNodeType().equals(JsonNodeType.STRING) ? (Number) new BigDecimal(node.textValue()) : node.isDouble() == true ? node.doubleValue() : node.longValue();\\n        }\\n        catch (IllegalArgumentException ex)\\n        {\\n            throw new org.finos.legend.engine.plan.dependencies.store.inMemory.DataParsingException(ex.getMessage());\\n        }\\n    }\\n\\n    private PureDate acceptStrictDate(JsonNode node) {\\n        try\\n        {\\n            String errorMessage = \\\"Unexpected node type:\\\" + node.getNodeType() + \\\" for PURE StrictDate\\\";\\n            this.check(Arrays.asList(JsonNodeType.valueOf(\\\"STRING\\\")), node.getNodeType(), errorMessage);\\n            return PureDate.parsePureDate(node.textValue());\\n        }\\n        catch (IllegalArgumentException ex)\\n        {\\n            throw new org.finos.legend.engine.plan.dependencies.store.inMemory.DataParsingException(ex.getMessage());\\n        }\\n    }\\n\\n    private PureDate acceptDateTime(JsonNode node) {\\n        try\\n        {\\n            String errorMessage = \\\"Unexpected node type:\\\" + node.getNodeType() + \\\" for PURE DateTime\\\";\\n            this.check(Arrays.asList(JsonNodeType.valueOf(\\\"STRING\\\")), node.getNodeType(), errorMessage);\\n            return PureDate.parsePureDate(node.textValue());\\n        }\\n        catch (IllegalArgumentException ex)\\n        {\\n            throw new org.finos.legend.engine.plan.dependencies.store.inMemory.DataParsingException(ex.getMessage());\\n        }\\n    }\\n\\n    private PureDate acceptDate(JsonNode node) {\\n        try\\n        {\\n            String errorMessage = \\\"Unexpected node type:\\\" + node.getNodeType() + \\\" for PURE Date\\\";\\n            this.check(Arrays.asList(JsonNodeType.valueOf(\\\"STRING\\\")), node.getNodeType(), errorMessage);\\n            return PureDate.parsePureDate(node.textValue());\\n        }\\n        catch (IllegalArgumentException ex)\\n        {\\n            throw new org.finos.legend.engine.plan.dependencies.store.inMemory.DataParsingException(ex.getMessage());\\n        }\\n    }\\n\\n    private <T> List<T> acceptMany(JsonNode node, Function<JsonNode, T> acceptor, Consumer<String> defectRecorder) {\\n        java.util.List<T> result = new java.util.ArrayList<T>();\\n        if (node.isNull())\\n        {\\n            return result;\\n        }\\n        if (node.isArray())\\n        {\\n            for (com.fasterxml.jackson.databind.JsonNode n: node)\\n            {\\n                try\\n                {\\n                    result.add(acceptor.apply(n));\\n                }\\n                catch (org.finos.legend.engine.plan.dependencies.store.inMemory.DataParsingException ex)\\n                {\\n                    defectRecorder.accept(ex.getMessage());\\n                }\\n            }\\n        }\\n        else\\n        {\\n            try\\n            {\\n                result.add(acceptor.apply(node));\\n            }\\n            catch (org.finos.legend.engine.plan.dependencies.store.inMemory.DataParsingException ex)\\n            {\\n                defectRecorder.accept(ex.getMessage());\\n            }\\n        }\\n        return result;\\n    }\\n\\n    private JsonToken getCurrentToken() {\\n        return parser.getCurrentToken();\\n    }\\n\\n    private void check(JsonNodeType expectedNode, JsonNodeType currentNode) {\\n        check(expectedNode, currentNode, \\\"Failed to parse JSON, expected '\\\" + expectedNode + \\\"', Found \\\" + currentNode);\\n    }\\n\\n    private void check(JsonNodeType expectedNode, JsonNodeType currentNode, String errorMessage) {\\n        check(Collections.singletonList(expectedNode), currentNode, errorMessage);\\n    }\\n\\n    private void check(List<JsonNodeType> expectedNodes, JsonNodeType currentNode, String errorMessage) {\\n        if (!expectedNodes.contains(currentNode))\\n        {\\n            throw new org.finos.legend.engine.plan.dependencies.store.inMemory.DataParsingException(errorMessage);\\n        }\\n    }\\n\\n    public Collection<IChecked<S_Person>> readCheckedObjects() {\\n        try\\n        {\\n            this.recordCount++;\\n            JsonNode node = this.objectMapper.readValue(this.parser, JsonNode.class);\\n            IChecked<S_Person> object = this.read_test_S_Person(node);\\n            long recordNumber = this.recordCount;\\n            String json = node.toString();\\n            _pure.app.meta.pure.mapping.modelToModel.JsonDataRecord source = new _pure.app.meta.pure.mapping.modelToModel.JsonDataRecord()\\n            {\\n                public long getNumber()\\n                {\\n                    return recordNumber;\\n                }\\n                public String getRecord()\\n                {\\n                    return json;\\n                }\\n            };\\n            return Collections.singleton(new IChecked<S_Person>()\\n            {\\n                public List<IDefect> getDefects()\\n                {\\n                    return object.getDefects();\\n                }\\n                public Object getSource()\\n                {\\n                    return source;\\n                }\\n                public S_Person getValue()\\n                {\\n                    return object.getValue();\\n                }\\n            });\\n        }\\n        catch (IOException e)\\n        {\\n            throw new RuntimeException(e);\\n        }\\n    }\\n}\\n\"},{\"name\":\"test_S_Person_Impl\",\"package\":\"_pure.plan.root.n1.localGraph.n1\",\"source\":\"package _pure.plan.root.n1.localGraph.n1;\\n\\nimport java.math.*;\\nimport java.util.*;\\nimport java.util.function.*;\\nimport java.util.stream.*;\\nimport org.finos.legend.engine.plan.dependencies.domain.dataQuality.Constrained;\\nimport org.finos.legend.engine.plan.dependencies.domain.dataQuality.EnforcementLevel;\\nimport org.finos.legend.engine.plan.dependencies.domain.dataQuality.GraphContext;\\nimport org.finos.legend.engine.plan.dependencies.domain.dataQuality.IDefect;\\nimport org.finos.legend.engine.plan.dependencies.domain.dataQuality.RelativePathNode;\\nimport org.finos.legend.engine.plan.dependencies.domain.dataQuality.RuleType;\\nimport org.finos.legend.engine.plan.dependencies.domain.date.DayOfWeek;\\nimport org.finos.legend.engine.plan.dependencies.domain.date.DurationUnit;\\nimport org.finos.legend.engine.plan.dependencies.domain.date.PureDate;\\nimport org.finos.legend.engine.plan.dependencies.util.Library;\\nimport org.finos.legend.engine.plan.dependencies.store.shared.IReferencedObject;\\nimport org.finos.legend.engine.plan.dependencies.domain.dataQuality.IChecked;\\n\\nclass test_S_Person_Impl implements _pure.app.test.S_Person, IReferencedObject, org.finos.legend.engine.plan.dependencies.domain.dataQuality.Constrained<_pure.app.test.S_Person> {\\n\\n    String firstName;\\n\\n    String lastName;\\n\\n    test_S_Person_Impl() {\\n        \\n    }\\n\\n    public String getFirstName() {\\n        return this.firstName;\\n    }\\n\\n    public String getLastName() {\\n        return this.lastName;\\n    }\\n\\n    public String getAlloyStoreObjectReference$() {\\n        return null;\\n    }\\n\\n    public List<IDefect> allConstraints() {\\n        return allConstraints(new GraphContext());\\n    }\\n\\n    public List<IDefect> allConstraints(GraphContext context) {\\n        List<IDefect> result = new ArrayList<>();\\n        if (!context.visited.contains(this))\\n        {\\n            context.visited.add(this);\\n        }\\n        return result;\\n    }\\n\\n    public _pure.app.test.S_Person withConstraintsApplied() {\\n        List<IDefect> defects = allConstraints();\\n        if (!defects.isEmpty())\\n        {\\n            throw new IllegalStateException(defects.stream().map(IDefect::getMessage).collect(Collectors.joining(\\\"\\\\n\\\")));\\n        }\\n        return this;\\n    }\\n\\n    public IChecked<_pure.app.test.S_Person> toChecked() {\\n        return this.toChecked(null, true);\\n    }\\n\\n    public IChecked<_pure.app.test.S_Person> toChecked(boolean applyConstraints) {\\n        return this.toChecked(null, applyConstraints);\\n    }\\n\\n    public IChecked<_pure.app.test.S_Person> toChecked(Object source) {\\n        return this.toChecked(source, true);\\n    }\\n\\n    public IChecked<_pure.app.test.S_Person> toChecked(Object source, boolean applyConstraints) {\\n        List<IDefect> defects = applyConstraints ? allConstraints() : Collections.emptyList();\\n        return new IChecked<_pure.app.test.S_Person>() {\\n            public List<IDefect> getDefects() { return defects; }\\n            public Object getSource() { return source; }\\n            public _pure.app.test.S_Person getValue() { return test_S_Person_Impl.this; }\\n        };\\n    }\\n}\\n\"}]},\"rootExecutionNode\":{\"_type\":\"platform\",\"executionNodes\":[{\"_type\":\"globalGraphFetchExecutionNode\",\"checked\":false,\"enableConstraints\":true,\"executionNodes\":[],\"graphFetchTree\":{\"_type\":\"rootGraphFetchTree\",\"class\":\"test::Person\",\"subTrees\":[{\"_type\":\"propertyGraphFetchTree\",\"parameters\":[],\"property\":\"fullName\",\"subTrees\":[]}]},\"localGraphFetchExecutionNode\":{\"_type\":\"inMemoryRootGraphFetch\",\"batchSize\":1,\"checked\":false,\"executionNodes\":[{\"_type\":\"storeStreamReading\",\"checked\":false,\"connection\":{\"_type\":\"JsonModelConnection\",\"class\":\"test::S_Person\",\"element\":\"ModelStore\",\"url\":\"data:application/json,{\\\"firstName\\\":\\\"Jane\\\",\\\"lastName\\\":\\\"Doe\\\"}\"},\"enableConstraints\":true,\"executionNodes\":[],\"graphFetchTree\":{\"_type\":\"rootGraphFetchTree\",\"class\":\"test::S_Person\",\"subTrees\":[{\"_type\":\"propertyGraphFetchTree\",\"parameters\":[],\"property\":\"lastName\",\"subTrees\":[]},{\"_type\":\"propertyGraphFetchTree\",\"parameters\":[],\"property\":\"firstName\",\"subTrees\":[]}]},\"implementation\":{\"_type\":\"java\",\"executionClassFullName\":\"_pure.plan.root.n1.localGraph.n1.Execute\"},\"resultType\":{\"_type\":\"partialClass\",\"class\":\"test::S_Person\",\"propertiesWithParameters\":[{\"property\":\"lastName\"},{\"property\":\"firstName\"}]}}],\"graphFetchTree\":{\"_type\":\"rootGraphFetchTree\",\"class\":\"test::Person\",\"subTrees\":[{\"_type\":\"propertyGraphFetchTree\",\"parameters\":[],\"property\":\"fullName\",\"subTrees\":[]}]},\"implementation\":{\"_type\":\"java\",\"executionClassFullName\":\"_pure.plan.root.n1.localGraph.Execute\"},\"nodeIndex\":0,\"resultType\":{\"_type\":\"partialClass\",\"class\":\"test::Person\",\"propertiesWithParameters\":[{\"property\":\"fullName\"}],\"setImplementations\":[{\"class\":\"test::Person\",\"id\":\"test_Person\",\"mapping\":\"test::combineNames\",\"propertyMappings\":[{\"enumMapping\":{},\"property\":\"fullName\",\"type\":\"String\"}]}]}},\"resultSizeRange\":{\"lowerBound\":0},\"resultType\":{\"_type\":\"partialClass\",\"class\":\"test::Person\",\"propertiesWithParameters\":[{\"property\":\"fullName\"}],\"setImplementations\":[{\"class\":\"test::Person\",\"id\":\"test_Person\",\"mapping\":\"test::combineNames\",\"propertyMappings\":[{\"enumMapping\":{},\"property\":\"fullName\",\"type\":\"String\"}]}]},\"store\":\"MODEL\"}],\"implementation\":{\"_type\":\"java\",\"executionClassFullName\":\"_pure.plan.root.Serialize\"},\"pure\":{\"_type\":\"func\",\"fControl\":\"serialize_T_MANY__RootGraphFetchTree_1__String_1_\",\"function\":\"serialize\",\"parameters\":[{\"_type\":\"func\",\"fControl\":\"graphFetch_T_MANY__RootGraphFetchTree_1__T_MANY_\",\"function\":\"graphFetch\",\"parameters\":[{\"_type\":\"func\",\"fControl\":\"getAll_Class_1__T_MANY_\",\"function\":\"getAll\",\"parameters\":[{\"_type\":\"class\",\"fullPath\":\"test::Person\"}]},{\"_type\":\"rootGraphFetchTree\",\"class\":\"test::Person\",\"subTrees\":[{\"_type\":\"propertyGraphFetchTree\",\"parameters\":[],\"property\":\"fullName\",\"subTrees\":[]}]}]},{\"_type\":\"rootGraphFetchTree\",\"class\":\"test::Person\",\"subTrees\":[{\"_type\":\"propertyGraphFetchTree\",\"parameters\":[],\"property\":\"fullName\",\"subTrees\":[]}]}]},\"resultType\":{\"_type\":\"dataType\",\"dataType\":\"String\"}},\"serializer\":{\"name\":\"pure\",\"version\":\"vX_X_X\"},\"templateFunctions\":[]}";
    Exception e = assertThrows(RuntimeException.class, () -> {
        Result result = PlanExecutor.newPlanExecutor(true, Lists.immutable.of(InMemory.build()), 1).execute(json);
        JsonStreamToJsonDefaultSerializer jsonStreamToJsonDefaultSerializer = new JsonStreamToJsonDefaultSerializer(((JsonStreamingResult) result));
        OutputStream outputStream = new ByteArrayOutputStream();
        jsonStreamToJsonDefaultSerializer.stream(outputStream);
        assertEquals("{\"builder\":{\"_type\":\"json\"},\"values\":{\"fullName\":\"Jane Doe\"}}", outputStream.toString());
    });
    assertEquals("Maximum memory reached when processing the graphFetch. Try reducing batch size of graphFetch fetch operation.", e.getMessage());
    Result result = PlanExecutor.newPlanExecutor(true, Lists.immutable.of(InMemory.build()), 200).execute(json);
    JsonStreamToJsonDefaultSerializer jsonStreamToJsonDefaultSerializer = new JsonStreamToJsonDefaultSerializer(((JsonStreamingResult) result));
    OutputStream outputStream = new ByteArrayOutputStream();
    jsonStreamToJsonDefaultSerializer.stream(outputStream);
    assertEquals("{\"builder\":{\"_type\":\"json\"},\"values\":{\"fullName\":\"Jane Doe\"}}", outputStream.toString());
}
Also used : JsonStreamingResult(org.finos.legend.engine.plan.execution.result.json.JsonStreamingResult) OutputStream(java.io.OutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) JsonStreamToJsonDefaultSerializer(org.finos.legend.engine.plan.execution.result.json.JsonStreamToJsonDefaultSerializer) IOException(java.io.IOException) Result(org.finos.legend.engine.plan.execution.result.Result) JsonStreamingResult(org.finos.legend.engine.plan.execution.result.json.JsonStreamingResult) Test(org.junit.Test)

Example 3 with JsonStreamToJsonDefaultSerializer

use of org.finos.legend.engine.plan.execution.result.json.JsonStreamToJsonDefaultSerializer in project legend-engine by finos.

the class TestPlanExecutor method testGeneratedPlanExecuteExternallyWithProvidedInputDataAsStream.

@Test
public void testGeneratedPlanExecuteExternallyWithProvidedInputDataAsStream() throws IOException {
    String json = "{\"rootExecutionNode\":{\"executionNodes\":[{\"implementation\":{\"executionClassFullName\":\"plan.root.n1.Execute\",\"_type\":\"java\",\"executionMethodName\":\"execute\"},\"_type\":\"graphFetchM2M\",\"enableConstraints\":true,\"trees\":[{\"subTrees\":[{\"_type\":\"propertyGraphFetchTree\",\"property\":\"firstName\"},{\"_type\":\"propertyGraphFetchTree\",\"property\":\"lastName\"}],\"_type\":\"rootGraphFetchTree\",\"class\":\"meta::pure::mapping::modelToModel::test::shared::dest::Person\"}],\"resultType\":{\"setImplementations\":[{\"mapping\":\"meta::pure::mapping::modelToModel::test::simple::simpleModelMapping\",\"propertyMappings\":[{\"property\":\"firstName\",\"type\":\"String\"},{\"property\":\"lastName\",\"type\":\"String\"}],\"id\":\"meta_pure_mapping_modelToModel_test_shared_dest_Person\",\"class\":\"meta::pure::mapping::modelToModel::test::shared::dest::Person\"}],\"_type\":\"class\",\"class\":\"meta::pure::mapping::modelToModel::test::shared::dest::Person\"}}],\"implementation\":{\"executionClassFullName\":\"plan.root.Serialize\",\"_type\":\"java\"},\"_type\":\"pureExp\",\"pure\":{\"fControl\":\"serialize_T_MANY__RootGraphFetchTree_1__String_1_\",\"function\":\"serialize\",\"_type\":\"func\",\"parameters\":[{\"fControl\":\"graphFetch_T_MANY__RootGraphFetchTree_1__T_MANY_\",\"function\":\"graphFetch\",\"_type\":\"func\",\"parameters\":[{\"fControl\":\"getAll_Class_1__T_MANY_\",\"function\":\"getAll\",\"_type\":\"func\",\"parameters\":[{\"fullPath\":\"meta::pure::mapping::modelToModel::test::shared::dest::Person\",\"_type\":\"class\"}]},{\"_type\":\"rootGraphFetchTree\",\"class\":\"meta::pure::mapping::modelToModel::test::shared::dest::Person\"}]},{\"subTrees\":[{\"_type\":\"propertyGraphFetchTree\",\"property\":\"firstName\"},{\"_type\":\"propertyGraphFetchTree\",\"property\":\"lastName\"}],\"_type\":\"rootGraphFetchTree\",\"class\":\"meta::pure::mapping::modelToModel::test::shared::dest::Person\"}]},\"resultType\":{\"dataType\":\"String\",\"_type\":\"dataType\"}},\"globalImplementationSupport\":{\"classes\":[{\"package\":\"_pure.app.meta.pure.mapping.modelToModel\",\"name\":\"JsonDataRecord\",\"source\":\"package _pure.app.meta.pure.mapping.modelToModel;\\n\\nimport org.finos.legend.engine.plan.dependencies.domain.date.PureDate;\\nimport java.math.*;\\nimport java.util.*;\\n\\npublic interface JsonDataRecord {\\n\\n    long getNumber();\\n\\n    String getRecord();\\n}\\n\"},{\"package\":\"_pure.app.meta.pure.mapping.modelToModel.test.shared.dest\",\"name\":\"Person\",\"source\":\"package _pure.app.meta.pure.mapping.modelToModel.test.shared.dest;\\n\\nimport org.finos.legend.engine.plan.dependencies.domain.date.PureDate;\\nimport java.math.*;\\nimport java.util.*;\\n\\npublic interface Person extends org.finos.legend.engine.plan.dependencies.store.shared.IReferencedObject {\\n\\n    String getFirstName();\\n\\n    String getLastName();\\n\\n    String getDescription();\\n\\n    String getAlloyStoreObjectReference$();\\n}\\n\"},{\"package\":\"_pure.app.meta.pure.mapping.modelToModel.test.shared.src\",\"name\":\"_S_Person\",\"source\":\"package _pure.app.meta.pure.mapping.modelToModel.test.shared.src;\\n\\nimport org.finos.legend.engine.plan.dependencies.domain.date.PureDate;\\nimport java.math.*;\\nimport java.util.*;\\n\\npublic interface _S_Person extends org.finos.legend.engine.plan.dependencies.store.shared.IReferencedObject {\\n\\n    String getFullName();\\n\\n    String getAlloyStoreObjectReference$();\\n}\\n\"},{\"package\":\"_pure.app.meta.pure.mapping.modelToModel.test.simple\",\"name\":\"SimpleModelMapping_Adaptor_meta_pure_mapping_modelToModel_test_shared_dest_Person\",\"source\":\"package _pure.app.meta.pure.mapping.modelToModel.test.simple;\\n\\nimport _pure.app.meta.pure.mapping.modelToModel.test.shared.dest.Person;\\nimport _pure.app.meta.pure.mapping.modelToModel.test.shared.src._S_Person;\\nimport _pure.app.meta.pure.mapping.modelToModel.test.simple.SimpleModelMapping_Mapper_meta_pure_mapping_modelToModel_test_shared_dest_Person;\\nimport org.finos.legend.engine.plan.dependencies.domain.dataQuality.Constrained;\\nimport org.finos.legend.engine.plan.dependencies.domain.dataQuality.EnforcementLevel;\\nimport org.finos.legend.engine.plan.dependencies.domain.dataQuality.GraphContext;\\nimport org.finos.legend.engine.plan.dependencies.domain.dataQuality.IDefect;\\nimport org.finos.legend.engine.plan.dependencies.domain.dataQuality.RelativePathNode;\\nimport org.finos.legend.engine.plan.dependencies.domain.dataQuality.RuleType;\\nimport org.finos.legend.engine.plan.dependencies.domain.date.DayOfWeek;\\nimport org.finos.legend.engine.plan.dependencies.domain.date.DurationUnit;\\nimport org.finos.legend.engine.plan.dependencies.util.Library;\\nimport org.finos.legend.engine.plan.dependencies.domain.date.PureDate;\\nimport java.math.*;\\nimport java.util.*;\\nimport java.util.function.*;\\nimport java.util.stream.*;\\n\\npublic class SimpleModelMapping_Adaptor_meta_pure_mapping_modelToModel_test_shared_dest_Person implements Person, org.finos.legend.engine.plan.dependencies.domain.dataQuality.Constrained<_pure.app.meta.pure.mapping.modelToModel.test.shared.dest.Person>, org.finos.legend.engine.plan.dependencies.store.shared.IReferencedObject {\\n\\n    private _S_Person src;\\n\\n    public SimpleModelMapping_Adaptor_meta_pure_mapping_modelToModel_test_shared_dest_Person(_S_Person src) {\\n        this.src = src;\\n    }\\n\\n    @Override\\n    public String getFirstName() {\\n        return src.getFullName().substring((int) 0L, src.getFullName().indexOf(\\\" \\\"));\\n    }\\n\\n    @Override\\n    public String getLastName() {\\n        return src.getFullName().substring(Arrays.asList((long) src.getFullName().indexOf(\\\" \\\"), 1L).stream().reduce(0L, Library::integerPlus).intValue(), src.getFullName().length());\\n    }\\n\\n    @Override\\n    public String getDescription() {\\n        return null;\\n    }\\n\\n    public List<IDefect> allConstraints() {\\n        return allConstraints(new GraphContext());\\n    }\\n\\n    public List<IDefect> allConstraints(GraphContext context) {\\n        List<IDefect> result = new ArrayList<>();\\n        if (!context.visited.contains(this))\\n        {\\n            context.visited.add(this);\\n        }\\n        return result;\\n    }\\n\\n    public Person withConstraintsApplied() {\\n        List<IDefect> defects = allConstraints();\\n        if (!defects.isEmpty())\\n        {\\n            throw new IllegalStateException(defects.stream().map(IDefect::getMessage).collect(Collectors.joining(\\\"\\\\n\\\")));\\n        }\\n        return this;\\n    }\\n\\n    public org.finos.legend.engine.plan.dependencies.domain.dataQuality.IChecked<Person> toChecked() {\\n        return this.toChecked(null, true);\\n    }\\n\\n    public org.finos.legend.engine.plan.dependencies.domain.dataQuality.IChecked<Person> toChecked(boolean applyConstraints) {\\n        return this.toChecked(null, applyConstraints);\\n    }\\n\\n    public org.finos.legend.engine.plan.dependencies.domain.dataQuality.IChecked<Person> toChecked(Object source) {\\n        return this.toChecked(source, true);\\n    }\\n\\n    public org.finos.legend.engine.plan.dependencies.domain.dataQuality.IChecked<Person> toChecked(Object source, boolean applyConstraints) {\\n        List<IDefect> defects = applyConstraints ? allConstraints() : Collections.emptyList();\\n        return new org.finos.legend.engine.plan.dependencies.domain.dataQuality.IChecked<Person>() {\\n            public List<IDefect> getDefects() { return defects; }\\n            public Object getSource() { return source; }\\n            public Person getValue() { return SimpleModelMapping_Adaptor_meta_pure_mapping_modelToModel_test_shared_dest_Person.this; }\\n        };\\n    }\\n\\n    public String getAlloyStoreObjectReference$() {\\n        return null;\\n    }\\n}\\n\"},{\"package\":\"_pure.app.meta.pure.mapping.modelToModel.test.simple\",\"name\":\"SimpleModelMapping_Mapper_meta_pure_mapping_modelToModel_test_shared_dest_Person\",\"source\":\"package _pure.app.meta.pure.mapping.modelToModel.test.simple;\\n\\nimport _pure.app.meta.pure.mapping.modelToModel.test.shared.dest.Person;\\nimport _pure.app.meta.pure.mapping.modelToModel.test.shared.src._S_Person;\\nimport _pure.app.meta.pure.mapping.modelToModel.test.simple.SimpleModelMapping_Adaptor_meta_pure_mapping_modelToModel_test_shared_dest_Person;\\nimport java.util.*;\\nimport java.util.stream.*;\\n\\npublic class SimpleModelMapping_Mapper_meta_pure_mapping_modelToModel_test_shared_dest_Person {\\n\\n    public static Person mapOne(_S_Person src) {\\n        return new SimpleModelMapping_Adaptor_meta_pure_mapping_modelToModel_test_shared_dest_Person(src);\\n    }\\n\\n    public static List<Person> mapMany(List<_S_Person> in) {\\n        return in == null ? Collections.<Person>emptyList() : in.stream().map((_S_Person x) -> SimpleModelMapping_Mapper_meta_pure_mapping_modelToModel_test_shared_dest_Person.mapOne(x)).filter((Person x) -> x != null).collect(Collectors.toList());\\n    }\\n}\\n\"},{\"package\":\"plan.root\",\"name\":\"Serialize\",\"source\":\"package plan.root;\\n\\nimport plan.root.Serializer;\\nimport org.finos.legend.engine.plan.dependencies.store.shared.IExecutionNodeContext;\\nimport org.finos.legend.engine.plan.dependencies.store.platform.IGraphSerializer;\\nimport org.finos.legend.engine.plan.dependencies.store.platform.IPlatformPureExpressionExecutionNodeSerializeSpecifics;\\nimport org.finos.legend.engine.plan.dependencies.store.platform.ISerializationWriter;\\n\\npublic class Serialize implements IPlatformPureExpressionExecutionNodeSerializeSpecifics {\\n\\n    public IGraphSerializer<?> serializer(ISerializationWriter writer, IExecutionNodeContext context) {\\n        return new Serializer(writer, context);\\n    }\\n}\\n\"},{\"package\":\"plan.root\",\"name\":\"Serializer\",\"source\":\"package plan.root;\\n\\nimport _pure.app.meta.pure.mapping.modelToModel.test.shared.dest.Person;\\nimport org.finos.legend.engine.plan.dependencies.store.shared.IExecutionNodeContext;\\nimport org.finos.legend.engine.plan.dependencies.store.shared.IReferencedObject;\\nimport org.finos.legend.engine.plan.dependencies.store.platform.IGraphSerializer;\\nimport org.finos.legend.engine.plan.dependencies.store.platform.ISerializationWriter;\\n\\npublic class Serializer implements IGraphSerializer<Person> {\\n\\n    private ISerializationWriter writer;\\n\\n    private IExecutionNodeContext context;\\n\\n    Serializer(ISerializationWriter writer,IExecutionNodeContext context) {\\n        this.writer = writer;\\n        this.context = context;\\n    }\\n\\n    public void serialize(Person value) {\\n        if (value instanceof IReferencedObject)\\n        {\\n            this.writer.startObject(\\\"meta::pure::mapping::modelToModel::test::shared::dest::Person\\\", ((IReferencedObject) value).getAlloyStoreObjectReference$());\\n        }\\n        else\\n        {\\n            this.writer.startObject(\\\"meta::pure::mapping::modelToModel::test::shared::dest::Person\\\");\\n        }\\n        this.writer.writeStringProperty(\\\"firstName\\\", value.getFirstName());\\n        this.writer.writeStringProperty(\\\"lastName\\\", value.getLastName());\\n        this.writer.endObject();\\n    }\\n}\\n\"},{\"package\":\"plan.root.n1\",\"name\":\"Execute\",\"source\":\"package plan.root.n1;\\n\\nimport _pure.app.meta.pure.mapping.modelToModel.test.shared.src._S_Person;\\nimport plan.root.n1.Fetch_meta_pure_mapping_modelToModel_test_shared_src__S_Person;\\nimport org.finos.legend.engine.plan.dependencies.store.inMemory.IGraphFetchM2MExecutionNodeContext;\\nimport java.util.stream.Stream;\\n\\npublic class Execute {\\n\\n    public static Object execute(IGraphFetchM2MExecutionNodeContext context) {\\n        try\\n        {\\n            return new Fetch_meta_pure_mapping_modelToModel_test_shared_src__S_Person(context).fetchTarget();\\n        }\\n        catch (Exception e)\\n        {\\n            throw new RuntimeException(\\\"Failed in node: root.n1\\\", e);\\n        }\\n    }\\n}\\n\"},{\"package\":\"plan.root.n1\",\"name\":\"Fetch_meta_pure_mapping_modelToModel_test_shared_src__S_Person\",\"source\":\"package plan.root.n1;\\n\\nimport _pure.app.meta.pure.mapping.modelToModel.test.shared.dest.Person;\\nimport _pure.app.meta.pure.mapping.modelToModel.test.shared.src._S_Person;\\nimport _pure.app.meta.pure.mapping.modelToModel.test.simple.SimpleModelMapping_Mapper_meta_pure_mapping_modelToModel_test_shared_dest_Person;\\nimport org.finos.legend.engine.plan.dependencies.domain.dataQuality.Constrained;\\nimport org.finos.legend.engine.plan.dependencies.domain.dataQuality.EnforcementLevel;\\nimport org.finos.legend.engine.plan.dependencies.domain.dataQuality.GraphContext;\\nimport org.finos.legend.engine.plan.dependencies.domain.dataQuality.IDefect;\\nimport org.finos.legend.engine.plan.dependencies.domain.dataQuality.RelativePathNode;\\nimport org.finos.legend.engine.plan.dependencies.domain.dataQuality.RuleType;\\nimport org.finos.legend.engine.plan.dependencies.domain.date.DayOfWeek;\\nimport org.finos.legend.engine.plan.dependencies.domain.date.DurationUnit;\\nimport org.finos.legend.engine.plan.dependencies.util.Library;\\nimport org.finos.legend.engine.plan.dependencies.domain.date.PureDate;\\nimport java.io.*;\\nimport java.math.*;\\nimport java.net.*;\\nimport java.util.*;\\nimport java.util.function.*;\\nimport java.util.stream.*;\\n\\npublic class Fetch_meta_pure_mapping_modelToModel_test_shared_src__S_Person implements Iterator<_S_Person>, Closeable {\\n\\n    private final org.finos.legend.engine.plan.dependencies.store.inMemory.IStoreStreamReader reader;\\n\\n    private final Queue<org.finos.legend.engine.plan.dependencies.domain.dataQuality.IChecked<_S_Person>> queue = new LinkedList<org.finos.legend.engine.plan.dependencies.domain.dataQuality.IChecked<_S_Person>>();\\n\\n    public Fetch_meta_pure_mapping_modelToModel_test_shared_src__S_Person(org.finos.legend.engine.plan.dependencies.store.inMemory.IGraphFetchM2MExecutionNodeContext context) {\\n        try\\n        {\\n            InputStream in = new URL(\\\"executor:default\\\").openStream();\\n            this.reader = new JsonDataReader_meta_pure_mapping_modelToModel_test_shared_src__S_Person(in);\\n            this.reader.initReading();\\n        }\\n        catch (IOException e)\\n        {\\n            throw new RuntimeException(e);\\n        }\\n    }\\n\\n    public Stream<Person> fetchTarget() {\\n        return this.fetchSource().map(SimpleModelMapping_Mapper_meta_pure_mapping_modelToModel_test_shared_dest_Person::mapOne).filter((Person x) -> x != null).map((Person x) -> ((Constrained<Person>) x).withConstraintsApplied()).filter((Person x) -> x != null);\\n    }\\n\\n    private Stream<_S_Person> fetchSource() {\\n        return StreamSupport.stream(Spliterators.spliteratorUnknownSize(this, Spliterator.ORDERED), false);\\n    }\\n\\n    public boolean hasNext() {\\n        if (this.queue.peek() == null && !this.reader.isFinished())\\n        {\\n            this.queue.addAll(this.reader.readCheckedObjects());\\n        }\\n        if (this.queue.peek() == null)\\n        {\\n            this.close();\\n        }\\n        return this.queue.peek() != null;\\n    }\\n\\n    public _S_Person next() {\\n        if (!this.hasNext())\\n        {\\n            throw new NoSuchElementException(\\\"End of stream has passed\\\");\\n        }\\n        org.finos.legend.engine.plan.dependencies.domain.dataQuality.IChecked<_S_Person> nextValue = this.queue.remove();\\n        if (!nextValue.getDefects().isEmpty())\\n        {\\n            throw new IllegalStateException(nextValue.getDefects().stream().map((IDefect d) -> d.getMessage()).filter((String x) -> x != null).collect(Collectors.joining(\\\"\\\\n\\\")));\\n        }\\n        else if (nextValue.getValue() == null)\\n        {\\n            throw new IllegalStateException(\\\"Unexpected error: no object and no defects\\\");\\n        }\\n        if (nextValue.getValue() instanceof Constrained)\\n        {\\n            return ((Constrained<_S_Person>) nextValue.getValue()).withConstraintsApplied();\\n        }\\n        else\\n        {\\n            return nextValue.getValue();\\n        }\\n    }\\n\\n    public void close() {\\n        this.reader.destroyReading();\\n    }\\n}\\n\"},{\"package\":\"plan.root.n1\",\"name\":\"JsonDataReader_meta_pure_mapping_modelToModel_test_shared_src__S_Person\",\"source\":\"package plan.root.n1;\\n\\nimport _pure.app.meta.pure.mapping.modelToModel.test.shared.src._S_Person;\\nimport com.fasterxml.jackson.core.JsonFactory;\\nimport com.fasterxml.jackson.core.JsonParser;\\nimport com.fasterxml.jackson.core.JsonToken;\\nimport com.fasterxml.jackson.databind.JsonNode;\\nimport com.fasterxml.jackson.databind.ObjectMapper;\\nimport com.fasterxml.jackson.databind.node.JsonNodeType;\\nimport org.finos.legend.engine.plan.dependencies.domain.dataQuality.Constrained;\\nimport org.finos.legend.engine.plan.dependencies.domain.dataQuality.EnforcementLevel;\\nimport org.finos.legend.engine.plan.dependencies.domain.dataQuality.GraphContext;\\nimport org.finos.legend.engine.plan.dependencies.domain.dataQuality.IChecked;\\nimport org.finos.legend.engine.plan.dependencies.domain.dataQuality.IDefect;\\nimport org.finos.legend.engine.plan.dependencies.domain.dataQuality.RelativePathNode;\\nimport org.finos.legend.engine.plan.dependencies.domain.dataQuality.RuleType;\\nimport org.finos.legend.engine.plan.dependencies.domain.date.DayOfWeek;\\nimport org.finos.legend.engine.plan.dependencies.domain.date.DurationUnit;\\nimport org.finos.legend.engine.plan.dependencies.util.Library;\\nimport org.finos.legend.engine.plan.dependencies.domain.date.PureDate;\\nimport java.io.*;\\nimport java.lang.reflect.InvocationTargetException;\\nimport java.lang.reflect.Method;\\nimport java.math.*;\\nimport java.net.*;\\nimport java.util.*;\\nimport java.util.function.*;\\nimport java.util.stream.*;\\n\\npublic class JsonDataReader_meta_pure_mapping_modelToModel_test_shared_src__S_Person implements org.finos.legend.engine.plan.dependencies.store.inMemory.IStoreStreamReader {\\n\\n    private boolean finishedReading = false;\\n\\n    private Stack<Object> stack = new Stack<Object>();\\n\\n    private JsonParser parser;\\n\\n    private ObjectMapper objectMapper;\\n\\n    private boolean inArray = false;\\n\\n    private long recordCount = 0;\\n\\n    private InputStream in;\\n\\n    JsonDataReader_meta_pure_mapping_modelToModel_test_shared_src__S_Person(InputStream in) {\\n        this.in = in;\\n    }\\n\\n    public void initReading() {\\n        try\\n        {\\n            this.parser = new JsonFactory().createParser(this.in);\\n            this.objectMapper = new ObjectMapper();\\n        }\\n        catch (IOException e)\\n        {\\n            throw new RuntimeException(e);\\n        }\\n    }\\n\\n    private boolean readMethodExists(String name) {\\n        Method[] methods = this.getClass().getDeclaredMethods();\\n        for (int i = 0; i < methods.length; i++) {\\n           if (methods[i].getName().equals(name)) return true;\\n        };\\n        return false;\\n    }\\n\\n    private Object readMethodInvoke(String name, JsonNode node) {\\n        Method m = null;\\n        try{\\n           m = this.getClass().getMethod(name, JsonNode.class);\\n        }\\n        catch (NoSuchMethodException e){throw new RuntimeException(e.getMessage());}\\n        try{\\n           return m.invoke(this, node);\\n        }\\n        catch (IllegalAccessException e){throw new RuntimeException(e.getMessage());}catch (InvocationTargetException e){throw new RuntimeException(e.getMessage());}\\n    }\\n\\n    public void destroyReading() {\\n        if (this.parser.isClosed())\\n        {\\n           return;\\n        }\\n        try\\n        {\\n            this.parser.close();\\n        }\\n        catch (IOException e)\\n        {\\n            throw new RuntimeException(e);\\n        }\\n    }\\n\\n    public boolean isFinished() {\\n        nextToken();\\n        if (!this.finishedReading && getCurrentToken() == JsonToken.START_ARRAY && !inArray)\\n        {\\n            nextToken();\\n            inArray = true;\\n        }\\n        if (!this.finishedReading && getCurrentToken() == JsonToken.END_ARRAY && inArray)\\n        {\\n            nextToken();\\n            inArray = false;\\n            this.finishedReading = true;\\n        }\\n        this.finishedReading |= getCurrentToken() == null;\\n        return this.finishedReading ;\\n    }\\n\\n    public void nextToken() {\\n            try\\n            {\\n                this.parser.nextToken();\\n            }\\n            catch (IOException e)\\n            {\\n                throw new RuntimeException(e);\\n            }\\n    }\\n\\n    public IChecked<_S_Person> read_meta_pure_mapping_modelToModel_test_shared_src__S_Person(JsonNode node) {\\n        if (!node.path(\\\"@type\\\").getNodeType().equals(JsonNodeType.MISSING) && !node.path(\\\"@type\\\").textValue().equals(\\\"meta::pure::mapping::modelToModel::test::shared::src::_S_Person\\\")){\\n           String methodName = \\\"read_\\\" + node.path(\\\"@type\\\").textValue().replace(\\\"::\\\", \\\"_\\\");\\n           if (readMethodExists(methodName)){\\n              return (IChecked) readMethodInvoke(methodName, node);\\n           }\\n        }\\n        List<IDefect> defects = new ArrayList<>();\\n        \\n        List<String> _fullName = new ArrayList<>();\\n        \\n        this.stack.push(new plan.root.n1.meta_pure_mapping_modelToModel_test_shared_src__S_Person_Impl());\\n        \\n        if (node.path(\\\"fullName\\\").getNodeType() != JsonNodeType.MISSING){\\n        _fullName = acceptMany(node.path(\\\"fullName\\\"), this::acceptString,m -> defects.add(org.finos.legend.engine.plan.dependencies.domain.dataQuality.BasicDefect.newInvalidInputErrorDefect(\\\"fullName\\\"+\\\": \\\"+m,\\\"meta::pure::mapping::modelToModel::test::shared::src::_S_Person\\\")));\\n        }\\n        if (_fullName.size() != 1)\\n        {\\n          defects.add(org.finos.legend.engine.plan.dependencies.domain.dataQuality.BasicDefect.newClassStructureDefect(\\\"Invalid multiplicity for fullName: expected [1] found [\\\" + _fullName.size() + \\\"]\\\", \\\"meta::pure::mapping::modelToModel::test::shared::src::_S_Person\\\"));\\n        }\\n        \\n        if (defects.stream().anyMatch(d -> d.getEnforcementLevel() == EnforcementLevel.Critical))\\n        {\\n            return new IChecked<_S_Person>() {\\n            public List<IDefect> getDefects() { return defects; }\\n            public Object getSource() { return null; }\\n            public _S_Person getValue() { return null; }\\n        };\\n        }\\n        else\\n        {\\n        ((plan.root.n1.meta_pure_mapping_modelToModel_test_shared_src__S_Person_Impl) this.stack.peek()).fullName = _fullName.get(0);\\n            _S_Person value = (_S_Person) this.stack.pop();\\n            return new IChecked<_S_Person>() {\\n            public List<IDefect> getDefects() { return defects; }\\n            public Object getSource() { return null; }\\n            public _S_Person getValue() { return value; }\\n        };\\n        }\\n    }\\n\\n    private String acceptString(JsonNode node) {\\n        try\\n        {\\n            String errorMessage = \\\"Unexpected node type:\\\" + node.getNodeType() + \\\" for PURE String\\\";\\n            this.check(Arrays.asList(JsonNodeType.valueOf(\\\"STRING\\\")), node.getNodeType(), errorMessage);\\n            return node.textValue();\\n        }\\n        catch (IllegalArgumentException ex)\\n        {\\n            throw new org.finos.legend.engine.plan.dependencies.store.inMemory.DataParsingException(ex.getMessage());\\n        }\\n    }\\n\\n    private boolean acceptBoolean(JsonNode node) {\\n        try\\n        {\\n            String errorMessage = \\\"Unexpected node type:\\\" + node.getNodeType() + \\\" for PURE Boolean\\\";\\n            this.check(Arrays.asList(JsonNodeType.valueOf(\\\"BOOLEAN\\\")), node.getNodeType(), errorMessage);\\n            return node.booleanValue();\\n        }\\n        catch (IllegalArgumentException ex)\\n        {\\n            throw new org.finos.legend.engine.plan.dependencies.store.inMemory.DataParsingException(ex.getMessage());\\n        }\\n    }\\n\\n    private long acceptInteger(JsonNode node) {\\n        try\\n        {\\n            String errorMessage = \\\"Unexpected node type:\\\" + node.getNodeType() + \\\" for PURE Integer\\\";\\n            this.check(Arrays.asList(JsonNodeType.valueOf(\\\"NUMBER\\\")), node.getNodeType(), errorMessage);\\n            return node.longValue();\\n        }\\n        catch (IllegalArgumentException ex)\\n        {\\n            throw new org.finos.legend.engine.plan.dependencies.store.inMemory.DataParsingException(ex.getMessage());\\n        }\\n    }\\n\\n    private double acceptFloat(JsonNode node) {\\n        try\\n        {\\n            String errorMessage = \\\"Unexpected node type:\\\" + node.getNodeType() + \\\" for PURE Float\\\";\\n            this.check(Arrays.asList(JsonNodeType.valueOf(\\\"NUMBER\\\")), node.getNodeType(), errorMessage);\\n            return node.doubleValue();\\n        }\\n        catch (IllegalArgumentException ex)\\n        {\\n            throw new org.finos.legend.engine.plan.dependencies.store.inMemory.DataParsingException(ex.getMessage());\\n        }\\n    }\\n\\n    private BigDecimal acceptDecimal(JsonNode node) {\\n        try\\n        {\\n            String errorMessage = \\\"Unexpected node type:\\\" + node.getNodeType() + \\\" for PURE Decimal\\\";\\n            this.check(Arrays.asList(JsonNodeType.valueOf(\\\"STRING\\\"), JsonNodeType.valueOf(\\\"NUMBER\\\")), node.getNodeType(), errorMessage);\\n            return node.getNodeType().equals(JsonNodeType.STRING) ? new BigDecimal(node.textValue()) : node.decimalValue();\\n        }\\n        catch (IllegalArgumentException ex)\\n        {\\n            throw new org.finos.legend.engine.plan.dependencies.store.inMemory.DataParsingException(ex.getMessage());\\n        }\\n    }\\n\\n    private Number acceptNumber(JsonNode node) {\\n        try\\n        {\\n            String errorMessage = \\\"Unexpected node type:\\\" + node.getNodeType() + \\\" for PURE Number\\\";\\n            this.check(Arrays.asList(JsonNodeType.valueOf(\\\"STRING\\\"), JsonNodeType.valueOf(\\\"NUMBER\\\")), node.getNodeType(), errorMessage);\\n            return node.getNodeType().equals(JsonNodeType.STRING) ? (Number) new BigDecimal(node.textValue()) : node.isDouble() == true ? node.doubleValue() : node.longValue();\\n        }\\n        catch (IllegalArgumentException ex)\\n        {\\n            throw new org.finos.legend.engine.plan.dependencies.store.inMemory.DataParsingException(ex.getMessage());\\n        }\\n    }\\n\\n    private PureDate acceptStrictDate(JsonNode node) {\\n        try\\n        {\\n            String errorMessage = \\\"Unexpected node type:\\\" + node.getNodeType() + \\\" for PURE StrictDate\\\";\\n            this.check(Arrays.asList(JsonNodeType.valueOf(\\\"STRING\\\")), node.getNodeType(), errorMessage);\\n            return PureDate.parsePureDate(node.textValue());\\n        }\\n        catch (IllegalArgumentException ex)\\n        {\\n            throw new org.finos.legend.engine.plan.dependencies.store.inMemory.DataParsingException(ex.getMessage());\\n        }\\n    }\\n\\n    private PureDate acceptDateTime(JsonNode node) {\\n        try\\n        {\\n            String errorMessage = \\\"Unexpected node type:\\\" + node.getNodeType() + \\\" for PURE DateTime\\\";\\n            this.check(Arrays.asList(JsonNodeType.valueOf(\\\"STRING\\\")), node.getNodeType(), errorMessage);\\n            return PureDate.parsePureDate(node.textValue());\\n        }\\n        catch (IllegalArgumentException ex)\\n        {\\n            throw new org.finos.legend.engine.plan.dependencies.store.inMemory.DataParsingException(ex.getMessage());\\n        }\\n    }\\n\\n    private PureDate acceptDate(JsonNode node) {\\n        try\\n        {\\n            String errorMessage = \\\"Unexpected node type:\\\" + node.getNodeType() + \\\" for PURE Date\\\";\\n            this.check(Arrays.asList(JsonNodeType.valueOf(\\\"STRING\\\")), node.getNodeType(), errorMessage);\\n            return PureDate.parsePureDate(node.textValue());\\n        }\\n        catch (IllegalArgumentException ex)\\n        {\\n            throw new org.finos.legend.engine.plan.dependencies.store.inMemory.DataParsingException(ex.getMessage());\\n        }\\n    }\\n\\n    private <T> List<T> acceptMany(JsonNode node, Function<JsonNode, T> acceptor, Consumer<String> defectRecorder) {\\n        java.util.List<T> result = new java.util.ArrayList<T>();\\n        if (node.isNull())\\n        {\\n            return result;\\n        }\\n        if (node.isArray())\\n        {\\n            for (com.fasterxml.jackson.databind.JsonNode n: node)\\n            {\\n                try\\n                {\\n                    result.add(acceptor.apply(n));\\n                }\\n                catch (org.finos.legend.engine.plan.dependencies.store.inMemory.DataParsingException ex)\\n                {\\n                    defectRecorder.accept(ex.getMessage());\\n                }\\n            }\\n        }\\n        else\\n        {\\n            try\\n            {\\n                result.add(acceptor.apply(node));\\n            }\\n            catch (org.finos.legend.engine.plan.dependencies.store.inMemory.DataParsingException ex)\\n            {\\n                defectRecorder.accept(ex.getMessage());\\n            }\\n        }\\n        return result;\\n    }\\n\\n    private JsonToken getCurrentToken() {\\n        return parser.getCurrentToken();\\n    }\\n\\n    private void check(JsonNodeType expectedNode, JsonNodeType currentNode) {\\n        check(expectedNode, currentNode, \\\"Failed to parse JSON, expected '\\\" + expectedNode + \\\"', Found \\\" + currentNode);\\n    }\\n\\n    private void check(JsonNodeType expectedNode, JsonNodeType currentNode, String errorMessage) {\\n        check(Collections.singletonList(expectedNode), currentNode, errorMessage);\\n    }\\n\\n    private void check(List<JsonNodeType> expectedNodes, JsonNodeType currentNode, String errorMessage) {\\n        if (!expectedNodes.contains(currentNode))\\n        {\\n            throw new org.finos.legend.engine.plan.dependencies.store.inMemory.DataParsingException(errorMessage);\\n        }\\n    }\\n\\n    public Collection<IChecked<_S_Person>> readCheckedObjects() {\\n        try\\n        {\\n            this.recordCount++;\\n            JsonNode node = this.objectMapper.readValue(this.parser, JsonNode.class);\\n            IChecked<_S_Person> object = this.read_meta_pure_mapping_modelToModel_test_shared_src__S_Person(node);\\n            long recordNumber = this.recordCount;\\n            String json = node.toString();\\n            _pure.app.meta.pure.mapping.modelToModel.JsonDataRecord source = new _pure.app.meta.pure.mapping.modelToModel.JsonDataRecord()\\n            {\\n                public long getNumber()\\n                {\\n                    return recordNumber;\\n                }\\n                public String getRecord()\\n                {\\n                    return json;\\n                }\\n            };\\n            return Collections.singleton(new IChecked<_S_Person>()\\n            {\\n                public List<IDefect> getDefects()\\n                {\\n                    return object.getDefects();\\n                }\\n                public Object getSource()\\n                {\\n                    return source;\\n                }\\n                public _S_Person getValue()\\n                {\\n                    return object.getValue();\\n                }\\n            });\\n        }\\n        catch (IOException e)\\n        {\\n            throw new RuntimeException(e);\\n        }\\n    }\\n}\\n\"},{\"package\":\"plan.root.n1\",\"name\":\"meta_pure_mapping_modelToModel_test_shared_src__S_Person_Impl\",\"source\":\"package plan.root.n1;\\n\\nimport _pure.app.meta.pure.mapping.modelToModel.test.shared.src._S_Person;\\nimport org.finos.legend.engine.plan.dependencies.domain.dataQuality.Constrained;\\nimport org.finos.legend.engine.plan.dependencies.domain.dataQuality.EnforcementLevel;\\nimport org.finos.legend.engine.plan.dependencies.domain.dataQuality.GraphContext;\\nimport org.finos.legend.engine.plan.dependencies.domain.dataQuality.IDefect;\\nimport org.finos.legend.engine.plan.dependencies.domain.dataQuality.RelativePathNode;\\nimport org.finos.legend.engine.plan.dependencies.domain.dataQuality.RuleType;\\nimport org.finos.legend.engine.plan.dependencies.domain.date.DayOfWeek;\\nimport org.finos.legend.engine.plan.dependencies.domain.date.DurationUnit;\\nimport org.finos.legend.engine.plan.dependencies.util.Library;\\nimport org.finos.legend.engine.plan.dependencies.domain.date.PureDate;\\nimport java.math.*;\\nimport java.util.*;\\nimport java.util.function.*;\\nimport java.util.stream.*;\\n\\nclass meta_pure_mapping_modelToModel_test_shared_src__S_Person_Impl implements _S_Person, org.finos.legend.engine.plan.dependencies.store.shared.IReferencedObject, org.finos.legend.engine.plan.dependencies.domain.dataQuality.Constrained<_pure.app.meta.pure.mapping.modelToModel.test.shared.src._S_Person> {\\n\\n    String fullName;\\n\\n    meta_pure_mapping_modelToModel_test_shared_src__S_Person_Impl() {\\n        \\n    }\\n\\n    public String getFullName() {\\n        return this.fullName;\\n    }\\n\\n    public String getAlloyStoreObjectReference$() {\\n        return null;\\n    }\\n\\n    public List<IDefect> allConstraints() {\\n        return allConstraints(new GraphContext());\\n    }\\n\\n    public List<IDefect> allConstraints(GraphContext context) {\\n        List<IDefect> result = new ArrayList<>();\\n        if (!context.visited.contains(this))\\n        {\\n            context.visited.add(this);\\n        }\\n        return result;\\n    }\\n\\n    public _S_Person withConstraintsApplied() {\\n        List<IDefect> defects = allConstraints();\\n        if (!defects.isEmpty())\\n        {\\n            throw new IllegalStateException(defects.stream().map(IDefect::getMessage).collect(Collectors.joining(\\\"\\\\n\\\")));\\n        }\\n        return this;\\n    }\\n\\n    public org.finos.legend.engine.plan.dependencies.domain.dataQuality.IChecked<_S_Person> toChecked() {\\n        return this.toChecked(null, true);\\n    }\\n\\n    public org.finos.legend.engine.plan.dependencies.domain.dataQuality.IChecked<_S_Person> toChecked(boolean applyConstraints) {\\n        return this.toChecked(null, applyConstraints);\\n    }\\n\\n    public org.finos.legend.engine.plan.dependencies.domain.dataQuality.IChecked<_S_Person> toChecked(Object source) {\\n        return this.toChecked(source, true);\\n    }\\n\\n    public org.finos.legend.engine.plan.dependencies.domain.dataQuality.IChecked<_S_Person> toChecked(Object source, boolean applyConstraints) {\\n        List<IDefect> defects = applyConstraints ? allConstraints() : Collections.emptyList();\\n        return new org.finos.legend.engine.plan.dependencies.domain.dataQuality.IChecked<_S_Person>() {\\n            public List<IDefect> getDefects() { return defects; }\\n            public Object getSource() { return source; }\\n            public _S_Person getValue() { return meta_pure_mapping_modelToModel_test_shared_src__S_Person_Impl.this; }\\n        };\\n    }\\n}\\n\"}],\"_type\":\"java\"},\"authDependent\":false,\"serializer\":{\"name\":\"pure\",\"version\":\"vX_X_X\"}}";
    Result result = PlanExecutor.newPlanExecutor(InMemory.build()).execute(json, new ByteArrayInputStream("[{\"fullName\":\"John Doe\"},{\"fullName\":\"Jane Doe\"}]".getBytes()));
    JsonStreamToJsonDefaultSerializer jsonStreamToJsonDefaultSerializer = new JsonStreamToJsonDefaultSerializer(((JsonStreamingResult) result));
    OutputStream outputStream = new ByteArrayOutputStream();
    jsonStreamToJsonDefaultSerializer.stream(outputStream);
    assertEquals("{\"builder\":{\"_type\":\"json\"},\"values\":[{\"firstName\":\"John\",\"lastName\":\"Doe\"},{\"firstName\":\"Jane\",\"lastName\":\"Doe\"}]}", outputStream.toString());
}
Also used : JsonStreamingResult(org.finos.legend.engine.plan.execution.result.json.JsonStreamingResult) ByteArrayInputStream(java.io.ByteArrayInputStream) OutputStream(java.io.OutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) JsonStreamToJsonDefaultSerializer(org.finos.legend.engine.plan.execution.result.json.JsonStreamToJsonDefaultSerializer) Result(org.finos.legend.engine.plan.execution.result.Result) JsonStreamingResult(org.finos.legend.engine.plan.execution.result.json.JsonStreamingResult) Test(org.junit.Test)

Example 4 with JsonStreamToJsonDefaultSerializer

use of org.finos.legend.engine.plan.execution.result.json.JsonStreamToJsonDefaultSerializer in project legend-engine by finos.

the class ServiceStoreTestUtils method executePlan.

public static String executePlan(SingleExecutionPlan plan, Map<String, ?> params) {
    SingleExecutionPlan singleExecutionPlan = plan.getSingleExecutionPlan(params);
    Map<String, Result> vars = org.eclipse.collections.impl.factory.Maps.mutable.ofInitialCapacity(params.size());
    params.forEach((key, value) -> vars.put(key, new ConstantResult(value)));
    JsonStreamingResult result = (JsonStreamingResult) planExecutor.execute(singleExecutionPlan, vars, (String) null, Lists.mutable.with(new KerberosProfile(LocalCredentials.INSTANCE)), null);
    return result.flush(new JsonStreamToJsonDefaultSerializer(result));
}
Also used : KerberosProfile(org.finos.legend.server.pac4j.kerberos.KerberosProfile) JsonStreamingResult(org.finos.legend.engine.plan.execution.result.json.JsonStreamingResult) ConstantResult(org.finos.legend.engine.plan.execution.result.ConstantResult) SingleExecutionPlan(org.finos.legend.engine.protocol.pure.v1.model.executionPlan.SingleExecutionPlan) JsonStreamToJsonDefaultSerializer(org.finos.legend.engine.plan.execution.result.json.JsonStreamToJsonDefaultSerializer) ConstantResult(org.finos.legend.engine.plan.execution.result.ConstantResult) Result(org.finos.legend.engine.plan.execution.result.Result) JsonStreamingResult(org.finos.legend.engine.plan.execution.result.json.JsonStreamingResult)

Example 5 with JsonStreamToJsonDefaultSerializer

use of org.finos.legend.engine.plan.execution.result.json.JsonStreamToJsonDefaultSerializer in project legend-engine by finos.

the class TestPlanExecutor method testGeneratedPlanExecuteExternally.

@Test
public void testGeneratedPlanExecuteExternally() throws IOException {
    String json = "{\"rootExecutionNode\":{\"executionNodes\":[{\"implementation\":{\"executionClassFullName\":\"plan.root.n1.Execute\",\"_type\":\"java\",\"executionMethodName\":\"execute\"},\"_type\":\"graphFetchM2M\",\"enableConstraints\":true,\"trees\":[{\"subTrees\":[{\"_type\":\"propertyGraphFetchTree\",\"property\":\"firstName\"},{\"_type\":\"propertyGraphFetchTree\",\"property\":\"lastName\"}],\"_type\":\"rootGraphFetchTree\",\"class\":\"meta::pure::mapping::modelToModel::test::shared::dest::Person\"}],\"resultType\":{\"setImplementations\":[{\"mapping\":\"meta::pure::mapping::modelToModel::test::simple::simpleModelMapping\",\"propertyMappings\":[{\"property\":\"firstName\",\"type\":\"String\"},{\"property\":\"lastName\",\"type\":\"String\"}],\"id\":\"meta_pure_mapping_modelToModel_test_shared_dest_Person\",\"class\":\"meta::pure::mapping::modelToModel::test::shared::dest::Person\"}],\"_type\":\"class\",\"class\":\"meta::pure::mapping::modelToModel::test::shared::dest::Person\"}}],\"implementation\":{\"executionClassFullName\":\"plan.root.Serialize\",\"_type\":\"java\"},\"_type\":\"pureExp\",\"pure\":{\"fControl\":\"serialize_T_MANY__RootGraphFetchTree_1__String_1_\",\"function\":\"serialize\",\"_type\":\"func\",\"parameters\":[{\"fControl\":\"graphFetch_T_MANY__RootGraphFetchTree_1__T_MANY_\",\"function\":\"graphFetch\",\"_type\":\"func\",\"parameters\":[{\"fControl\":\"getAll_Class_1__T_MANY_\",\"function\":\"getAll\",\"_type\":\"func\",\"parameters\":[{\"fullPath\":\"meta::pure::mapping::modelToModel::test::shared::dest::Person\",\"_type\":\"class\"}]},{\"_type\":\"rootGraphFetchTree\",\"class\":\"meta::pure::mapping::modelToModel::test::shared::dest::Person\"}]},{\"subTrees\":[{\"_type\":\"propertyGraphFetchTree\",\"property\":\"firstName\"},{\"_type\":\"propertyGraphFetchTree\",\"property\":\"lastName\"}],\"_type\":\"rootGraphFetchTree\",\"class\":\"meta::pure::mapping::modelToModel::test::shared::dest::Person\"}]},\"resultType\":{\"dataType\":\"String\",\"_type\":\"dataType\"}},\"globalImplementationSupport\":{\"classes\":[{\"package\":\"_pure.app.meta.pure.mapping.modelToModel\",\"name\":\"JsonDataRecord\",\"source\":\"package _pure.app.meta.pure.mapping.modelToModel;\\n\\nimport org.finos.legend.engine.plan.dependencies.domain.date.PureDate;\\nimport java.math.*;\\nimport java.util.*;\\n\\npublic interface JsonDataRecord {\\n\\n    long getNumber();\\n\\n    String getRecord();\\n}\\n\"},{\"package\":\"_pure.app.meta.pure.mapping.modelToModel.test.shared.dest\",\"name\":\"Person\",\"source\":\"package _pure.app.meta.pure.mapping.modelToModel.test.shared.dest;\\n\\nimport org.finos.legend.engine.plan.dependencies.domain.date.PureDate;\\nimport java.math.*;\\nimport java.util.*;\\n\\npublic interface Person extends org.finos.legend.engine.plan.dependencies.store.shared.IReferencedObject {\\n\\n    String getFirstName();\\n\\n    String getLastName();\\n\\n    String getDescription();\\n\\n    String getAlloyStoreObjectReference$();\\n}\\n\"},{\"package\":\"_pure.app.meta.pure.mapping.modelToModel.test.shared.src\",\"name\":\"_S_Person\",\"source\":\"package _pure.app.meta.pure.mapping.modelToModel.test.shared.src;\\n\\nimport org.finos.legend.engine.plan.dependencies.domain.date.PureDate;\\nimport java.math.*;\\nimport java.util.*;\\n\\npublic interface _S_Person extends org.finos.legend.engine.plan.dependencies.store.shared.IReferencedObject {\\n\\n    String getFullName();\\n\\n    String getAlloyStoreObjectReference$();\\n}\\n\"},{\"package\":\"_pure.app.meta.pure.mapping.modelToModel.test.simple\",\"name\":\"SimpleModelMapping_Adaptor_meta_pure_mapping_modelToModel_test_shared_dest_Person\",\"source\":\"package _pure.app.meta.pure.mapping.modelToModel.test.simple;\\n\\nimport _pure.app.meta.pure.mapping.modelToModel.test.shared.dest.Person;\\nimport _pure.app.meta.pure.mapping.modelToModel.test.shared.src._S_Person;\\nimport _pure.app.meta.pure.mapping.modelToModel.test.simple.SimpleModelMapping_Mapper_meta_pure_mapping_modelToModel_test_shared_dest_Person;\\nimport org.finos.legend.engine.plan.dependencies.domain.dataQuality.Constrained;\\nimport org.finos.legend.engine.plan.dependencies.domain.dataQuality.EnforcementLevel;\\nimport org.finos.legend.engine.plan.dependencies.domain.dataQuality.GraphContext;\\nimport org.finos.legend.engine.plan.dependencies.domain.dataQuality.IDefect;\\nimport org.finos.legend.engine.plan.dependencies.domain.dataQuality.RelativePathNode;\\nimport org.finos.legend.engine.plan.dependencies.domain.dataQuality.RuleType;\\nimport org.finos.legend.engine.plan.dependencies.domain.date.DayOfWeek;\\nimport org.finos.legend.engine.plan.dependencies.domain.date.DurationUnit;\\nimport org.finos.legend.engine.plan.dependencies.util.Library;\\nimport org.finos.legend.engine.plan.dependencies.domain.date.PureDate;\\nimport java.math.*;\\nimport java.util.*;\\nimport java.util.function.*;\\nimport java.util.stream.*;\\n\\npublic class SimpleModelMapping_Adaptor_meta_pure_mapping_modelToModel_test_shared_dest_Person implements Person, org.finos.legend.engine.plan.dependencies.domain.dataQuality.Constrained<_pure.app.meta.pure.mapping.modelToModel.test.shared.dest.Person>, org.finos.legend.engine.plan.dependencies.store.shared.IReferencedObject {\\n\\n    private _S_Person src;\\n\\n    public SimpleModelMapping_Adaptor_meta_pure_mapping_modelToModel_test_shared_dest_Person(_S_Person src) {\\n        this.src = src;\\n    }\\n\\n    @Override\\n    public String getFirstName() {\\n        return src.getFullName().substring((int) 0L, src.getFullName().indexOf(\\\" \\\"));\\n    }\\n\\n    @Override\\n    public String getLastName() {\\n        return src.getFullName().substring(Arrays.asList((long) src.getFullName().indexOf(\\\" \\\"), 1L).stream().reduce(0L, Library::integerPlus).intValue(), src.getFullName().length());\\n    }\\n\\n    @Override\\n    public String getDescription() {\\n        return null;\\n    }\\n\\n    public List<IDefect> allConstraints() {\\n        return allConstraints(new GraphContext());\\n    }\\n\\n    public List<IDefect> allConstraints(GraphContext context) {\\n        List<IDefect> result = new ArrayList<>();\\n        if (!context.visited.contains(this))\\n        {\\n            context.visited.add(this);\\n        }\\n        return result;\\n    }\\n\\n    public Person withConstraintsApplied() {\\n        List<IDefect> defects = allConstraints();\\n        if (!defects.isEmpty())\\n        {\\n            throw new IllegalStateException(defects.stream().map(IDefect::getMessage).collect(Collectors.joining(\\\"\\\\n\\\")));\\n        }\\n        return this;\\n    }\\n\\n    public org.finos.legend.engine.plan.dependencies.domain.dataQuality.IChecked<Person> toChecked() {\\n        return this.toChecked(null, true);\\n    }\\n\\n    public org.finos.legend.engine.plan.dependencies.domain.dataQuality.IChecked<Person> toChecked(boolean applyConstraints) {\\n        return this.toChecked(null, applyConstraints);\\n    }\\n\\n    public org.finos.legend.engine.plan.dependencies.domain.dataQuality.IChecked<Person> toChecked(Object source) {\\n        return this.toChecked(source, true);\\n    }\\n\\n    public org.finos.legend.engine.plan.dependencies.domain.dataQuality.IChecked<Person> toChecked(Object source, boolean applyConstraints) {\\n        List<IDefect> defects = applyConstraints ? allConstraints() : Collections.emptyList();\\n        return new org.finos.legend.engine.plan.dependencies.domain.dataQuality.IChecked<Person>() {\\n            public List<IDefect> getDefects() { return defects; }\\n            public Object getSource() { return source; }\\n            public Person getValue() { return SimpleModelMapping_Adaptor_meta_pure_mapping_modelToModel_test_shared_dest_Person.this; }\\n        };\\n    }\\n\\n    public String getAlloyStoreObjectReference$() {\\n        return null;\\n    }\\n}\\n\"},{\"package\":\"_pure.app.meta.pure.mapping.modelToModel.test.simple\",\"name\":\"SimpleModelMapping_Mapper_meta_pure_mapping_modelToModel_test_shared_dest_Person\",\"source\":\"package _pure.app.meta.pure.mapping.modelToModel.test.simple;\\n\\nimport _pure.app.meta.pure.mapping.modelToModel.test.shared.dest.Person;\\nimport _pure.app.meta.pure.mapping.modelToModel.test.shared.src._S_Person;\\nimport _pure.app.meta.pure.mapping.modelToModel.test.simple.SimpleModelMapping_Adaptor_meta_pure_mapping_modelToModel_test_shared_dest_Person;\\nimport java.util.*;\\nimport java.util.stream.*;\\n\\npublic class SimpleModelMapping_Mapper_meta_pure_mapping_modelToModel_test_shared_dest_Person {\\n\\n    public static Person mapOne(_S_Person src) {\\n        return new SimpleModelMapping_Adaptor_meta_pure_mapping_modelToModel_test_shared_dest_Person(src);\\n    }\\n\\n    public static List<Person> mapMany(List<_S_Person> in) {\\n        return in == null ? Collections.<Person>emptyList() : in.stream().map((_S_Person x) -> SimpleModelMapping_Mapper_meta_pure_mapping_modelToModel_test_shared_dest_Person.mapOne(x)).filter((Person x) -> x != null).collect(Collectors.toList());\\n    }\\n}\\n\"},{\"package\":\"plan.root\",\"name\":\"Serialize\",\"source\":\"package plan.root;\\n\\nimport plan.root.Serializer;\\nimport org.finos.legend.engine.plan.dependencies.store.shared.IExecutionNodeContext;\\nimport org.finos.legend.engine.plan.dependencies.store.platform.IGraphSerializer;\\nimport org.finos.legend.engine.plan.dependencies.store.platform.IPlatformPureExpressionExecutionNodeSerializeSpecifics;\\nimport org.finos.legend.engine.plan.dependencies.store.platform.ISerializationWriter;\\n\\npublic class Serialize implements IPlatformPureExpressionExecutionNodeSerializeSpecifics {\\n\\n    public IGraphSerializer<?> serializer(ISerializationWriter writer, IExecutionNodeContext context) {\\n        return new Serializer(writer, context);\\n    }\\n}\\n\"},{\"package\":\"plan.root\",\"name\":\"Serializer\",\"source\":\"package plan.root;\\n\\nimport _pure.app.meta.pure.mapping.modelToModel.test.shared.dest.Person;\\nimport org.finos.legend.engine.plan.dependencies.store.shared.IExecutionNodeContext;\\nimport org.finos.legend.engine.plan.dependencies.store.shared.IReferencedObject;\\nimport org.finos.legend.engine.plan.dependencies.store.platform.IGraphSerializer;\\nimport org.finos.legend.engine.plan.dependencies.store.platform.ISerializationWriter;\\n\\npublic class Serializer implements IGraphSerializer<Person> {\\n\\n    private ISerializationWriter writer;\\n\\n    private IExecutionNodeContext context;\\n\\n    Serializer(ISerializationWriter writer,IExecutionNodeContext context) {\\n        this.writer = writer;\\n        this.context = context;\\n    }\\n\\n    public void serialize(Person value) {\\n        if (value instanceof IReferencedObject)\\n        {\\n            this.writer.startObject(\\\"meta::pure::mapping::modelToModel::test::shared::dest::Person\\\", ((IReferencedObject) value).getAlloyStoreObjectReference$());\\n        }\\n        else\\n        {\\n            this.writer.startObject(\\\"meta::pure::mapping::modelToModel::test::shared::dest::Person\\\");\\n        }\\n        this.writer.writeStringProperty(\\\"firstName\\\", value.getFirstName());\\n        this.writer.writeStringProperty(\\\"lastName\\\", value.getLastName());\\n        this.writer.endObject();\\n    }\\n}\\n\"},{\"package\":\"plan.root.n1\",\"name\":\"Execute\",\"source\":\"package plan.root.n1;\\n\\nimport _pure.app.meta.pure.mapping.modelToModel.test.shared.src._S_Person;\\nimport plan.root.n1.Fetch_meta_pure_mapping_modelToModel_test_shared_src__S_Person;\\nimport org.finos.legend.engine.plan.dependencies.store.inMemory.IGraphFetchM2MExecutionNodeContext;\\nimport java.util.stream.Stream;\\n\\npublic class Execute {\\n\\n    public static Object execute(IGraphFetchM2MExecutionNodeContext context) {\\n        try\\n        {\\n            return new Fetch_meta_pure_mapping_modelToModel_test_shared_src__S_Person(context).fetchTarget();\\n        }\\n        catch (Exception e)\\n        {\\n            throw new RuntimeException(\\\"Failed in node: root.n1\\\", e);\\n        }\\n    }\\n}\\n\"},{\"package\":\"plan.root.n1\",\"name\":\"Fetch_meta_pure_mapping_modelToModel_test_shared_src__S_Person\",\"source\":\"package plan.root.n1;\\n\\nimport _pure.app.meta.pure.mapping.modelToModel.test.shared.dest.Person;\\nimport _pure.app.meta.pure.mapping.modelToModel.test.shared.src._S_Person;\\nimport _pure.app.meta.pure.mapping.modelToModel.test.simple.SimpleModelMapping_Mapper_meta_pure_mapping_modelToModel_test_shared_dest_Person;\\nimport org.finos.legend.engine.plan.dependencies.domain.dataQuality.Constrained;\\nimport org.finos.legend.engine.plan.dependencies.domain.dataQuality.EnforcementLevel;\\nimport org.finos.legend.engine.plan.dependencies.domain.dataQuality.GraphContext;\\nimport org.finos.legend.engine.plan.dependencies.domain.dataQuality.IDefect;\\nimport org.finos.legend.engine.plan.dependencies.domain.dataQuality.RelativePathNode;\\nimport org.finos.legend.engine.plan.dependencies.domain.dataQuality.RuleType;\\nimport org.finos.legend.engine.plan.dependencies.domain.date.DayOfWeek;\\nimport org.finos.legend.engine.plan.dependencies.domain.date.DurationUnit;\\nimport org.finos.legend.engine.plan.dependencies.util.Library;\\nimport org.finos.legend.engine.plan.dependencies.domain.date.PureDate;\\nimport java.io.*;\\nimport java.math.*;\\nimport java.net.*;\\nimport java.util.*;\\nimport java.util.function.*;\\nimport java.util.stream.*;\\n\\npublic class Fetch_meta_pure_mapping_modelToModel_test_shared_src__S_Person implements Iterator<_S_Person>, Closeable {\\n\\n    private final org.finos.legend.engine.plan.dependencies.store.inMemory.IStoreStreamReader reader;\\n\\n    private final Queue<org.finos.legend.engine.plan.dependencies.domain.dataQuality.IChecked<_S_Person>> queue = new LinkedList<org.finos.legend.engine.plan.dependencies.domain.dataQuality.IChecked<_S_Person>>();\\n\\n    public Fetch_meta_pure_mapping_modelToModel_test_shared_src__S_Person(org.finos.legend.engine.plan.dependencies.store.inMemory.IGraphFetchM2MExecutionNodeContext context) {\\n        try\\n        {\\n            InputStream in = new URL(\\\"data:application\\/json,[{\\\\\\\"fullName\\\\\\\":\\\\\\\"Johny Doe\\\\\\\"},{\\\\\\\"fullName\\\\\\\":\\\\\\\"Jane Doe\\\\\\\"}]\\\").openStream();\\n            this.reader = new JsonDataReader_meta_pure_mapping_modelToModel_test_shared_src__S_Person(in);\\n            this.reader.initReading();\\n        }\\n        catch (IOException e)\\n        {\\n            throw new RuntimeException(e);\\n        }\\n    }\\n\\n    public Stream<Person> fetchTarget() {\\n        return this.fetchSource().map(SimpleModelMapping_Mapper_meta_pure_mapping_modelToModel_test_shared_dest_Person::mapOne).filter((Person x) -> x != null).map((Person x) -> ((Constrained<Person>) x).withConstraintsApplied()).filter((Person x) -> x != null);\\n    }\\n\\n    private Stream<_S_Person> fetchSource() {\\n        return StreamSupport.stream(Spliterators.spliteratorUnknownSize(this, Spliterator.ORDERED), false);\\n    }\\n\\n    public boolean hasNext() {\\n        if (this.queue.peek() == null && !this.reader.isFinished())\\n        {\\n            this.queue.addAll(this.reader.readCheckedObjects());\\n        }\\n        if (this.queue.peek() == null)\\n        {\\n            this.close();\\n        }\\n        return this.queue.peek() != null;\\n    }\\n\\n    public _S_Person next() {\\n        if (!this.hasNext())\\n        {\\n            throw new NoSuchElementException(\\\"End of stream has passed\\\");\\n        }\\n        org.finos.legend.engine.plan.dependencies.domain.dataQuality.IChecked<_S_Person> nextValue = this.queue.remove();\\n        if (!nextValue.getDefects().isEmpty())\\n        {\\n            throw new IllegalStateException(nextValue.getDefects().stream().map((IDefect d) -> d.getMessage()).filter((String x) -> x != null).collect(Collectors.joining(\\\"\\\\n\\\")));\\n        }\\n        else if (nextValue.getValue() == null)\\n        {\\n            throw new IllegalStateException(\\\"Unexpected error: no object and no defects\\\");\\n        }\\n        if (nextValue.getValue() instanceof Constrained)\\n        {\\n            return ((Constrained<_S_Person>) nextValue.getValue()).withConstraintsApplied();\\n        }\\n        else\\n        {\\n            return nextValue.getValue();\\n        }\\n    }\\n\\n    public void close() {\\n        this.reader.destroyReading();\\n    }\\n}\\n\"},{\"package\":\"plan.root.n1\",\"name\":\"JsonDataReader_meta_pure_mapping_modelToModel_test_shared_src__S_Person\",\"source\":\"package plan.root.n1;\\n\\nimport _pure.app.meta.pure.mapping.modelToModel.test.shared.src._S_Person;\\nimport com.fasterxml.jackson.core.JsonFactory;\\nimport com.fasterxml.jackson.core.JsonParser;\\nimport com.fasterxml.jackson.core.JsonToken;\\nimport com.fasterxml.jackson.databind.JsonNode;\\nimport com.fasterxml.jackson.databind.ObjectMapper;\\nimport com.fasterxml.jackson.databind.node.JsonNodeType;\\nimport org.finos.legend.engine.plan.dependencies.domain.dataQuality.Constrained;\\nimport org.finos.legend.engine.plan.dependencies.domain.dataQuality.EnforcementLevel;\\nimport org.finos.legend.engine.plan.dependencies.domain.dataQuality.GraphContext;\\nimport org.finos.legend.engine.plan.dependencies.domain.dataQuality.IChecked;\\nimport org.finos.legend.engine.plan.dependencies.domain.dataQuality.IDefect;\\nimport org.finos.legend.engine.plan.dependencies.domain.dataQuality.RelativePathNode;\\nimport org.finos.legend.engine.plan.dependencies.domain.dataQuality.RuleType;\\nimport org.finos.legend.engine.plan.dependencies.domain.date.DayOfWeek;\\nimport org.finos.legend.engine.plan.dependencies.domain.date.DurationUnit;\\nimport org.finos.legend.engine.plan.dependencies.util.Library;\\nimport org.finos.legend.engine.plan.dependencies.domain.date.PureDate;\\nimport java.io.*;\\nimport java.lang.reflect.InvocationTargetException;\\nimport java.lang.reflect.Method;\\nimport java.math.*;\\nimport java.net.*;\\nimport java.util.*;\\nimport java.util.function.*;\\nimport java.util.stream.*;\\n\\npublic class JsonDataReader_meta_pure_mapping_modelToModel_test_shared_src__S_Person implements org.finos.legend.engine.plan.dependencies.store.inMemory.IStoreStreamReader {\\n\\n    private boolean finishedReading = false;\\n\\n    private Stack<Object> stack = new Stack<Object>();\\n\\n    private JsonParser parser;\\n\\n    private ObjectMapper objectMapper;\\n\\n    private boolean inArray = false;\\n\\n    private long recordCount = 0;\\n\\n    private InputStream in;\\n\\n    JsonDataReader_meta_pure_mapping_modelToModel_test_shared_src__S_Person(InputStream in) {\\n        this.in = in;\\n    }\\n\\n    public void initReading() {\\n        try\\n        {\\n            this.parser = new JsonFactory().createParser(this.in);\\n            this.objectMapper = new ObjectMapper();\\n        }\\n        catch (IOException e)\\n        {\\n            throw new RuntimeException(e);\\n        }\\n    }\\n\\n    private boolean readMethodExists(String name) {\\n        Method[] methods = this.getClass().getDeclaredMethods();\\n        for (int i = 0; i < methods.length; i++) {\\n           if (methods[i].getName().equals(name)) return true;\\n        };\\n        return false;\\n    }\\n\\n    private Object readMethodInvoke(String name, JsonNode node) {\\n        Method m = null;\\n        try{\\n           m = this.getClass().getMethod(name, JsonNode.class);\\n        }\\n        catch (NoSuchMethodException e){throw new RuntimeException(e.getMessage());}\\n        try{\\n           return m.invoke(this, node);\\n        }\\n        catch (IllegalAccessException e){throw new RuntimeException(e.getMessage());}catch (InvocationTargetException e){throw new RuntimeException(e.getMessage());}\\n    }\\n\\n    public void destroyReading() {\\n        if (this.parser.isClosed())\\n        {\\n           return;\\n        }\\n        try\\n        {\\n            this.parser.close();\\n        }\\n        catch (IOException e)\\n        {\\n            throw new RuntimeException(e);\\n        }\\n    }\\n\\n    public boolean isFinished() {\\n        nextToken();\\n        if (!this.finishedReading && getCurrentToken() == JsonToken.START_ARRAY && !inArray)\\n        {\\n            nextToken();\\n            inArray = true;\\n        }\\n        if (!this.finishedReading && getCurrentToken() == JsonToken.END_ARRAY && inArray)\\n        {\\n            nextToken();\\n            inArray = false;\\n            this.finishedReading = true;\\n        }\\n        this.finishedReading |= getCurrentToken() == null;\\n        return this.finishedReading ;\\n    }\\n\\n    public void nextToken() {\\n            try\\n            {\\n                this.parser.nextToken();\\n            }\\n            catch (IOException e)\\n            {\\n                throw new RuntimeException(e);\\n            }\\n    }\\n\\n    public IChecked<_S_Person> read_meta_pure_mapping_modelToModel_test_shared_src__S_Person(JsonNode node) {\\n        if (!node.path(\\\"@type\\\").getNodeType().equals(JsonNodeType.MISSING) && !node.path(\\\"@type\\\").textValue().equals(\\\"meta::pure::mapping::modelToModel::test::shared::src::_S_Person\\\")){\\n           String methodName = \\\"read_\\\" + node.path(\\\"@type\\\").textValue().replace(\\\"::\\\", \\\"_\\\");\\n           if (readMethodExists(methodName)){\\n              return (IChecked) readMethodInvoke(methodName, node);\\n           }\\n        }\\n        List<IDefect> defects = new ArrayList<>();\\n        \\n        List<String> _fullName = new ArrayList<>();\\n        \\n        this.stack.push(new plan.root.n1.meta_pure_mapping_modelToModel_test_shared_src__S_Person_Impl());\\n        \\n        if (node.path(\\\"fullName\\\").getNodeType() != JsonNodeType.MISSING){\\n        _fullName = acceptMany(node.path(\\\"fullName\\\"), this::acceptString,m -> defects.add(org.finos.legend.engine.plan.dependencies.domain.dataQuality.BasicDefect.newInvalidInputErrorDefect(\\\"fullName\\\"+\\\": \\\"+m,\\\"meta::pure::mapping::modelToModel::test::shared::src::_S_Person\\\")));\\n        }\\n        if (_fullName.size() != 1)\\n        {\\n          defects.add(org.finos.legend.engine.plan.dependencies.domain.dataQuality.BasicDefect.newClassStructureDefect(\\\"Invalid multiplicity for fullName: expected [1] found [\\\" + _fullName.size() + \\\"]\\\", \\\"meta::pure::mapping::modelToModel::test::shared::src::_S_Person\\\"));\\n        }\\n        \\n        if (defects.stream().anyMatch(d -> d.getEnforcementLevel() == EnforcementLevel.Critical))\\n        {\\n            return new IChecked<_S_Person>() {\\n            public List<IDefect> getDefects() { return defects; }\\n            public Object getSource() { return null; }\\n            public _S_Person getValue() { return null; }\\n        };\\n        }\\n        else\\n        {\\n        ((plan.root.n1.meta_pure_mapping_modelToModel_test_shared_src__S_Person_Impl) this.stack.peek()).fullName = _fullName.get(0);\\n            _S_Person value = (_S_Person) this.stack.pop();\\n            return new IChecked<_S_Person>() {\\n            public List<IDefect> getDefects() { return defects; }\\n            public Object getSource() { return null; }\\n            public _S_Person getValue() { return value; }\\n        };\\n        }\\n    }\\n\\n    private String acceptString(JsonNode node) {\\n        try\\n        {\\n            String errorMessage = \\\"Unexpected node type:\\\" + node.getNodeType() + \\\" for PURE String\\\";\\n            this.check(Arrays.asList(JsonNodeType.valueOf(\\\"STRING\\\")), node.getNodeType(), errorMessage);\\n            return node.textValue();\\n        }\\n        catch (IllegalArgumentException ex)\\n        {\\n            throw new org.finos.legend.engine.plan.dependencies.store.inMemory.DataParsingException(ex.getMessage());\\n        }\\n    }\\n\\n    private boolean acceptBoolean(JsonNode node) {\\n        try\\n        {\\n            String errorMessage = \\\"Unexpected node type:\\\" + node.getNodeType() + \\\" for PURE Boolean\\\";\\n            this.check(Arrays.asList(JsonNodeType.valueOf(\\\"BOOLEAN\\\")), node.getNodeType(), errorMessage);\\n            return node.booleanValue();\\n        }\\n        catch (IllegalArgumentException ex)\\n        {\\n            throw new org.finos.legend.engine.plan.dependencies.store.inMemory.DataParsingException(ex.getMessage());\\n        }\\n    }\\n\\n    private long acceptInteger(JsonNode node) {\\n        try\\n        {\\n            String errorMessage = \\\"Unexpected node type:\\\" + node.getNodeType() + \\\" for PURE Integer\\\";\\n            this.check(Arrays.asList(JsonNodeType.valueOf(\\\"NUMBER\\\")), node.getNodeType(), errorMessage);\\n            return node.longValue();\\n        }\\n        catch (IllegalArgumentException ex)\\n        {\\n            throw new org.finos.legend.engine.plan.dependencies.store.inMemory.DataParsingException(ex.getMessage());\\n        }\\n    }\\n\\n    private double acceptFloat(JsonNode node) {\\n        try\\n        {\\n            String errorMessage = \\\"Unexpected node type:\\\" + node.getNodeType() + \\\" for PURE Float\\\";\\n            this.check(Arrays.asList(JsonNodeType.valueOf(\\\"NUMBER\\\")), node.getNodeType(), errorMessage);\\n            return node.doubleValue();\\n        }\\n        catch (IllegalArgumentException ex)\\n        {\\n            throw new org.finos.legend.engine.plan.dependencies.store.inMemory.DataParsingException(ex.getMessage());\\n        }\\n    }\\n\\n    private BigDecimal acceptDecimal(JsonNode node) {\\n        try\\n        {\\n            String errorMessage = \\\"Unexpected node type:\\\" + node.getNodeType() + \\\" for PURE Decimal\\\";\\n            this.check(Arrays.asList(JsonNodeType.valueOf(\\\"STRING\\\"), JsonNodeType.valueOf(\\\"NUMBER\\\")), node.getNodeType(), errorMessage);\\n            return node.getNodeType().equals(JsonNodeType.STRING) ? new BigDecimal(node.textValue()) : node.decimalValue();\\n        }\\n        catch (IllegalArgumentException ex)\\n        {\\n            throw new org.finos.legend.engine.plan.dependencies.store.inMemory.DataParsingException(ex.getMessage());\\n        }\\n    }\\n\\n    private Number acceptNumber(JsonNode node) {\\n        try\\n        {\\n            String errorMessage = \\\"Unexpected node type:\\\" + node.getNodeType() + \\\" for PURE Number\\\";\\n            this.check(Arrays.asList(JsonNodeType.valueOf(\\\"STRING\\\"), JsonNodeType.valueOf(\\\"NUMBER\\\")), node.getNodeType(), errorMessage);\\n            return node.getNodeType().equals(JsonNodeType.STRING) ? (Number) new BigDecimal(node.textValue()) : node.isDouble() == true ? node.doubleValue() : node.longValue();\\n        }\\n        catch (IllegalArgumentException ex)\\n        {\\n            throw new org.finos.legend.engine.plan.dependencies.store.inMemory.DataParsingException(ex.getMessage());\\n        }\\n    }\\n\\n    private PureDate acceptStrictDate(JsonNode node) {\\n        try\\n        {\\n            String errorMessage = \\\"Unexpected node type:\\\" + node.getNodeType() + \\\" for PURE StrictDate\\\";\\n            this.check(Arrays.asList(JsonNodeType.valueOf(\\\"STRING\\\")), node.getNodeType(), errorMessage);\\n            return PureDate.parsePureDate(node.textValue());\\n        }\\n        catch (IllegalArgumentException ex)\\n        {\\n            throw new org.finos.legend.engine.plan.dependencies.store.inMemory.DataParsingException(ex.getMessage());\\n        }\\n    }\\n\\n    private PureDate acceptDateTime(JsonNode node) {\\n        try\\n        {\\n            String errorMessage = \\\"Unexpected node type:\\\" + node.getNodeType() + \\\" for PURE DateTime\\\";\\n            this.check(Arrays.asList(JsonNodeType.valueOf(\\\"STRING\\\")), node.getNodeType(), errorMessage);\\n            return PureDate.parsePureDate(node.textValue());\\n        }\\n        catch (IllegalArgumentException ex)\\n        {\\n            throw new org.finos.legend.engine.plan.dependencies.store.inMemory.DataParsingException(ex.getMessage());\\n        }\\n    }\\n\\n    private PureDate acceptDate(JsonNode node) {\\n        try\\n        {\\n            String errorMessage = \\\"Unexpected node type:\\\" + node.getNodeType() + \\\" for PURE Date\\\";\\n            this.check(Arrays.asList(JsonNodeType.valueOf(\\\"STRING\\\")), node.getNodeType(), errorMessage);\\n            return PureDate.parsePureDate(node.textValue());\\n        }\\n        catch (IllegalArgumentException ex)\\n        {\\n            throw new org.finos.legend.engine.plan.dependencies.store.inMemory.DataParsingException(ex.getMessage());\\n        }\\n    }\\n\\n    private <T> List<T> acceptMany(JsonNode node, Function<JsonNode, T> acceptor, Consumer<String> defectRecorder) {\\n        java.util.List<T> result = new java.util.ArrayList<T>();\\n        if (node.isNull())\\n        {\\n            return result;\\n        }\\n        if (node.isArray())\\n        {\\n            for (com.fasterxml.jackson.databind.JsonNode n: node)\\n            {\\n                try\\n                {\\n                    result.add(acceptor.apply(n));\\n                }\\n                catch (org.finos.legend.engine.plan.dependencies.store.inMemory.DataParsingException ex)\\n                {\\n                    defectRecorder.accept(ex.getMessage());\\n                }\\n            }\\n        }\\n        else\\n        {\\n            try\\n            {\\n                result.add(acceptor.apply(node));\\n            }\\n            catch (org.finos.legend.engine.plan.dependencies.store.inMemory.DataParsingException ex)\\n            {\\n                defectRecorder.accept(ex.getMessage());\\n            }\\n        }\\n        return result;\\n    }\\n\\n    private JsonToken getCurrentToken() {\\n        return parser.getCurrentToken();\\n    }\\n\\n    private void check(JsonNodeType expectedNode, JsonNodeType currentNode) {\\n        check(expectedNode, currentNode, \\\"Failed to parse JSON, expected '\\\" + expectedNode + \\\"', Found \\\" + currentNode);\\n    }\\n\\n    private void check(JsonNodeType expectedNode, JsonNodeType currentNode, String errorMessage) {\\n        check(Collections.singletonList(expectedNode), currentNode, errorMessage);\\n    }\\n\\n    private void check(List<JsonNodeType> expectedNodes, JsonNodeType currentNode, String errorMessage) {\\n        if (!expectedNodes.contains(currentNode))\\n        {\\n            throw new org.finos.legend.engine.plan.dependencies.store.inMemory.DataParsingException(errorMessage);\\n        }\\n    }\\n\\n    public Collection<IChecked<_S_Person>> readCheckedObjects() {\\n        try\\n        {\\n            this.recordCount++;\\n            JsonNode node = this.objectMapper.readValue(this.parser, JsonNode.class);\\n            IChecked<_S_Person> object = this.read_meta_pure_mapping_modelToModel_test_shared_src__S_Person(node);\\n            long recordNumber = this.recordCount;\\n            String json = node.toString();\\n            _pure.app.meta.pure.mapping.modelToModel.JsonDataRecord source = new _pure.app.meta.pure.mapping.modelToModel.JsonDataRecord()\\n            {\\n                public long getNumber()\\n                {\\n                    return recordNumber;\\n                }\\n                public String getRecord()\\n                {\\n                    return json;\\n                }\\n            };\\n            return Collections.singleton(new IChecked<_S_Person>()\\n            {\\n                public List<IDefect> getDefects()\\n                {\\n                    return object.getDefects();\\n                }\\n                public Object getSource()\\n                {\\n                    return source;\\n                }\\n                public _S_Person getValue()\\n                {\\n                    return object.getValue();\\n                }\\n            });\\n        }\\n        catch (IOException e)\\n        {\\n            throw new RuntimeException(e);\\n        }\\n    }\\n}\\n\"},{\"package\":\"plan.root.n1\",\"name\":\"meta_pure_mapping_modelToModel_test_shared_src__S_Person_Impl\",\"source\":\"package plan.root.n1;\\n\\nimport _pure.app.meta.pure.mapping.modelToModel.test.shared.src._S_Person;\\nimport org.finos.legend.engine.plan.dependencies.domain.dataQuality.Constrained;\\nimport org.finos.legend.engine.plan.dependencies.domain.dataQuality.EnforcementLevel;\\nimport org.finos.legend.engine.plan.dependencies.domain.dataQuality.GraphContext;\\nimport org.finos.legend.engine.plan.dependencies.domain.dataQuality.IDefect;\\nimport org.finos.legend.engine.plan.dependencies.domain.dataQuality.RelativePathNode;\\nimport org.finos.legend.engine.plan.dependencies.domain.dataQuality.RuleType;\\nimport org.finos.legend.engine.plan.dependencies.domain.date.DayOfWeek;\\nimport org.finos.legend.engine.plan.dependencies.domain.date.DurationUnit;\\nimport org.finos.legend.engine.plan.dependencies.util.Library;\\nimport org.finos.legend.engine.plan.dependencies.domain.date.PureDate;\\nimport java.math.*;\\nimport java.util.*;\\nimport java.util.function.*;\\nimport java.util.stream.*;\\n\\nclass meta_pure_mapping_modelToModel_test_shared_src__S_Person_Impl implements _S_Person, org.finos.legend.engine.plan.dependencies.store.shared.IReferencedObject, org.finos.legend.engine.plan.dependencies.domain.dataQuality.Constrained<_pure.app.meta.pure.mapping.modelToModel.test.shared.src._S_Person> {\\n\\n    String fullName;\\n\\n    meta_pure_mapping_modelToModel_test_shared_src__S_Person_Impl() {\\n        \\n    }\\n\\n    public String getFullName() {\\n        return this.fullName;\\n    }\\n\\n    public String getAlloyStoreObjectReference$() {\\n        return null;\\n    }\\n\\n    public List<IDefect> allConstraints() {\\n        return allConstraints(new GraphContext());\\n    }\\n\\n    public List<IDefect> allConstraints(GraphContext context) {\\n        List<IDefect> result = new ArrayList<>();\\n        if (!context.visited.contains(this))\\n        {\\n            context.visited.add(this);\\n        }\\n        return result;\\n    }\\n\\n    public _S_Person withConstraintsApplied() {\\n        List<IDefect> defects = allConstraints();\\n        if (!defects.isEmpty())\\n        {\\n            throw new IllegalStateException(defects.stream().map(IDefect::getMessage).collect(Collectors.joining(\\\"\\\\n\\\")));\\n        }\\n        return this;\\n    }\\n\\n    public org.finos.legend.engine.plan.dependencies.domain.dataQuality.IChecked<_S_Person> toChecked() {\\n        return this.toChecked(null, true);\\n    }\\n\\n    public org.finos.legend.engine.plan.dependencies.domain.dataQuality.IChecked<_S_Person> toChecked(boolean applyConstraints) {\\n        return this.toChecked(null, applyConstraints);\\n    }\\n\\n    public org.finos.legend.engine.plan.dependencies.domain.dataQuality.IChecked<_S_Person> toChecked(Object source) {\\n        return this.toChecked(source, true);\\n    }\\n\\n    public org.finos.legend.engine.plan.dependencies.domain.dataQuality.IChecked<_S_Person> toChecked(Object source, boolean applyConstraints) {\\n        List<IDefect> defects = applyConstraints ? allConstraints() : Collections.emptyList();\\n        return new org.finos.legend.engine.plan.dependencies.domain.dataQuality.IChecked<_S_Person>() {\\n            public List<IDefect> getDefects() { return defects; }\\n            public Object getSource() { return source; }\\n            public _S_Person getValue() { return meta_pure_mapping_modelToModel_test_shared_src__S_Person_Impl.this; }\\n        };\\n    }\\n}\\n\"}],\"_type\":\"java\"},\"authDependent\":false,\"serializer\":{\"name\":\"pure\",\"version\":\"vX_X_X\"}}";
    Result result = PlanExecutor.newPlanExecutor(InMemory.build()).execute(json);
    JsonStreamToJsonDefaultSerializer jsonStreamToJsonDefaultSerializer = new JsonStreamToJsonDefaultSerializer(((JsonStreamingResult) result));
    OutputStream outputStream = new ByteArrayOutputStream();
    jsonStreamToJsonDefaultSerializer.stream(outputStream);
    assertEquals("{\"builder\":{\"_type\":\"json\"},\"values\":[{\"firstName\":\"Johny\",\"lastName\":\"Doe\"},{\"firstName\":\"Jane\",\"lastName\":\"Doe\"}]}", outputStream.toString());
}
Also used : JsonStreamingResult(org.finos.legend.engine.plan.execution.result.json.JsonStreamingResult) OutputStream(java.io.OutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) JsonStreamToJsonDefaultSerializer(org.finos.legend.engine.plan.execution.result.json.JsonStreamToJsonDefaultSerializer) Result(org.finos.legend.engine.plan.execution.result.Result) JsonStreamingResult(org.finos.legend.engine.plan.execution.result.json.JsonStreamingResult) Test(org.junit.Test)

Aggregations

JsonStreamToJsonDefaultSerializer (org.finos.legend.engine.plan.execution.result.json.JsonStreamToJsonDefaultSerializer)8 JsonStreamingResult (org.finos.legend.engine.plan.execution.result.json.JsonStreamingResult)8 Test (org.junit.Test)6 Result (org.finos.legend.engine.plan.execution.result.Result)5 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 OutputStream (java.io.OutputStream)4 PlanExecutionContext (org.finos.legend.engine.plan.execution.PlanExecutionContext)3 SingleExecutionPlan (org.finos.legend.engine.protocol.pure.v1.model.executionPlan.SingleExecutionPlan)3 GraphFetchCacheByEqualityKeys (org.finos.legend.engine.plan.execution.cache.graphFetch.GraphFetchCacheByEqualityKeys)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 ConstantResult (org.finos.legend.engine.plan.execution.result.ConstantResult)1 KerberosProfile (org.finos.legend.server.pac4j.kerberos.KerberosProfile)1