diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/HelperModelBuilder.java b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/HelperModelBuilder.java index b89f19d4120..b65beea2ab9 100644 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/HelperModelBuilder.java +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/HelperModelBuilder.java @@ -80,7 +80,7 @@ public static org.eclipse.collections.api.block.function.Function lambdaFunction = HelperValueSpecificationBuilder.buildLambda(Collections.singletonList(property.defaultValue.value), Collections.emptyList(), context); - defaultValue = new Root_meta_pure_metamodel_function_property_DefaultValue_Impl(null, SourceInformationHelper.toM3SourceInformation(property.defaultValue.sourceInformation), null); + defaultValue = new Root_meta_pure_metamodel_function_property_DefaultValue_Impl(null, SourceInformationHelper.toM3SourceInformation(property.defaultValue.sourceInformation), context.pureModel.getClass("meta::pure::metamodel::function::property::DefaultValue")); defaultValue._functionDefinition(lambdaFunction); } GenericType returnGenericType = context.resolveGenericType(property.type, property.propertyTypeSourceInformation); diff --git a/legend-engine-pure/legend-engine-pure-ide/legend-engine-pure-ide-light-http-server/README.md b/legend-engine-pure/legend-engine-pure-ide/legend-engine-pure-ide-light-http-server/README.md index ff252271d2c..c13a8aa6e31 100644 --- a/legend-engine-pure/legend-engine-pure-ide/legend-engine-pure-ide-light-http-server/README.md +++ b/legend-engine-pure/legend-engine-pure-ide/legend-engine-pure-ide-light-http-server/README.md @@ -8,7 +8,7 @@ Pure IDE Light is a development environment for Pure, the language underlying th From the root of legend-engine, run the following to launch the Pure IDE Light server. ``` -mvn -pl legend-engine-pure-ide-light exec:java -Dexec.mainClass="org.finos.legend.engine.ide.PureIDELight" -Dexec.args="server ./legend-engine-pure-ide-light/src/main/resources/ideLightConfig.json" +mvn -pl legend-engine-pure/legend-engine-pure-ide/legend-engine-pure-ide-light-http-server exec:java -Dexec.mainClass="org.finos.legend.engine.ide.PureIDELight" -Dexec.args="server ./legend-engine-pure/legend-engine-pure-ide/legend-engine-pure-ide-light-http-server/src/main/resources/ideLightConfig.json" ``` Then navigate to http://127.0.0.1/ide diff --git a/legend-engine-pure/legend-engine-pure-ide/legend-engine-pure-ide-light-http-server/pom.xml b/legend-engine-pure/legend-engine-pure-ide/legend-engine-pure-ide-light-http-server/pom.xml index 1b763bc9fad..8f76d64a530 100644 --- a/legend-engine-pure/legend-engine-pure-ide/legend-engine-pure-ide-light-http-server/pom.xml +++ b/legend-engine-pure/legend-engine-pure-ide/legend-engine-pure-ide-light-http-server/pom.xml @@ -260,6 +260,16 @@ org.finos.legend.engine legend-engine-pure-runtime-java-extension-interpreted-functions-legendCompiler + + org.finos.legend.engine + legend-engine-pure-runtime-java-extension-interpreted-functions-javaCompiler + runtime + + + org.finos.legend.engine + legend-engine-pure-runtime-java-extension-compiled-functions-javaCompiler + runtime + org.finos.legend.engine diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/pom.xml b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/pom.xml index 02070a08d1a..ebc2b017b97 100644 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/pom.xml +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/pom.xml @@ -44,10 +44,6 @@ org.eclipse.collections eclipse-collections-api - - org.finos.legend.engine - legend-engine-pure-code-compiled-core - org.finos.legend.engine legend-engine-xt-changetoken-pure diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/main/java/org/finos/legend/engine/changetoken/generation/GenerateDiff.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/main/java/org/finos/legend/engine/changetoken/generation/GenerateDiff.java index 63bcbcd3163..2793b3383f7 100644 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/main/java/org/finos/legend/engine/changetoken/generation/GenerateDiff.java +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/main/java/org/finos/legend/engine/changetoken/generation/GenerateDiff.java @@ -81,20 +81,6 @@ public GenerateDiff(List newEntities, List allTypes = pureModel.getModelClasses().collect(a -> - core_pure_corefunctions_metaExtension.Root_meta_pure_functions_meta_fullPackageName_PackageableElement_1__String_1__String_1_((org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.PackageableElement) a, "::", pureModel.getExecutionSupport())).toSet(); - MutableList javaSources = Lists.mutable.empty(); - javaSources.addAllIterable(javaSourceCodeGenerator.generatePureCoreHelperClasses(javaSourceCodeGenerator.getProcessorContext())); - javaSources.addAllIterable(javaSourceCodeGenerator.generateCode(allTypes)); - try - { - compiler.compile(javaSources); - } - catch (PureJavaCompileException e) - { - throw new RuntimeException(e); - } } private static PureMap toPureMap(Map objectNode) diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCast2Test.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCast2Test.java deleted file mode 100644 index a2db314b027..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCast2Test.java +++ /dev/null @@ -1,112 +0,0 @@ -// Copyright 2023 Goldman Sachs -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCast2Test extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::AddField\",\n" + - " \"fieldName\": \"abc\",\n" + - " \"fieldType\": \"Integer[1]\",\n" + - " \"defaultValue\": {\n" + - " \"@type\": \"meta::pure::changetoken::CopyValue\",\n" + - " \"source\": {\n" + - " \"@type\": \"meta::pure::changetoken::RelativeFieldReference\",\n" + - " \"path\": \"../existingValue\"\n" + - " }\n" + - " },\n" + - " \"safeCast\": true,\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\": \"ftdm:abcdefg123\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SomeClassWithAnArray\",\n" + - " \"array\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::tests::OuterClass\",\n" + - " \"existingValue\": \"someValue\",\n" + - " \"innerObject\": {\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " }\n" + - " ]\n" + - "}\n"), - "{\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SomeClassWithAnArray\",\n" + - " \"array\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::tests::OuterClass\",\n" + - " \"existingValue\": \"someValue\",\n" + - " \"innerObject\": {\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"abc\": \"someValue\"\n" + - " }\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::OuterClass\",\n" + - " \"existingValue\": \"someValue\",\n" + - " \"innerObject\": {\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"abc\": \"someValue\"\n" + - " }\n" + - "}\n", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::OuterClass\",\n" + - " \"existingValue\": \"someValue\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}\n" + - "}\n"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCast3Test.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCast3Test.java deleted file mode 100644 index bcf81fec6c3..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCast3Test.java +++ /dev/null @@ -1,119 +0,0 @@ -// Copyright 2023 Goldman Sachs -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCast3Test extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::ChangeFieldType\",\n" + - " \"fieldName\": \"abc\",\n" + - " \"oldFieldType\": \"Integer[1]\",\n" + - " \"newFieldType\": \"String[1]\",\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\": \"ftdm:abcdefg123\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SomeClassWithAnArray\",\n" + - " \"array\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::tests::OuterClass\",\n" + - " \"existingValue\": \"someValue\",\n" + - " \"innerObject\": {\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"abc\": 123\n" + - " }\n" + - " }\n" + - " ]\n" + - "}\n"), - "{\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SomeClassWithAnArray\",\n" + - " \"array\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::tests::OuterClass\",\n" + - " \"existingValue\": \"someValue\",\n" + - " \"innerObject\": {\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"abc\": \"123\"\n" + - " }\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SomeClassWithAnArray\",\n" + - " \"array\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::tests::OuterClass\",\n" + - " \"existingValue\": \"someValue\",\n" + - " \"innerObject\": {\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"abc\": \"123\"\n" + - " }\n" + - " }\n" + - " ]\n" + - "}\n", "ftdm:abcdefg123"), - "{\n" + - " \"version\": \"ftdm:abcdefg123\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SomeClassWithAnArray\",\n" + - " \"array\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::tests::OuterClass\",\n" + - " \"existingValue\": \"someValue\",\n" + - " \"innerObject\": {\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"abc\": 123\n" + - " }\n" + - " }\n" + - " ]\n" + - "}\n"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCast4Test.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCast4Test.java deleted file mode 100644 index 44440ecbb1f..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCast4Test.java +++ /dev/null @@ -1,119 +0,0 @@ -// Copyright 2023 Goldman Sachs -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCast4Test extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::ChangeFieldType\",\n" + - " \"fieldName\": \"abc\",\n" + - " \"oldFieldType\": \"String[1]\",\n" + - " \"newFieldType\": \"String[0..1]\",\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\": \"ftdm:abcdefg123\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SomeClassWithAnArray\",\n" + - " \"array\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::tests::OuterClass\",\n" + - " \"existingValue\": \"someValue\",\n" + - " \"innerObject\": {\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"abc\": 123\n" + - " }\n" + - " }\n" + - " ]\n" + - "}\n"), - "{\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SomeClassWithAnArray\",\n" + - " \"array\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::tests::OuterClass\",\n" + - " \"existingValue\": \"someValue\",\n" + - " \"innerObject\": {\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"abc\": 123\n" + - " }\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SomeClassWithAnArray\",\n" + - " \"array\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::tests::OuterClass\",\n" + - " \"existingValue\": \"someValue\",\n" + - " \"innerObject\": {\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"abc\": \"123\"\n" + - " }\n" + - " }\n" + - " ]\n" + - "}\n", "ftdm:abcdefg123"), - "{\n" + - " \"version\": \"ftdm:abcdefg123\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SomeClassWithAnArray\",\n" + - " \"array\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::tests::OuterClass\",\n" + - " \"existingValue\": \"someValue\",\n" + - " \"innerObject\": {\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"abc\": \"123\"\n" + - " }\n" + - " }\n" + - " ]\n" + - "}\n"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastBooleanStringTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastBooleanStringTest.java deleted file mode 100644 index f1218adb444..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastBooleanStringTest.java +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright 2023 Goldman Sachs -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastBooleanStringTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::AddField\",\n" + - " \"fieldName\": \"abc\",\n" + - " \"fieldType\": \"Boolean[1]\",\n" + - " \"defaultValue\": {\n" + - " \"@type\": \"meta::pure::changetoken::ConstValue\",\n" + - " \"value\": \"true\"\n" + - " },\n" + - " \"safeCast\": true,\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": true},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": true},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": true}]\n" + - " ],\n" + - " \"abc\": true\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": true},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": true},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": true}]\n" + - " ],\n" + - " \"abc\": true\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNonDefault() throws JsonProcessingException, NoSuchMethodException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": true},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": true},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": true}]\n" + - " ],\n" + - " \"abc\": false\n" + - "}", "ftdm:abcdefg123"), - "Cannot remove non-default value:false"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastBooleanTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastBooleanTest.java deleted file mode 100644 index 73af6a72109..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastBooleanTest.java +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright 2023 Goldman Sachs -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastBooleanTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::AddField\",\n" + - " \"fieldName\": \"abc\",\n" + - " \"fieldType\": \"Boolean[1]\",\n" + - " \"defaultValue\": {\n" + - " \"@type\": \"meta::pure::changetoken::ConstValue\",\n" + - " \"value\": true\n" + - " },\n" + - " \"safeCast\": true,\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": true},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": true},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": true}]\n" + - " ],\n" + - " \"abc\": true\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": true},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": true},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": true}]\n" + - " ],\n" + - " \"abc\": true\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNonDefault() throws JsonProcessingException, NoSuchMethodException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": true},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": true},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": true}]\n" + - " ],\n" + - " \"abc\": false\n" + - "}", "ftdm:abcdefg123"), - "Cannot remove non-default value:false"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastChainTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastChainTest.java deleted file mode 100644 index bf8d11307e0..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastChainTest.java +++ /dev/null @@ -1,150 +0,0 @@ -// Copyright 2023 Goldman Sachs -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; -import java.util.Arrays; -import java.util.List; - -public class GenerateCastChainTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::AddField\",\n" + - " \"fieldName\": \"abc\",\n" + - " \"fieldType\": \"Integer[1]\",\n" + - " \"defaultValue\": {\n" + - " \"@type\": \"meta::pure::changetoken::ConstValue\",\n" + - " \"value\": 100\n" + - " },\n" + - " \"safeCast\": true,\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg789\",\n" + - " \"prevVersion\": \"ftdm:abcdefg456\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::AddField\",\n" + - " \"fieldName\": \"def\",\n" + - " \"fieldType\": \"Integer[1]\",\n" + - " \"defaultValue\": {\n" + - " \"@type\": \"meta::pure::changetoken::ConstValue\",\n" + - " \"value\": 200\n" + - " },\n" + - " \"safeCast\": true,\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testVersions() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - List versions = (List) compiledClass.getMethod("versions").invoke(null); - List expected = Arrays.asList("ftdm:abcdefg123", "ftdm:abcdefg456", "ftdm:abcdefg789"); - Assert.assertEquals(expected, versions); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg789\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100, \"def\": 200},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100, \"def\": 200},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100, \"def\": 200}]\n" + - " ],\n" + - " \"abc\": 100, \"def\": 200\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg789\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100, \"def\": 200},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100, \"def\": 200},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100, \"def\": 200}]\n" + - " ],\n" + - " \"abc\": 100, \"def\": 200\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNonDefault() throws JsonProcessingException, NoSuchMethodException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg789\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100, \"def\": 200},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100, \"def\": 200},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100, \"def\": 200}]\n" + - " ],\n" + - " \"abc\": 100, \"def\": 300\n" + - "}", "ftdm:abcdefg123"), - "Cannot remove non-default value:300"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomArrayBooleanTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomArrayBooleanTest.java deleted file mode 100644 index 301c0d38cd3..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomArrayBooleanTest.java +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright 2024 Goldman Sachs -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastCustomArrayBooleanTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::AddField\",\n" + - " \"fieldName\": \"abc\",\n" + - " \"fieldType\": \"Boolean[*]\",\n" + - " \"defaultValue\": {\n" + - " \"@type\": \"meta::pure::changetoken::ConstValue\",\n" + - " \"value\": [true]\n" + - " },\n" + - " \"safeCast\": true,\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [true]},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [true]},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [true]}]\n" + - " ],\n" + - " \"abc\": [true]\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [true]},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [true]},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [true]}]\n" + - " ],\n" + - " \"abc\": [true]\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNonDefault() throws JsonProcessingException, NoSuchMethodException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [true]},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [true]},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [true]}]\n" + - " ],\n" + - " \"abc\":[false]\n" + - "}", "ftdm:abcdefg123"), - "Cannot remove non-default value:[false]"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomArrayEmbeddedTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomArrayEmbeddedTest.java deleted file mode 100644 index 9f857cee3df..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomArrayEmbeddedTest.java +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright 2024 Goldman Sachs -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastCustomArrayEmbeddedTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::AddField\",\n" + - " \"fieldName\": \"abc\",\n" + - " \"fieldType\": \"Integer[*]\",\n" + - " \"defaultValue\": {\n" + - " \"@type\": \"meta::pure::changetoken::ConstValue\",\n" + - " \"value\": \"[1,2,3]\"\n" + - " },\n" + - " \"safeCast\": true,\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1,2,3]},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1,2,3]},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1,2,3]}]\n" + - " ],\n" + - " \"abc\": [1,2,3]\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1,2,3]},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1,2,3]},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1,2,3]}]\n" + - " ],\n" + - " \"abc\": [1,2,3]\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNonDefault() throws JsonProcessingException, NoSuchMethodException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1,2,3]},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1,2,3]},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1,2,3]}]\n" + - " ],\n" + - " \"abc\":[5,6,7]\n" + - "}", "ftdm:abcdefg123"), - "Cannot remove non-default value:[5, 6, 7]"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomArrayFloatTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomArrayFloatTest.java deleted file mode 100644 index 73261130073..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomArrayFloatTest.java +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright 2024 Goldman Sachs -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastCustomArrayFloatTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::AddField\",\n" + - " \"fieldName\": \"abc\",\n" + - " \"fieldType\": \"Float[*]\",\n" + - " \"defaultValue\": {\n" + - " \"@type\": \"meta::pure::changetoken::ConstValue\",\n" + - " \"value\": [1.2, 3.4]\n" + - " },\n" + - " \"safeCast\": true,\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1.2, 3.4]},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1.2, 3.4]},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1.2, 3.4]}]\n" + - " ],\n" + - " \"abc\": [1.2, 3.4]\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1.2, 3.4]},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1.2, 3.4]},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1.2, 3.4]}]\n" + - " ],\n" + - " \"abc\": [1.2, 3.4]\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNonDefault() throws JsonProcessingException, NoSuchMethodException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1.2, 3.4]},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1.2, 3.4]},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1.2, 3.4]}]\n" + - " ],\n" + - " \"abc\":[5.6, 7.8]\n" + - "}", "ftdm:abcdefg123"), - "Cannot remove non-default value:[5.6, 7.8]"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomArrayIntegerTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomArrayIntegerTest.java deleted file mode 100644 index db67175f179..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomArrayIntegerTest.java +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright 2024 Goldman Sachs -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastCustomArrayIntegerTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::AddField\",\n" + - " \"fieldName\": \"abc\",\n" + - " \"fieldType\": \"Integer[*]\",\n" + - " \"defaultValue\": {\n" + - " \"@type\": \"meta::pure::changetoken::ConstValue\",\n" + - " \"value\": [1,2,3]\n" + - " },\n" + - " \"safeCast\": true,\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1,2,3]},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1,2,3]},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1,2,3]}]\n" + - " ],\n" + - " \"abc\": [1,2,3]\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1,2,3]},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1,2,3]},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1,2,3]}]\n" + - " ],\n" + - " \"abc\": [1,2,3]\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNonDefault() throws JsonProcessingException, NoSuchMethodException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1,2,3]},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1,2,3]},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1,2,3]}]\n" + - " ],\n" + - " \"abc\":[5,6,7]\n" + - "}", "ftdm:abcdefg123"), - "Cannot remove non-default value:[5, 6, 7]"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomArrayObjectTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomArrayObjectTest.java deleted file mode 100644 index 62ec45c16e5..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomArrayObjectTest.java +++ /dev/null @@ -1,126 +0,0 @@ -// Copyright 2024 Goldman Sachs -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastCustomArrayObjectTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::AddField\",\n" + - " \"fieldName\": \"abc\",\n" + - " \"fieldType\": \"Custom[1..*]\",\n" + - " \"defaultValue\": {\n" + - " \"@type\": \"meta::pure::changetoken::ConstValue\",\n" + - " \"value\": [\n" + - " {\n" + - " \"@type\": \"Custom\",\n" + - " \"value\": 4.2\n" + - " }\n" + - " ]\n" + - " },\n" + - " \"safeCast\": true,\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [{\"@type\": \"Custom\",\"value\": 4.2}]},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [{\"@type\": \"Custom\",\"value\": 4.2}]},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [{\"@type\": \"Custom\",\"value\": 4.2}]}]\n" + - " ],\n" + - " \"abc\": [{\"@type\": \"Custom\",\"value\": 4.2}]\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [{\"@type\": \"Custom\",\"value\": 4.2}]},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [{\"@type\": \"Custom\",\"value\": 4.2}]},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [{\"@type\": \"Custom\",\"value\": 4.2}]}]\n" + - " ],\n" + - " \"abc\": [{\"@type\": \"Custom\",\"value\": 4.2}]\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNonDefault() throws JsonProcessingException, NoSuchMethodException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [{\"@type\": \"Custom\",\"value\": 4.2}]},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [{\"@type\": \"Custom\",\"value\": 4.2}]},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [{\"@type\": \"Custom\",\"value\": 4.2}]}]\n" + - " ],\n" + - " \"abc\":[{\"@type\": \"Custom\",\"value\": 8.8}]\n" + - "}", "ftdm:abcdefg123"), - "Cannot remove non-default value:[{@type=Custom, value=8.8}]"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomArrayStringTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomArrayStringTest.java deleted file mode 100644 index 769b25cf24f..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomArrayStringTest.java +++ /dev/null @@ -1,124 +0,0 @@ -// Copyright 2024 Goldman Sachs -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastCustomArrayStringTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::AddField\",\n" + - " \"fieldName\": \"abc\",\n" + - " \"fieldType\": \"String[1..*]\",\n" + - " \"defaultValue\": {\n" + - " \"@type\": \"meta::pure::changetoken::ConstValue\",\n" + - " \"value\": [\n" + - " \"Foo\",\n" + - " \"Bar\"\n" + - " ]\n" + - " },\n" + - " \"safeCast\": true,\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [\"Foo\", \"Bar\"]},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [\"Foo\", \"Bar\"]},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [\"Foo\", \"Bar\"]}]\n" + - " ],\n" + - " \"abc\": [\"Foo\", \"Bar\"]\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [\"Foo\", \"Bar\"]},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [\"Foo\", \"Bar\"]},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [\"Foo\", \"Bar\"]}]\n" + - " ],\n" + - " \"abc\": [\"Foo\", \"Bar\"]\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNonDefault() throws JsonProcessingException, NoSuchMethodException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [\"Foo\", \"Bar\"]},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [\"Foo\", \"Bar\"]},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [\"Foo\", \"Bar\"]}]\n" + - " ],\n" + - " \"abc\":[\"Something\",\"Else\"]\n" + - "}", "ftdm:abcdefg123"), - "Cannot remove non-default value:[Something, Else]"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomEmptyTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomEmptyTest.java deleted file mode 100644 index 7a9d9a46983..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomEmptyTest.java +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright 2024 Goldman Sachs -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastCustomEmptyTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::AddField\",\n" + - " \"fieldName\": \"abc\",\n" + - " \"fieldType\": \"Custom[*]\",\n" + - " \"defaultValue\": {\n" + - " \"@type\": \"meta::pure::changetoken::ConstValue\",\n" + - " \"value\": []\n" + - " },\n" + - " \"safeCast\": true,\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": []},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": []},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": []}]\n" + - " ],\n" + - " \"abc\": []\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": []},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": []},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": []}]\n" + - " ],\n" + - " \"abc\": []\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNonDefault() throws JsonProcessingException, NoSuchMethodException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": []},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": []},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": []}]\n" + - " ],\n" + - " \"abc\": [\"2023-06-22T18:30:01Z\"]\n" + - "}", "ftdm:abcdefg123"), - "Cannot remove non-default value:[2023-06-22T18:30:01Z]"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomMapTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomMapTest.java deleted file mode 100644 index aa97b20e8fd..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomMapTest.java +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright 2024 Goldman Sachs -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.finos.legend.pure.generated.Root_meta_pure_changetoken_Versions; -import org.finos.legend.pure.generated.core_pure_changetoken_changetoken_test; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastCustomMapTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - Root_meta_pure_changetoken_Versions versions = core_pure_changetoken_changetoken_test.Root_meta_pure_changetoken_tests_getVersionsCustomMap__Versions_1_(null); - setupSuiteFromVersions(versions); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}}\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}}\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNonDefault() throws JsonProcessingException, NoSuchMethodException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.0}, \"value\":1}}\n" + - "}", "ftdm:abcdefg123"), - "Cannot remove non-default value:{@type=Custom, restricted=true, range={min=-1, round=0.0, max=1, @type=intMinMax}, value=1}"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomNestedNoEscapingTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomNestedNoEscapingTest.java deleted file mode 100644 index d5308583c19..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomNestedNoEscapingTest.java +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright 2024 Goldman Sachs -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastCustomNestedNoEscapingTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::AddField\",\n" + - " \"fieldName\": \"abc\",\n" + - " \"fieldType\": \"Custom[1]\",\n" + - " \"defaultValue\": {\n" + - " \"@type\": \"meta::pure::changetoken::ConstValue\",\n" + - " \"value\": \"{\\\"@type\\\":\\\"Custom\\\",\\\"restricted\\\":true,\\\"value\\\":0,\\\"range\\\":{\\\"@type\\\":\\\"intMinMax\\\",\\\"min\\\":-1,\\\"max\\\":1,\\\"round\\\":0.5}}\"\n" + - " },\n" + - " \"safeCast\": true,\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n", - true, false, false); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"{\\\"@type\\\":\\\"Custom\\\",\\\"restricted\\\":true,\\\"value\\\":0,\\\"range\\\":{\\\"@type\\\":\\\"intMinMax\\\",\\\"min\\\":-1,\\\"max\\\":1,\\\"round\\\":0.5}}\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"{\\\"@type\\\":\\\"Custom\\\",\\\"restricted\\\":true,\\\"value\\\":0,\\\"range\\\":{\\\"@type\\\":\\\"intMinMax\\\",\\\"min\\\":-1,\\\"max\\\":1,\\\"round\\\":0.5}}\"},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"{\\\"@type\\\":\\\"Custom\\\",\\\"restricted\\\":true,\\\"value\\\":0,\\\"range\\\":{\\\"@type\\\":\\\"intMinMax\\\",\\\"min\\\":-1,\\\"max\\\":1,\\\"round\\\":0.5}}\"}]\n" + - " ],\n" + - " \"abc\": \"{\\\"@type\\\":\\\"Custom\\\",\\\"restricted\\\":true,\\\"value\\\":0,\\\"range\\\":{\\\"@type\\\":\\\"intMinMax\\\",\\\"min\\\":-1,\\\"max\\\":1,\\\"round\\\":0.5}}\"}\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"{\\\"@type\\\":\\\"Custom\\\",\\\"restricted\\\":true,\\\"value\\\":0,\\\"range\\\":{\\\"@type\\\":\\\"intMinMax\\\",\\\"min\\\":-1,\\\"max\\\":1,\\\"round\\\":0.5}}\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"{\\\"@type\\\":\\\"Custom\\\",\\\"restricted\\\":true,\\\"value\\\":0,\\\"range\\\":{\\\"@type\\\":\\\"intMinMax\\\",\\\"min\\\":-1,\\\"max\\\":1,\\\"round\\\":0.5}}\"},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"{\\\"@type\\\":\\\"Custom\\\",\\\"restricted\\\":true,\\\"value\\\":0,\\\"range\\\":{\\\"@type\\\":\\\"intMinMax\\\",\\\"min\\\":-1,\\\"max\\\":1,\\\"round\\\":0.5}}\"}]\n" + - " ],\n" + - " \"abc\": \"{\\\"@type\\\":\\\"Custom\\\",\\\"restricted\\\":true,\\\"value\\\":0,\\\"range\\\":{\\\"@type\\\":\\\"intMinMax\\\",\\\"min\\\":-1,\\\"max\\\":1,\\\"round\\\":0.5}}\"}\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNonDefault() throws JsonProcessingException, NoSuchMethodException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"{\\\"@type\\\":\\\"Custom\\\",\\\"restricted\\\":true,\\\"value\\\":0,\\\"range\\\":{\\\"@type\\\":\\\"intMinMax\\\",\\\"min\\\":-1,\\\"max\\\":1,\\\"round\\\":0.5}}\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"{\\\"@type\\\":\\\"Custom\\\",\\\"restricted\\\":true,\\\"value\\\":0,\\\"range\\\":{\\\"@type\\\":\\\"intMinMax\\\",\\\"min\\\":-1,\\\"max\\\":1,\\\"round\\\":0.5}}\"},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"{\\\"@type\\\":\\\"Custom\\\",\\\"restricted\\\":true,\\\"value\\\":0,\\\"range\\\":{\\\"@type\\\":\\\"intMinMax\\\",\\\"min\\\":-1,\\\"max\\\":1,\\\"round\\\":0.5}}\"}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.0}, \"value\":1}}\n" + - "}", "ftdm:abcdefg123"), - "Cannot remove non-default value:{@type=Custom, restricted=true, range={min=-1, round=0.0, max=1, @type=intMinMax}, value=1}"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomNestedTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomNestedTest.java deleted file mode 100644 index 3e7e2a39ffb..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomNestedTest.java +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright 2023 Goldman Sachs -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastCustomNestedTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::AddField\",\n" + - " \"fieldName\": \"abc\",\n" + - " \"fieldType\": \"Custom[1]\",\n" + - " \"defaultValue\": {\n" + - " \"@type\": \"meta::pure::changetoken::ConstValue\",\n" + - " \"value\": \"{\\\"@type\\\":\\\"Custom\\\",\\\"restricted\\\":true,\\\"value\\\":0,\\\"range\\\":{\\\"@type\\\":\\\"intMinMax\\\",\\\"min\\\":-1,\\\"max\\\":1,\\\"round\\\":0.5}}\"\n" + - " },\n" + - " \"safeCast\": true,\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}}\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}}\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNonDefault() throws JsonProcessingException, NoSuchMethodException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.0}, \"value\":1}}\n" + - "}", "ftdm:abcdefg123"), - "Cannot remove non-default value:{@type=Custom, restricted=true, range={min=-1, round=0.0, max=1, @type=intMinMax}, value=1}"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomNullKeywordTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomNullKeywordTest.java deleted file mode 100644 index 29c879d6ca3..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomNullKeywordTest.java +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright 2024 Goldman Sachs -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastCustomNullKeywordTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::AddField\",\n" + - " \"fieldName\": \"abc\",\n" + - " \"fieldType\": \"Custom[0..1]\",\n" + - " \"defaultValue\": {\n" + - " \"@type\": \"meta::pure::changetoken::ConstValue\",\n" + - " \"value\": \"null\"\n" + - " },\n" + - " \"safeCast\": true,\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null}]\n" + - " ],\n" + - " \"abc\": null\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null}]\n" + - " ],\n" + - " \"abc\": null\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNonDefault() throws JsonProcessingException, NoSuchMethodException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null}]\n" + - " ],\n" + - " \"abc\": \"2023-06-22T18:30:01Z\"\n" + - "}", "ftdm:abcdefg123"), - "Cannot remove non-default value:2023-06-22T18:30:01Z"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomNullStringTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomNullStringTest.java deleted file mode 100644 index edeca56de21..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomNullStringTest.java +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright 2024 Goldman Sachs -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastCustomNullStringTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::AddField\",\n" + - " \"fieldName\": \"abc\",\n" + - " \"fieldType\": \"Custom[0..1]\",\n" + - " \"defaultValue\": {\n" + - " \"@type\": \"meta::pure::changetoken::ConstValue\",\n" + - " \"value\": \"\"\n" + - " },\n" + - " \"safeCast\": true,\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null}]\n" + - " ],\n" + - " \"abc\": null\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null}]\n" + - " ],\n" + - " \"abc\": null\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNonDefault() throws JsonProcessingException, NoSuchMethodException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null}]\n" + - " ],\n" + - " \"abc\": \"2023-06-22T18:30:01Z\"\n" + - "}", "ftdm:abcdefg123"), - "Cannot remove non-default value:2023-06-22T18:30:01Z"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomNullTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomNullTest.java deleted file mode 100644 index bb3926b9983..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomNullTest.java +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright 2024 Goldman Sachs -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastCustomNullTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::AddField\",\n" + - " \"fieldName\": \"abc\",\n" + - " \"fieldType\": \"Custom[0..1]\",\n" + - " \"defaultValue\": {\n" + - " \"@type\": \"meta::pure::changetoken::ConstValue\",\n" + - " \"value\": null\n" + - " },\n" + - " \"safeCast\": true,\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null}]\n" + - " ],\n" + - " \"abc\": null\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null}]\n" + - " ],\n" + - " \"abc\": null\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNonDefault() throws JsonProcessingException, NoSuchMethodException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null}]\n" + - " ],\n" + - " \"abc\": \"2023-06-22T18:30:01Z\"\n" + - "}", "ftdm:abcdefg123"), - "Cannot remove non-default value:2023-06-22T18:30:01Z"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomObjectNestedVersionTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomObjectNestedVersionTest.java deleted file mode 100644 index 64ae9119537..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomObjectNestedVersionTest.java +++ /dev/null @@ -1,132 +0,0 @@ -// Copyright 2024 Goldman Sachs -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastCustomObjectNestedVersionTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::AddField\",\n" + - " \"fieldName\": \"abc\",\n" + - " \"fieldType\": \"Custom[1]\",\n" + - " \"defaultValue\": {\n" + - " \"@type\": \"meta::pure::changetoken::ConstValue\",\n" + - " \"value\": {\n" + - " \"range\": {\n" + - " \"min\": -1,\n" + - " \"max\": 1,\n" + - " \"@type\": \"intMinMax\",\n" + - " \"round\": 0.5\n" + - " },\n" + - " \"@type\": \"Custom\",\n" + - " \"restricted\": true,\n" + - " \"value\": 0\n" + - " }\n" + - " },\n" + - " \"safeCast\": true,\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n", - true, true, true); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"version\":\"ftdm:abcdefg123\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"version\":\"ftdm:abcdefg123\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"version\":\"ftdm:abcdefg123\"}]\n" + - " ]\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"version\":\"ftdm:abcdefg456\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"version\":\"ftdm:abcdefg456\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"version\":\"ftdm:abcdefg456\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}}\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"version\":\"ftdm:abcdefg456\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"version\":\"ftdm:abcdefg456\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"version\":\"ftdm:abcdefg456\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}}\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"version\":\"ftdm:abcdefg123\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"version\":\"ftdm:abcdefg123\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"version\":\"ftdm:abcdefg123\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNonDefault() throws JsonProcessingException, NoSuchMethodException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"version\":\"ftdm:abcdefg456\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"version\":\"ftdm:abcdefg456\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"version\":\"ftdm:abcdefg456\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.0}, \"value\":1}}\n" + - "}", "ftdm:abcdefg123"), - "Cannot remove non-default value:{@type=Custom, restricted=true, range={min=-1, round=0.0, max=1, @type=intMinMax}, value=1}"); - } -} \ No newline at end of file diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomObjectTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomObjectTest.java deleted file mode 100644 index 0b81983ace2..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomObjectTest.java +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright 2023 Goldman Sachs -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastCustomObjectTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::AddField\",\n" + - " \"fieldName\": \"abc\",\n" + - " \"fieldType\": \"Custom[1]\",\n" + - " \"defaultValue\": {\n" + - " \"@type\": \"meta::pure::changetoken::ConstValue\",\n" + - " \"value\": {\n" + - " \"range\": {\n" + - " \"min\": -1,\n" + - " \"max\": 1,\n" + - " \"@type\": \"intMinMax\",\n" + - " \"round\": 0.5\n" + - " },\n" + - " \"@type\": \"Custom\",\n" + - " \"restricted\": true,\n" + - " \"value\": 0\n" + - " }\n" + - " },\n" + - " \"safeCast\": true,\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}}\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}}\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNonDefault() throws JsonProcessingException, NoSuchMethodException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.0}, \"value\":1}}\n" + - "}", "ftdm:abcdefg123"), - "Cannot remove non-default value:{@type=Custom, restricted=true, range={min=-1, round=0.0, max=1, @type=intMinMax}, value=1}"); - } -} \ No newline at end of file diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomPrimitiveStringNoEscapingTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomPrimitiveStringNoEscapingTest.java deleted file mode 100644 index 355b8a117c9..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomPrimitiveStringNoEscapingTest.java +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright 2024 Goldman Sachs -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastCustomPrimitiveStringNoEscapingTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::AddField\",\n" + - " \"fieldName\": \"abc\",\n" + - " \"fieldType\": \"Custom[1]\",\n" + - " \"defaultValue\": {\n" + - " \"@type\": \"meta::pure::changetoken::ConstValue\",\n" + - " \"value\": \"\\\"1970-01-01T00:00:01Z\\\"\"\n" + - " },\n" + - " \"safeCast\": true,\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n", - true, false, false); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"\\\"1970-01-01T00:00:01Z\\\"\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"\\\"1970-01-01T00:00:01Z\\\"\"},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"\\\"1970-01-01T00:00:01Z\\\"\"}]\n" + - " ],\n" + - " \"abc\": \"\\\"1970-01-01T00:00:01Z\\\"\"\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"\\\"1970-01-01T00:00:01Z\\\"\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"\\\"1970-01-01T00:00:01Z\\\"\"},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"\\\"1970-01-01T00:00:01Z\\\"\"}]\n" + - " ],\n" + - " \"abc\": \"\\\"1970-01-01T00:00:01Z\\\"\"\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNonDefault() throws JsonProcessingException, NoSuchMethodException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"\\\"1970-01-01T00:00:01Z\\\"\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"\\\"1970-01-01T00:00:01Z\\\"\"},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"\\\"1970-01-01T00:00:01Z\\\"\"}]\n" + - " ],\n" + - " \"abc\": \"2023-06-22T18:30:01Z\"\n" + - "}", "ftdm:abcdefg123"), - "Cannot remove non-default value:2023-06-22T18:30:01Z"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomPrimitiveStringTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomPrimitiveStringTest.java deleted file mode 100644 index 89e157ecb15..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomPrimitiveStringTest.java +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright 2023 Goldman Sachs -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastCustomPrimitiveStringTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::AddField\",\n" + - " \"fieldName\": \"abc\",\n" + - " \"fieldType\": \"Custom[1]\",\n" + - " \"defaultValue\": {\n" + - " \"@type\": \"meta::pure::changetoken::ConstValue\",\n" + - " \"value\": \"\\\"1970-01-01T00:00:01Z\\\"\"\n" + - " },\n" + - " \"safeCast\": true,\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"1970-01-01T00:00:01Z\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"1970-01-01T00:00:01Z\"},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"1970-01-01T00:00:01Z\"}]\n" + - " ],\n" + - " \"abc\": \"1970-01-01T00:00:01Z\"\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"1970-01-01T00:00:01Z\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"1970-01-01T00:00:01Z\"},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"1970-01-01T00:00:01Z\"}]\n" + - " ],\n" + - " \"abc\": \"1970-01-01T00:00:01Z\"\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNonDefault() throws JsonProcessingException, NoSuchMethodException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"1970-01-01T00:00:01Z\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"1970-01-01T00:00:01Z\"},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"1970-01-01T00:00:01Z\"}]\n" + - " ],\n" + - " \"abc\": \"2023-06-22T18:30:01Z\"\n" + - "}", "ftdm:abcdefg123"), - "Cannot remove non-default value:2023-06-22T18:30:01Z"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomPrimitiveTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomPrimitiveTest.java deleted file mode 100644 index c8b2886e3c2..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomPrimitiveTest.java +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright 2023 Goldman Sachs -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastCustomPrimitiveTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::AddField\",\n" + - " \"fieldName\": \"abc\",\n" + - " \"fieldType\": \"Custom[1]\",\n" + - " \"defaultValue\": {\n" + - " \"@type\": \"meta::pure::changetoken::ConstValue\",\n" + - " \"value\": \"1970-01-01T00:00:01Z\"\n" + - " },\n" + - " \"safeCast\": true,\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"1970-01-01T00:00:01Z\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"1970-01-01T00:00:01Z\"},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"1970-01-01T00:00:01Z\"}]\n" + - " ],\n" + - " \"abc\": \"1970-01-01T00:00:01Z\"\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"1970-01-01T00:00:01Z\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"1970-01-01T00:00:01Z\"},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"1970-01-01T00:00:01Z\"}]\n" + - " ],\n" + - " \"abc\": \"1970-01-01T00:00:01Z\"\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNonDefault() throws JsonProcessingException, NoSuchMethodException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"1970-01-01T00:00:01Z\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"1970-01-01T00:00:01Z\"},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"1970-01-01T00:00:01Z\"}]\n" + - " ],\n" + - " \"abc\": \"2023-06-22T18:30:01Z\"\n" + - "}", "ftdm:abcdefg123"), - "Cannot remove non-default value:2023-06-22T18:30:01Z"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomTest.java deleted file mode 100644 index 4c3ba0d0ceb..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastCustomTest.java +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright 2023 Goldman Sachs -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastCustomTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::AddField\",\n" + - " \"fieldName\": \"abc\",\n" + - " \"fieldType\": \"Custom[1]\",\n" + - " \"defaultValue\": {\n" + - " \"@type\": \"meta::pure::changetoken::ConstValue\",\n" + - " \"value\": \"{\\\"@type\\\":\\\"Custom\\\",\\\"value\\\":\\\"0d\\\"}\"\n" + - " },\n" + - " \"safeCast\": true,\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"0d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"0d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"0d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"0d\"}\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"0d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"0d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"0d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"0d\"}\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNonDefault() throws JsonProcessingException, NoSuchMethodException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"0d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"0d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"0d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n" + - "}", "ftdm:abcdefg123"), - "Cannot remove non-default value:{@type=Custom, value=1d}"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastDoubleStringTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastDoubleStringTest.java deleted file mode 100644 index 224fbc8ca6c..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastDoubleStringTest.java +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright 2023 Goldman Sachs -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastDoubleStringTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::AddField\",\n" + - " \"fieldName\": \"abc\",\n" + - " \"fieldType\": \"double[1]\",\n" + - " \"defaultValue\": {\n" + - " \"@type\": \"meta::pure::changetoken::ConstValue\",\n" + - " \"value\": \"123.45\"\n" + - " },\n" + - " \"safeCast\": true,\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 123.45},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 123.45},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 123.45}]\n" + - " ],\n" + - " \"abc\": 123.45\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 123.45},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 123.45},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 123.45}]\n" + - " ],\n" + - " \"abc\": 123.45\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNonDefault() throws JsonProcessingException, NoSuchMethodException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 123.45},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 123.45},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 123.45}]\n" + - " ],\n" + - " \"abc\": 67.89\n" + - "}", "ftdm:abcdefg123"), - "Cannot remove non-default value:67.89"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastDoubleTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastDoubleTest.java deleted file mode 100644 index df96a82d589..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastDoubleTest.java +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright 2023 Goldman Sachs -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastDoubleTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::AddField\",\n" + - " \"fieldName\": \"abc\",\n" + - " \"fieldType\": \"double[1]\",\n" + - " \"defaultValue\": {\n" + - " \"@type\": \"meta::pure::changetoken::ConstValue\",\n" + - " \"value\": 123.45\n" + - " },\n" + - " \"safeCast\": true,\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 123.45},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 123.45},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 123.45}]\n" + - " ],\n" + - " \"abc\": 123.45\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 123.45},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 123.45},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 123.45}]\n" + - " ],\n" + - " \"abc\": 123.45\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNonDefault() throws JsonProcessingException, NoSuchMethodException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 123.45},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 123.45},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 123.45}]\n" + - " ],\n" + - " \"abc\": 67.89\n" + - "}", "ftdm:abcdefg123"), - "Cannot remove non-default value:67.89"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastFromJsonTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastFromJsonTest.java deleted file mode 100644 index 4611d8d3a95..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastFromJsonTest.java +++ /dev/null @@ -1,145 +0,0 @@ -// Copyright 2023 Goldman Sachs -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastFromJsonTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::AddField\",\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"fieldName\": \"abc\",\n" + - " \"fieldType\": \"Integer[1]\",\n" + - " \"safeCast\": true,\n" + - " \"defaultValue\": {\n" + - " \"@type\": \"meta::pure::changetoken::ConstValue\",\n" + - " \"value\": 100\n" + - " }\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100}]\n" + - " ],\n" + - " \"abc\": 100\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100}]\n" + - " ],\n" + - " \"abc\": 100\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNull() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null}]\n" + - " ],\n" + - " \"abc\": null\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNonDefault() throws JsonProcessingException, NoSuchMethodException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100}]\n" + - " ],\n" + - " \"abc\": 300\n" + - "}", "ftdm:abcdefg123"), - "Cannot remove non-default value:300"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastFromVersionsTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastFromVersionsTest.java deleted file mode 100644 index 8af0c5d917a..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastFromVersionsTest.java +++ /dev/null @@ -1,137 +0,0 @@ -// Copyright 2023 Goldman Sachs -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.finos.legend.pure.generated.*; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastFromVersionsTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - Root_meta_pure_changetoken_Version abcdefg123 = new Root_meta_pure_changetoken_Version_Impl("Anonymous_NoCounter"); - abcdefg123._version("ftdm:abcdefg123"); - Root_meta_pure_changetoken_Version abcdefg456 = new Root_meta_pure_changetoken_Version_Impl("Anonymous_NoCounter"); - abcdefg456._version("ftdm:abcdefg456"); - abcdefg456._prevVersion("ftdm:abcdefg123"); - Root_meta_pure_changetoken_AddField addField = new Root_meta_pure_changetoken_AddField_Impl("Anonymous_NoCounter"); - addField._class("meta::pure::changetoken::tests::SampleClass"); - addField._fieldName("abc"); - addField._fieldType("Integer[1]"); - addField._safeCast(true); - Root_meta_pure_changetoken_ConstValue value = new Root_meta_pure_changetoken_ConstValue_Impl("Anonymous_NoCounter"); - value._value(100L); - addField._defaultValue(value); - abcdefg456._changeTokensAdd(addField); - Root_meta_pure_changetoken_Versions versions = new Root_meta_pure_changetoken_Versions_Impl("Anonymous_NoCounter"); - versions._versionsAdd(abcdefg123); - versions._versionsAdd(abcdefg456); - setupSuiteFromVersions(versions); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100}]\n" + - " ],\n" + - " \"abc\": 100\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100}]\n" + - " ],\n" + - " \"abc\": 100\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNull() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null}]\n" + - " ],\n" + - " \"abc\": null\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNonDefault() throws JsonProcessingException, NoSuchMethodException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100}]\n" + - " ],\n" + - " \"abc\": 300\n" + - "}", "ftdm:abcdefg123"), - "Cannot remove non-default value:300"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastIntegerStringTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastIntegerStringTest.java deleted file mode 100644 index c853e37bd71..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastIntegerStringTest.java +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright 2023 Goldman Sachs -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastIntegerStringTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::AddField\",\n" + - " \"fieldName\": \"abc\",\n" + - " \"fieldType\": \"Integer[1]\",\n" + - " \"defaultValue\": {\n" + - " \"@type\": \"meta::pure::changetoken::ConstValue\",\n" + - " \"value\": \"100\"\n" + - " },\n" + - " \"safeCast\": true,\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100}]\n" + - " ],\n" + - " \"abc\": 100\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100}]\n" + - " ],\n" + - " \"abc\": 100\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNonDefault() throws JsonProcessingException, NoSuchMethodException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100}]\n" + - " ],\n" + - " \"abc\": 300\n" + - "}", "ftdm:abcdefg123"), - "Cannot remove non-default value:300"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastMoveExtractTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastMoveExtractTest.java deleted file mode 100644 index 40f9576508f..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastMoveExtractTest.java +++ /dev/null @@ -1,129 +0,0 @@ -// Copyright 2023 Goldman Sachs -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastMoveExtractTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::RenameField\",\n" + - " \"oldFieldName\": [\n" + - " \"names\",\n" + - " \"first\"\n" + - " ],\n" + - " \"newFieldName\": [\n" + - " \"firstName\"\n" + - " ],\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::RenameField\",\n" + - " \"oldFieldName\": [\n" + - " \"names\",\n" + - " \"last\"\n" + - " ],\n" + - " \"newFieldName\": [\n" + - " \"lastName\"\n" + - " ],\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::RemoveField\",\n" + - " \"fieldName\": \"names\",\n" + - " \"fieldType\": \"NamesClass[1]\",\n" + - " \"defaultValue\": {\n" + - " \"@type\": \"meta::pure::changetoken::ConstValue\",\n" + - " \"value\": \"{\\\"@type\\\":\\\"NamesClass\\\",\\\"middle\\\":\\\"\\\"}\"\n" + - " },\n" + - " \"safeCast\": true,\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"names\": {\"@type\":\"NamesClass\", \"first\":\"1d\", \"middle\":\"\", \"last\":\"2d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"names\": {\"@type\":\"NamesClass\", \"first\":\"3d\", \"middle\":\"\", \"last\":\"4d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"names\": {\"@type\":\"NamesClass\", \"first\":\"5d\", \"middle\":\"\", \"last\":\"6d\"}}]\n" + - " ],\n" + - " \"names\": {\"@type\":\"NamesClass\", \"first\":\"7d\", \"middle\":\"\", \"last\":\"8d\"}\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"firstName\":\"1d\", \"lastName\":\"2d\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"firstName\":\"3d\", \"lastName\":\"4d\"},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"firstName\":\"5d\", \"lastName\":\"6d\"}]\n" + - " ],\n" + - " \"firstName\":\"7d\", \"lastName\":\"8d\"\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"firstName\":\"1d\", \"lastName\":\"2d\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"firstName\":\"3d\", \"lastName\":\"4d\"},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"firstName\":\"5d\", \"lastName\":\"6d\"}]\n" + - " ],\n" + - " \"firstName\":\"7d\", \"lastName\":\"8d\"\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"names\": {\"@type\":\"NamesClass\", \"first\":\"1d\", \"middle\":\"\", \"last\":\"2d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"names\": {\"@type\":\"NamesClass\", \"first\":\"3d\", \"middle\":\"\", \"last\":\"4d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"names\": {\"@type\":\"NamesClass\", \"first\":\"5d\", \"middle\":\"\", \"last\":\"6d\"}}]\n" + - " ],\n" + - " \"names\": {\"@type\":\"NamesClass\", \"first\":\"7d\", \"middle\":\"\", \"last\":\"8d\"}\n" + - "}\n"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastMoveNestedTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastMoveNestedTest.java deleted file mode 100644 index 4d8af2165bd..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastMoveNestedTest.java +++ /dev/null @@ -1,254 +0,0 @@ -// Copyright 2023 Goldman Sachs -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastMoveNestedTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::RenameField\",\n" + - " \"oldFieldName\": [\n" + - " \"abc\",\n" + - " \"value\"\n" + - " ],\n" + - " \"newFieldName\": [\n" + - " \"xyz\",\n" + - " \"value\"\n" + - " ],\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"String\", \"value\":\"1d\"}, \"xyz\": {\"@type\":\"String\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"String\", \"value\":\"2d\"}, \"xyz\": {\"@type\":\"String\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"String\", \"value\":\"3d\"}, \"xyz\": {\"@type\":\"String\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"String\", \"value\":\"4d\"}, \"xyz\": {\"@type\":\"String\"}\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"String\", \"value\":\"1d\"}, \"abc\": {\"@type\":\"String\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"String\", \"value\":\"2d\"}, \"abc\": {\"@type\":\"String\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"String\", \"value\":\"3d\"}, \"abc\": {\"@type\":\"String\"}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"String\", \"value\":\"4d\"}, \"abc\": {\"@type\":\"String\"}\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"String\", \"value\":\"1d\"}, \"abc\": {\"@type\":\"String\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"String\", \"value\":\"2d\"}, \"abc\": {\"@type\":\"String\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"String\", \"value\":\"3d\"}, \"abc\": {\"@type\":\"String\"}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"String\", \"value\":\"4d\"}, \"abc\": {\"@type\":\"String\"}\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"String\", \"value\":\"1d\"}, \"xyz\": {\"@type\":\"String\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"String\", \"value\":\"2d\"}, \"xyz\": {\"@type\":\"String\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"String\", \"value\":\"3d\"}, \"xyz\": {\"@type\":\"String\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"String\", \"value\":\"4d\"}, \"xyz\": {\"@type\":\"String\"}\n" + - "}\n"); - } - - @Test - public void testUpcastSame() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"String\", \"value\":\"1d\"}, \"xyz\": {\"@type\":\"String\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"String\", \"value\":\"2d\"}, \"xyz\": {\"@type\":\"String\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"String\", \"value\":\"3d\"}, \"xyz\": {\"@type\":\"String\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"String\", \"value\":\"4d\"}, \"xyz\": {\"@type\":\"String\"}\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"String\", \"value\":\"1d\"}, \"abc\": {\"@type\":\"String\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"String\", \"value\":\"2d\"}, \"abc\": {\"@type\":\"String\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"String\", \"value\":\"3d\"}, \"abc\": {\"@type\":\"String\"}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"String\", \"value\":\"4d\"}, \"abc\": {\"@type\":\"String\"}\n" + - "}\n"); - } - - @Test - public void testDowncastSame() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"String\", \"value\":\"1d\"}, \"abc\": {\"@type\":\"String\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"String\", \"value\":\"2d\"}, \"abc\": {\"@type\":\"String\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"String\", \"value\":\"3d\"}, \"abc\": {\"@type\":\"String\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"String\", \"value\":\"4d\"}, \"abc\": {\"@type\":\"String\"}\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"String\", \"value\":\"1d\"}, \"xyz\": {\"@type\":\"String\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"String\", \"value\":\"2d\"}, \"xyz\": {\"@type\":\"String\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"String\", \"value\":\"3d\"}, \"xyz\": {\"@type\":\"String\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"String\", \"value\":\"4d\"}, \"xyz\": {\"@type\":\"String\"}\n" + - "}\n"); - } - - @Test - public void testUpcastDifferent() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - exception(() -> upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"String\", \"value\":\"1d\"}, \"xyz\": {\"@type\":\"String\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"String\", \"value\":\"2d\"}, \"xyz\": {\"@type\":\"String\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"String\", \"value\":\"3d\"}, \"xyz\": {\"@type\":\"String\", \"value\":\"5d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"String\", \"value\":\"4d\"}, \"xyz\": {\"@type\":\"String\"}\n" + - "}"), - "Cannot overwrite with different value:5d"); - } - - @Test - public void testDowncastDifferent() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"String\", \"value\":\"1d\"}, \"abc\": {\"@type\":\"String\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"String\", \"value\":\"2d\"}, \"abc\": {\"@type\":\"String\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"String\", \"value\":\"3d\"}, \"abc\": {\"@type\":\"String\", \"value\":\"6d\"}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"String\", \"value\":\"4d\"}, \"abc\": {\"@type\":\"String\"}\n" + - "}", "ftdm:abcdefg123"), - "Cannot overwrite with different value:6d"); - } - - @Test - public void testUpcastInvalidDestination() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - exception(() -> upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"String\", \"value\":\"1d\"}, \"xyz\": {\"@type\":\"String\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"String\", \"value\":\"2d\"}, \"xyz\": {\"@type\":\"String\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"String\", \"value\":\"3d\"}, \"xyz\": \"invalid\"}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"String\", \"value\":\"4d\"}, \"xyz\": {\"@type\":\"String\"}\n" + - "}"), - "Destination is not a map: xyz"); - } - - @Test - public void testDowncastInvalidDestination() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"String\", \"value\":\"1d\"}, \"abc\": {\"@type\":\"String\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"String\", \"value\":\"2d\"}, \"abc\": {\"@type\":\"String\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"String\", \"value\":\"3d\"}, \"abc\": \"invalid\"}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"String\", \"value\":\"4d\"}, \"abc\": {\"@type\":\"String\"}\n" + - "}", "ftdm:abcdefg123"), - "Destination is not a map: abc"); - } - - @Test - public void testUpcastInvalidSource() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - exception(() -> upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"String\", \"value\":\"1d\"}, \"xyz\": {\"@type\":\"String\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"String\", \"value\":\"2d\"}, \"xyz\": {\"@type\":\"String\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"invalid\", \"xyz\": {\"@type\":\"String\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"String\", \"value\":\"4d\"}, \"xyz\": {\"@type\":\"String\"}\n" + - "}"), - "Source is not a map: abc"); - } - - @Test - public void testDowncastInvalidSource() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"String\", \"value\":\"1d\"}, \"abc\": {\"@type\":\"String\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"String\", \"value\":\"2d\"}, \"abc\": {\"@type\":\"String\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": \"invalid\", \"abc\": {\"@type\":\"String\"}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"String\", \"value\":\"4d\"}, \"abc\": {\"@type\":\"String\"}\n" + - "}", "ftdm:abcdefg123"), - "Source is not a map: xyz"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastMoveTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastMoveTest.java deleted file mode 100644 index 0241f0ab169..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastMoveTest.java +++ /dev/null @@ -1,218 +0,0 @@ -// Copyright 2023 Goldman Sachs -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastMoveTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::AddField\",\n" + - " \"fieldName\": \"xyz\",\n" + - " \"fieldType\": \"SampleNestedClass[1]\",\n" + - " \"defaultValue\": {\n" + - " \"@type\": \"meta::pure::changetoken::ConstValue\",\n" + - " \"value\": \"{\\\"@type\\\":\\\"SampleNestedClass\\\",\\\"step\\\":0,\\\"active\\\":true}\"\n" + - " },\n" + - " \"safeCast\": true,\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::RenameField\",\n" + - " \"oldFieldName\": [\n" + - " \"abc\"\n" + - " ],\n" + - " \"newFieldName\": [\n" + - " \"xyz\",\n" + - " \"def\"\n" + - " ],\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"SampleNestedClass\", \"active\":true, \"step\":0, \"def\": {\"@type\":\"Custom\", \"value\":\"1d\"}}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"SampleNestedClass\", \"active\":true, \"step\":0, \"def\": {\"@type\":\"Custom\", \"value\":\"2d\"}}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"SampleNestedClass\", \"active\":true, \"step\":0, \"def\": {\"@type\":\"Custom\", \"value\":\"3d\"}}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"SampleNestedClass\", \"active\":true, \"step\":0, \"def\": {\"@type\":\"Custom\", \"value\":\"4d\"}}\n" + - "}\n"); - } - - @Test - public void testUpcastType() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}\n"); - } - - @Test - public void testUpcastMissing() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"def\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"SampleNestedClass\", \"active\":true, \"step\":0}, \"def\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"SampleNestedClass\", \"active\":true, \"step\":0}, \"def\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"SampleNestedClass\", \"active\":true, \"step\":0}, \"def\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"SampleNestedClass\", \"active\":true, \"step\":0}, \"def\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"SampleNestedClass\", \"active\":true, \"step\":0, \"def\": {\"@type\":\"Custom\", \"value\":\"1d\"}}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"SampleNestedClass\", \"active\":true, \"step\":0, \"def\": {\"@type\":\"Custom\", \"value\":\"2d\"}}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"SampleNestedClass\", \"active\":true, \"step\":0, \"def\": {\"@type\":\"Custom\", \"value\":\"3d\"}}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"SampleNestedClass\", \"active\":true, \"step\":0, \"def\": {\"@type\":\"Custom\", \"value\":\"4d\"}}\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}\n"); - } - - @Test - public void testDowncastType() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n" + - "}\n"); - } - - @Test - public void testDowncastMissing() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n" + - " ],\n" + - " \"def\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n" + - " ],\n" + - " \"def\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n" + - "}\n"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastRemoveTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastRemoveTest.java deleted file mode 100644 index f02987e157c..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastRemoveTest.java +++ /dev/null @@ -1,145 +0,0 @@ -// Copyright 2023 Goldman Sachs -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastRemoveTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::RemoveField\",\n" + - " \"fieldName\": \"abc\",\n" + - " \"fieldType\": \"Integer[1]\",\n" + - " \"defaultValue\": {\n" + - " \"@type\": \"meta::pure::changetoken::ConstValue\",\n" + - " \"value\": 100\n" + - " },\n" + - " \"safeCast\": true,\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100}]\n" + - " ],\n" + - " \"abc\": 100\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void tesUpcastNull() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null}]\n" + - " ],\n" + - " \"abc\": null\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcastNonDefault() throws JsonProcessingException, NoSuchMethodException - { - exception(() -> upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100}]\n" + - " ],\n" + - " \"abc\": 300\n" + - "}"), - "Cannot remove non-default value:300"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100}]\n" + - " ],\n" + - " \"abc\": 100\n" + - "}\n"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastRenameFieldRenamedClassTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastRenameFieldRenamedClassTest.java deleted file mode 100644 index 09f096071f2..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastRenameFieldRenamedClassTest.java +++ /dev/null @@ -1,293 +0,0 @@ -// Copyright 2023 Goldman Sachs -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastRenameFieldRenamedClassTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::RenameField\",\n" + - " \"oldFieldName\": [\n" + - " \"abc\"\n" + - " ],\n" + - " \"newFieldName\": [\n" + - " \"xyz\"\n" + - " ],\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::RenamedClass\",\n" + - " \"newName\": \"meta::pure::changetoken::tests::nested::NewSampleClass\",\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}\n"); - } - - @Test - public void testUpcastType() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}\n"); - } - - @Test - public void testUpcastMissing() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"def\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"def\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n" + - "}\n"); - } - - @Test - public void testDowncastType() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n" + - "}\n"); - } - - @Test - public void testDowncastMissing() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n" + - " ],\n" + - " \"def\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n" + - " ],\n" + - " \"def\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n" + - "}\n"); - } - - @Test - public void testUpcastExistingTheSame() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}\n"); - } - - @Test - public void testDowncastExistingTheSame() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"5d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"5d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"6d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"6d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"7d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"7d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"8d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"8d\"}\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"5d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"6d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"7d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"8d\"}\n" + - "}\n"); - } - - @Test - public void testUpcastExistingTheDifferent() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - exception(() -> upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"9d\"}\n" + - "}"), - "Cannot overwrite with different value:{@type=Custom, value=9d}"); - } - - @Test - public void testDowncastExistingTheDifferent() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"5d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"5d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"6d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"6d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"7d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"7d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"8d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"9d\"}\n" + - "}", "ftdm:abcdefg123"), - "Cannot overwrite with different value:{@type=Custom, value=8d}"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastRenameNestedPropertyTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastRenameNestedPropertyTest.java deleted file mode 100644 index 3ce0a394284..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastRenameNestedPropertyTest.java +++ /dev/null @@ -1,290 +0,0 @@ -// Copyright 2023 Goldman Sachs -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastRenameNestedPropertyTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::RenameField\",\n" + - " \"oldFieldName\": [\n" + - " \"abc\",\n" + - " \"value\"\n" + - " ],\n" + - " \"newFieldName\": [\n" + - " \"abc\",\n" + - " \"valueCustom\"\n" + - " ],\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"valueCustom\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"valueCustom\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"valueCustom\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"valueCustom\":\"4d\"}\n" + - "}\n"); - } - - @Test - public void testUpcastType() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"4d\"}\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"4d\"}\n" + - "}\n"); - } - - @Test - public void testUpcastMissing() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"valueOther\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"valueOther\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"valueOther\":\"3d\"}}]\n" + - " ],\n" + - " \"def\": {\"@type\":\"Custom\", \"valueOther\":\"4d\"}\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"valueOther\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"valueOther\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"valueOther\":\"3d\"}}]\n" + - " ],\n" + - " \"def\": {\"@type\":\"Custom\", \"valueOther\":\"4d\"}\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"valueCustom\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"valueCustom\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"valueCustom\":\"2d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"valueCustom\":\"1d\"}\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n" + - "}\n"); - } - - @Test - public void testDowncastType() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"2d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"1d\"}\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"2d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"1d\"}\n" + - "}\n"); - } - - @Test - public void testDowncastMissing() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"valueOther\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"valueOther\":\"2d\"}}]\n" + - " ],\n" + - " \"def\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"valueOther\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"valueOther\":\"2d\"}}]\n" + - " ],\n" + - " \"def\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n" + - "}\n"); - } - - @Test - public void testUpcastExistingTheSame() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\", \"valueCustom\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\", \"valueCustom\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\", \"valueCustom\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\", \"valueCustom\":\"4d\"}\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"valueCustom\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"valueCustom\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"valueCustom\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"valueCustom\":\"4d\"}\n" + - "}\n"); - } - - @Test - public void testDowncastExistingTheSame() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"5d\", \"valueCustom\":\"5d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"6d\", \"valueCustom\":\"6d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"7d\", \"valueCustom\":\"7d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"8d\", \"valueCustom\":\"8d\"}\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"5d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"6d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"7d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"8d\"}\n" + - "}\n"); - } - - @Test - public void testUpcastExistingTheDifferent() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - exception(() -> upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\", \"valueCustom\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\", \"valueCustom\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\", \"valueCustom\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\", \"valueCustom\":\"9d\"}\n" + - "}"), - "Cannot overwrite with different value:9d"); - } - - @Test - public void testDowncastExistingTheDifferent() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"5d\", \"valueCustom\":\"5d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"6d\", \"valueCustom\":\"6d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"7d\", \"valueCustom\":\"7d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"8d\", \"valueCustom\":\"9d\"}\n" + - "}", "ftdm:abcdefg123"), - "Cannot overwrite with different value:8d"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastRenamePropertyTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastRenamePropertyTest.java deleted file mode 100644 index 0458f6c6aba..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastRenamePropertyTest.java +++ /dev/null @@ -1,288 +0,0 @@ -// Copyright 2023 Goldman Sachs -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastRenamePropertyTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::RenameField\",\n" + - " \"oldFieldName\": [\n" + - " \"value\"\n" + - " ],\n" + - " \"newFieldName\": [\n" + - " \"valueCustom\"\n" + - " ],\n" + - " \"class\": \"Custom\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"valueCustom\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"valueCustom\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"valueCustom\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"valueCustom\":\"4d\"}\n" + - "}\n"); - } - - @Test - public void testUpcastType() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"4d\"}\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"4d\"}\n" + - "}\n"); - } - - @Test - public void testUpcastMissing() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"valueOther\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"valueOther\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"valueOther\":\"3d\"}}]\n" + - " ],\n" + - " \"def\": {\"@type\":\"Custom\", \"valueOther\":\"4d\"}\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"valueOther\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"valueOther\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"valueOther\":\"3d\"}}]\n" + - " ],\n" + - " \"def\": {\"@type\":\"Custom\", \"valueOther\":\"4d\"}\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"Custom\", \"valueCustom\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"Custom\", \"valueCustom\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"Custom\", \"valueCustom\":\"2d\"}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"Custom\", \"valueCustom\":\"1d\"}\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n" + - "}\n"); - } - - @Test - public void testDowncastType() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"OtherCustom\", \"value\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"OtherCustom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"OtherCustom\", \"value\":\"2d\"}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"OtherCustom\", \"value\":\"1d\"}\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"OtherCustom\", \"value\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"OtherCustom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"OtherCustom\", \"value\":\"2d\"}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"OtherCustom\", \"value\":\"1d\"}\n" + - "}\n"); - } - - @Test - public void testDowncastMissing() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"valueOther\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"valueOther\":\"2d\"}}]\n" + - " ],\n" + - " \"def\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"valueOther\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"valueOther\":\"2d\"}}]\n" + - " ],\n" + - " \"def\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n" + - "}\n"); - } - - @Test - public void testUpcastExistingTheSame() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\", \"valueCustom\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\", \"valueCustom\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\", \"valueCustom\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\", \"valueCustom\":\"4d\"}\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"valueCustom\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"valueCustom\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"valueCustom\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"valueCustom\":\"4d\"}\n" + - "}\n"); - } - - @Test - public void testDowncastExistingTheSame() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"5d\", \"valueCustom\":\"5d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"6d\", \"valueCustom\":\"6d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"7d\", \"valueCustom\":\"7d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"8d\", \"valueCustom\":\"8d\"}\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"5d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"6d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"7d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"8d\"}\n" + - "}\n"); - } - - @Test - public void testUpcastExistingTheDifferent() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - exception(() -> upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\", \"valueCustom\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\", \"valueCustom\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\", \"valueCustom\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\", \"valueCustom\":\"9d\"}\n" + - "}"), - "Cannot overwrite with different value:9d"); - } - - @Test - public void testDowncastExistingTheDifferent() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"5d\", \"valueCustom\":\"5d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"6d\", \"valueCustom\":\"6d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"7d\", \"valueCustom\":\"7d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"8d\", \"valueCustom\":\"9d\"}\n" + - "}", "ftdm:abcdefg123"), - "Cannot overwrite with different value:8d"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastRenameTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastRenameTest.java deleted file mode 100644 index 4fa70b49728..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastRenameTest.java +++ /dev/null @@ -1,288 +0,0 @@ -// Copyright 2023 Goldman Sachs -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastRenameTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::RenameField\",\n" + - " \"oldFieldName\": [\n" + - " \"abc\"\n" + - " ],\n" + - " \"newFieldName\": [\n" + - " \"xyz\"\n" + - " ],\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}\n"); - } - - @Test - public void testUpcastType() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}\n"); - } - - @Test - public void testUpcastMissing() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"def\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"def\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n" + - "}\n"); - } - - @Test - public void testDowncastType() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n" + - "}\n"); - } - - @Test - public void testDowncastMissing() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n" + - " ],\n" + - " \"def\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n" + - " ],\n" + - " \"def\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n" + - "}\n"); - } - - @Test - public void testUpcastExistingTheSame() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}\n"); - } - - @Test - public void testDowncastExistingTheSame() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"5d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"5d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"6d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"6d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"7d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"7d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"8d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"8d\"}\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"5d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"6d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"7d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"8d\"}\n" + - "}\n"); - } - - @Test - public void testUpcastExistingTheDifferent() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - exception(() -> upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"9d\"}\n" + - "}"), - "Cannot overwrite with different value:{@type=Custom, value=9d}"); - } - - @Test - public void testDowncastExistingTheDifferent() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"5d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"5d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"6d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"6d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"7d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"7d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"8d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"9d\"}\n" + - "}", "ftdm:abcdefg123"), - "Cannot overwrite with different value:{@type=Custom, value=8d}"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastRenamedClassRenameFieldTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastRenamedClassRenameFieldTest.java deleted file mode 100644 index 45442796a27..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastRenamedClassRenameFieldTest.java +++ /dev/null @@ -1,293 +0,0 @@ -// Copyright 2023 Goldman Sachs -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastRenamedClassRenameFieldTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::RenamedClass\",\n" + - " \"newName\": \"meta::pure::changetoken::tests::nested::NewSampleClass\",\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::RenameField\",\n" + - " \"oldFieldName\": [\n" + - " \"abc\"\n" + - " ],\n" + - " \"newFieldName\": [\n" + - " \"xyz\"\n" + - " ],\n" + - " \"class\": \"meta::pure::changetoken::tests::nested::NewSampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}\n"); - } - - @Test - public void testUpcastType() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}\n"); - } - - @Test - public void testUpcastMissing() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"def\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"def\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n" + - "}\n"); - } - - @Test - public void testDowncastType() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n" + - "}\n"); - } - - @Test - public void testDowncastMissing() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n" + - " ],\n" + - " \"def\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n" + - " ],\n" + - " \"def\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n" + - "}\n"); - } - - @Test - public void testUpcastExistingTheSame() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}\n"); - } - - @Test - public void testDowncastExistingTheSame() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"5d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"5d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"6d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"6d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"7d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"7d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"8d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"8d\"}\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"5d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"6d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"7d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"8d\"}\n" + - "}\n"); - } - - @Test - public void testUpcastExistingTheDifferent() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - exception(() -> upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"9d\"}\n" + - "}"), - "Cannot overwrite with different value:{@type=Custom, value=9d}"); - } - - @Test - public void testDowncastExistingTheDifferent() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"5d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"5d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"6d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"6d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"7d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"7d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"8d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"9d\"}\n" + - "}", "ftdm:abcdefg123"), - "Cannot overwrite with different value:{@type=Custom, value=8d}"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastRenamedClassTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastRenamedClassTest.java deleted file mode 100644 index 79c6b745cd6..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastRenamedClassTest.java +++ /dev/null @@ -1,151 +0,0 @@ -// Copyright 2023 Goldman Sachs -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastRenamedClassTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::RenamedClass\",\n" + - " \"newName\": \"meta::pure::changetoken::tests::nested::NewSampleClass\",\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}\n"); - } - - @Test - public void testUpcastType() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n" + - " ],\n" + - " \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n" + - "}\n"); - } - - @Test - public void testDowncastType() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n" + - " ],\n" + - " \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n" + - "}\n"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastStringQuotesTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastStringQuotesTest.java deleted file mode 100644 index 15c8f783a21..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastStringQuotesTest.java +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright 2023 Goldman Sachs -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastStringQuotesTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::AddField\",\n" + - " \"fieldName\": \"abc\",\n" + - " \"fieldType\": \"String[1]\",\n" + - " \"defaultValue\": {\n" + - " \"@type\": \"meta::pure::changetoken::ConstValue\",\n" + - " \"value\": \"\\\"one \\\\\\\" two\\\"\"\n" + - " },\n" + - " \"safeCast\": true,\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"one \\\" two\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"one \\\" two\"},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"one \\\" two\"}]\n" + - " ],\n" + - " \"abc\": \"one \\\" two\"\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"one \\\" two\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"one \\\" two\"},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"one \\\" two\"}]\n" + - " ],\n" + - " \"abc\": \"one \\\" two\"\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNonDefault() throws JsonProcessingException, NoSuchMethodException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"one \\\" two\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"one \\\" two\"},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"one \\\" two\"}]\n" + - " ],\n" + - " \"abc\": \"two \\\" one\"\n" + - "}", "ftdm:abcdefg123"), - "Cannot remove non-default value:two \" one"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastStringTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastStringTest.java deleted file mode 100644 index ef87ca95cef..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastStringTest.java +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright 2023 Goldman Sachs -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastStringTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::AddField\",\n" + - " \"fieldName\": \"abc\",\n" + - " \"fieldType\": \"String[1]\",\n" + - " \"defaultValue\": {\n" + - " \"@type\": \"meta::pure::changetoken::ConstValue\",\n" + - " \"value\": \"one \\\" two\"\n" + - " },\n" + - " \"safeCast\": true,\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}"), - "{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"one \\\" two\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"one \\\" two\"},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"one \\\" two\"}]\n" + - " ],\n" + - " \"abc\": \"one \\\" two\"\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"one \\\" two\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"one \\\" two\"},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"one \\\" two\"}]\n" + - " ],\n" + - " \"abc\": \"one \\\" two\"\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"version\":\"ftdm:abcdefg123\", \n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNonDefault() throws JsonProcessingException, NoSuchMethodException - { - exception(() -> downcast("{\n" + - " \"version\":\"ftdm:abcdefg456\",\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"one \\\" two\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"one \\\" two\"},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"one \\\" two\"}]\n" + - " ],\n" + - " \"abc\": \"two \\\" one\"\n" + - "}", "ftdm:abcdefg123"), - "Cannot remove non-default value:two \" one"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastVersionCustomTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastVersionCustomTest.java deleted file mode 100644 index f295ffd153d..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastVersionCustomTest.java +++ /dev/null @@ -1,145 +0,0 @@ -// Copyright 2024 Goldman Sachs -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastVersionCustomTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"$type$\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"$type$\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"$type$\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"$type$\": \"meta::pure::changetoken::AddField\",\n" + - " \"fieldName\": \"abc\",\n" + - " \"fieldType\": \"Integer[1]\",\n" + - " \"defaultValue\": {\n" + - " \"$type$\": \"meta::pure::changetoken::ConstValue\",\n" + - " \"value\": 100\n" + - " },\n" + - " \"safeCast\": true,\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n", "$type$", "$version$"); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"$version$\":\"ftdm:abcdefg123\", \n" + - " \"$type$\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"$type$\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"$type$\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"$type$\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}"), - "{\n" + - " \"$version$\":\"ftdm:abcdefg456\",\n" + - " \"$type$\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"$type$\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " \"innerNestedArray\":[\n" + - " {\"$type$\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " [{\"$type$\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100}]\n" + - " ],\n" + - " \"abc\": 100\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"$version$\":\"ftdm:abcdefg456\",\n" + - " \"$type$\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"$type$\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " \"innerNestedArray\":[\n" + - " {\"$type$\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " [{\"$type$\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100}]\n" + - " ],\n" + - " \"abc\": 100\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"$version$\":\"ftdm:abcdefg123\", \n" + - " \"$type$\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"$type$\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"$type$\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"$type$\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNull() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"$version$\":\"ftdm:abcdefg456\",\n" + - " \"$type$\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"$type$\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null},\n" + - " \"innerNestedArray\":[\n" + - " {\"$type$\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null},\n" + - " [{\"$type$\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null}]\n" + - " ],\n" + - " \"abc\": null\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"$version$\":\"ftdm:abcdefg123\", \n" + - " \"$type$\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"$type$\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"$type$\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"$type$\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNonDefault() throws JsonProcessingException, NoSuchMethodException - { - exception(() -> downcast("{\n" + - " \"$version$\":\"ftdm:abcdefg456\",\n" + - " \"$type$\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"$type$\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " \"innerNestedArray\":[\n" + - " {\"$type$\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " [{\"$type$\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100}]\n" + - " ],\n" + - " \"abc\": 300\n" + - "}", "ftdm:abcdefg123"), - "Cannot remove non-default value:300"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastVersionNullTest.java b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastVersionNullTest.java deleted file mode 100644 index b52338ce3af..00000000000 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-compiler/src/test/java/org/finos/legend/engine/changetoken/generation/GenerateCastVersionNullTest.java +++ /dev/null @@ -1,138 +0,0 @@ -// Copyright 2024 Goldman Sachs -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package org.finos.legend.engine.changetoken.generation; - -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -public class GenerateCastVersionNullTest extends GenerateCastTestBase -{ - @BeforeClass - public static void setupSuite() throws IOException, ClassNotFoundException - { - setupSuiteFromJson("{\n" + - " \"@type\": \"meta::pure::changetoken::Versions\",\n" + - " \"versions\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg123\"\n" + - " },\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::Version\",\n" + - " \"version\": \"ftdm:abcdefg456\",\n" + - " \"prevVersion\": \"ftdm:abcdefg123\",\n" + - " \"changeTokens\": [\n" + - " {\n" + - " \"@type\": \"meta::pure::changetoken::AddField\",\n" + - " \"fieldName\": \"abc\",\n" + - " \"fieldType\": \"Integer[1]\",\n" + - " \"defaultValue\": {\n" + - " \"@type\": \"meta::pure::changetoken::ConstValue\",\n" + - " \"value\": 100\n" + - " },\n" + - " \"safeCast\": true,\n" + - " \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}\n", "@type", null); - } - - @Test - public void testUpcast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(upcast("{\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}", "ftdm:abcdefg123"), - "{\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100}]\n" + - " ],\n" + - " \"abc\": 100\n" + - "}\n"); - } - - @Test - public void testDowncast() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100}]\n" + - " ],\n" + - " \"abc\": 100\n" + - "}", "ftdm:abcdefg123", "ftdm:abcdefg456"), - "{\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNull() throws JsonProcessingException, NoSuchMethodException, InvocationTargetException, IllegalAccessException - { - expect(downcast("{\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null}]\n" + - " ],\n" + - " \"abc\": null\n" + - "}", "ftdm:abcdefg123", "ftdm:abcdefg456"), - "{\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n" + - " ]\n" + - "}\n"); - } - - @Test - public void testDowncastNonDefault() throws JsonProcessingException, NoSuchMethodException - { - exception(() -> downcast("{\n" + - " \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n" + - " \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " \"innerNestedArray\":[\n" + - " {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n" + - " [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100}]\n" + - " ],\n" + - " \"abc\": 300\n" + - "}", "ftdm:abcdefg123", "ftdm:abcdefg456"), - "Cannot remove non-default value:300"); - } -} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/pom.xml b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/pom.xml index e339f63ef61..aa97761d1bc 100644 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/pom.xml +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/pom.xml @@ -84,6 +84,16 @@ legend-engine-pure-functions-unclassified-pure ${project.version} + + org.finos.legend.engine + legend-engine-pure-functions-legendCompiler-pure + ${project.version} + + + org.finos.legend.engine + legend-engine-pure-functions-javaCompiler-pure + ${project.version} + org.finos.legend.engine legend-engine-xt-javaGeneration-pure @@ -122,6 +132,21 @@ legend-engine-pure-code-compiled-core ${project.version} + + org.finos.legend.engine + legend-engine-pure-functions-unclassified-pure + ${project.version} + + + org.finos.legend.engine + legend-engine-pure-functions-legendCompiler-pure + ${project.version} + + + org.finos.legend.engine + legend-engine-pure-functions-javaCompiler-pure + ${project.version} + org.finos.legend.engine legend-engine-xt-javaGeneration-pure @@ -159,10 +184,19 @@ org.finos.legend.engine legend-engine-pure-runtime-java-extension-compiled-functions-unclassified + + org.finos.legend.engine + legend-engine-pure-runtime-java-extension-compiled-functions-legendCompiler + test + org.finos.legend.engine legend-engine-pure-runtime-java-extension-compiled-functions-json + + org.finos.legend.engine + legend-engine-pure-runtime-java-extension-compiled-functions-javaCompiler + org.finos.legend.engine legend-engine-pure-platform-dsl-store-java diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken.definition.json b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken.definition.json index 55fabf81525..daac246ac65 100644 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken.definition.json +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken.definition.json @@ -1,5 +1,5 @@ { "name" : "core_pure_changetoken", "pattern" : "(meta::pure::changetoken)(::.*)?", - "dependencies" : ["platform", "core_functions_unclassified", "core_functions_json", "core", "core_external_language_java"] + "dependencies" : ["platform", "core_functions_unclassified", "core_functions_json", "core", "core_external_language_java", "core_external_language_java_compiler"] } diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test.pure index 29c95376b47..ccfc01b291c 100644 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test.pure +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test.pure @@ -12,6 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. +import meta::external::language::java::serialization::*; +import meta::external::language::java::compiler::*; +import meta::external::language::java::factory::*; +import meta::external::language::java::metamodel::project::*; +import meta::json::*; +import meta::pure::changetoken::*; import meta::pure::changetoken::cast_generation::*; import meta::pure::changetoken::tests::*; @@ -54,3 +60,94 @@ function <> meta::pure::changetoken::tests::assertExtractTypeMul assertEquals($min, $multiplicity->getLowerBound()); assertEquals($max, if($multiplicity->hasUpperBound(), | $multiplicity->getUpperBound(), | [])); } + +function meta::pure::changetoken::tests::setupSuiteFromJson(json: String[1]): meta::external::language::java::metamodel::Class[1] +{ + $json->setupSuiteFromJson('@type', 'version', true, false, true); +} + +function meta::pure::changetoken::tests::setupSuiteFromJson(json: String[1], alwaysStampAtRootVersion: Boolean[1], optionalStampAllVersions: Boolean[1], obsoleteJsonAsString: Boolean[1]): meta::external::language::java::metamodel::Class[1] +{ + $json->setupSuiteFromJson('@type', 'version', $alwaysStampAtRootVersion, $optionalStampAllVersions, $obsoleteJsonAsString); +} + +function meta::pure::changetoken::tests::setupSuiteFromJson(json: String[1], typeKeyName: String[1], versionKeyName: String[0..1]): meta::external::language::java::metamodel::Class[1] +{ + $json->setupSuiteFromJson($typeKeyName, $versionKeyName, true, false, true); +} + +function meta::pure::changetoken::tests::setupSuiteFromJson(json: String[1], typeKeyName: String[1], versionKeyName: String[0..1], alwaysStampAtRootVersion: Boolean[1], optionalStampAllVersions: Boolean[1], obsoleteJsonAsString: Boolean[1]): meta::external::language::java::metamodel::Class[1] +{ + $json->jsonToVersions($typeKeyName)->setupSuiteFromVersions($typeKeyName, $versionKeyName, $alwaysStampAtRootVersion, $optionalStampAllVersions, $obsoleteJsonAsString); +} + +function meta::pure::changetoken::tests::setupSuiteFromVersions(versions: Versions[1]): meta::external::language::java::metamodel::Class[1] +{ + $versions->setupSuiteFromVersions('@type', 'version', true, false, true); +} + +function meta::pure::changetoken::tests::setupSuiteFromVersions(versions: Versions[1], typeKeyName: String[1], versionKeyName: String[0..1], alwaysStampAtRootVersion: Boolean[1], optionalStampAllVersions: Boolean[1], obsoleteJsonAsString: Boolean[1]): meta::external::language::java::metamodel::Class[1] +{ + let project = generateCastFromVersions($alwaysStampAtRootVersion, $optionalStampAllVersions, $obsoleteJsonAsString, $typeKeyName, $versionKeyName, $versions, 'TestCast'); + let classes = allClasses($project); + $classes->toOne(); +} + +function meta::pure::changetoken::tests::upcast(class: meta::external::language::java::metamodel::Class[1], json: String[1]): meta::external::language::java::metamodel::Class[1] +{ + $class->addMethod(javaMethod(['public', 'static'], javaMap(javaString(), javaObject()), 'test', [], j_return($class->j_invoke('upcast', $json->parseJSON()->inlineJsonValue(), javaMap(javaString(), javaObject()))))); +} + +function meta::pure::changetoken::tests::upcast(class: meta::external::language::java::metamodel::Class[1], json: String[1], currentVersion: String[1]): meta::external::language::java::metamodel::Class[1] +{ + $class->addMethod(javaMethod(['public', 'static'], javaMap(javaString(), javaObject()), 'test', [], j_return($class->j_invoke('upcast', [$json->parseJSON()->inlineJsonValue(), j_string($currentVersion)], javaMap(javaString(), javaObject()))))); +} + +function meta::pure::changetoken::tests::downcast(class: meta::external::language::java::metamodel::Class[1], json: String[1], targetVersion: String[1]): meta::external::language::java::metamodel::Class[1] +{ + $class->addMethod(javaMethod(['public', 'static'], javaMap(javaString(), javaObject()), 'test', [], j_return($class->j_invoke('downcast', [$json->parseJSON()->inlineJsonValue(), j_string($targetVersion)], javaMap(javaString(), javaObject()))))); +} + +function meta::pure::changetoken::tests::downcast(class: meta::external::language::java::metamodel::Class[1], json: String[1], targetVersion: String[1], currentVersion: String[1]): meta::external::language::java::metamodel::Class[1] +{ + $class->addMethod(javaMethod(['public', 'static'], javaMap(javaString(), javaObject()), 'test', [], j_return($class->j_invoke('downcast', [$json->parseJSON()->inlineJsonValue(), j_string($targetVersion), j_string($currentVersion)], javaMap(javaString(), javaObject()))))); +} + +function meta::pure::changetoken::tests::versions(class: meta::external::language::java::metamodel::Class[1]): meta::external::language::java::metamodel::Class[1] +{ + $class->addMethod(javaMethod(['public', 'static'], javaList(javaString()), 'test', [], j_return($class->j_invoke('versions', [])))); +} + +function meta::pure::changetoken::tests::expect(class: meta::external::language::java::metamodel::Class[1], json: String[1]): Boolean[1] +{ + let ret = compileAndExecuteJava($class, ^CompilationConfiguration(classpath=[]), ^ExecutionConfiguration(class='org.finos.legend.engine.generated.meta.pure.changetoken.cast_generation.TestCast', method='test')); + assert($ret.compilationResult.errors->isEmpty(), | $ret.compilationResult.errors->joinStrings('expected no errors, got: \'', '\', \'', '\'')); + assert($ret.compilationResult.successful, | 'expected successful compilation'); + assert($ret.executionResult->toOne().error->isEmpty(), | 'expected no execution error, got: ' + $ret.executionResult->toOne().error->toOne()); + assert($ret.executionResult->toOne().successful, | 'expected successful execution'); + assert(!$ret.executionResult->isEmpty(), | 'expected non-empty execution result'); + let retJson = $ret.executionResult->toOne().returnValue->toOne()->toCompactJSONString(); + assert($retJson->parseJSON()->sort()->toCompactJSONString() == $json->parseJSON()->sort()->toCompactJSONString(), | 'unexpected return value, got: ' + $retJson); +} + +function meta::pure::changetoken::tests::exception(class: meta::external::language::java::metamodel::Class[1], error: String[1]): Boolean[1] +{ + let ret = compileAndExecuteJava($class, ^CompilationConfiguration(classpath=[]), ^ExecutionConfiguration(class='org.finos.legend.engine.generated.meta.pure.changetoken.cast_generation.TestCast', method='test')); + assert($ret.compilationResult.errors->isEmpty(), | $ret.compilationResult.errors->joinStrings('expected no errors, got: \'', '\', \'', '\'')); + assert($ret.compilationResult.successful, | 'expected successful compilation'); + assert($ret.executionResult->toOne().error->isEmpty()->not(), | 'expected execution error'); + assert($ret.executionResult->toOne().successful->not(), | 'expected not successful execution'); + assert(!$ret.executionResult->isEmpty(), | 'expected non-empty execution result'); + assert($ret.executionResult->toOne().returnValue->isEmpty(), | 'unexpected no return value, got: ' + $ret.executionResult->toOne().returnValue->toOne()->toString()); + assert($ret.executionResult->toOne().error->toOne()->toString()->contains($error), | 'expected execution error, got: ' + $ret.executionResult->toOne().error->toOne()->toString()); +} + +function <> meta::pure::changetoken::tests::toCompactJSONString(json:JavaValue[1]):String[1] +{ + $json->match([ + s:JavaObject[1] | if($s.class->in(['java.lang.Boolean', 'java.lang.Integer', 'java.lang.Double']), | $s.string, | '"' + $s.string->meta::json::escape() + '"'), + n:JavaNull[1] | 'null', + a:JavaIterable[1] | $a.values->map(v | $v->toCompactJSONString())->joinStrings('[', ',', ']'), + o:JavaMap[1] | $o.keyValuePairs->map(kv | $kv.first->toCompactJSONString() + ':' + $kv.second->toCompactJSONString())->joinStrings('{', ',', '}') + ]) +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test2.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test2.pure new file mode 100644 index 00000000000..646cec92e5a --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test2.pure @@ -0,0 +1,100 @@ +// Copyright 2023 Goldman Sachs +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import meta::pure::changetoken::tests::test2::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::test2::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' \"@type\": \"meta::pure::changetoken::Versions\",\n' + + ' \"versions\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg123\"\n' + + ' },\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg456\",\n' + + ' \"prevVersion\": \"ftdm:abcdefg123\",\n' + + ' \"changeTokens\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::AddField\",\n' + + ' \"fieldName\": \"abc\",\n' + + ' \"fieldType\": \"Integer[1]\",\n' + + ' \"defaultValue\": {\n' + + ' \"@type\": \"meta::pure::changetoken::CopyValue\",\n' + + ' \"source\": {\n' + + ' \"@type\": \"meta::pure::changetoken::RelativeFieldReference\",\n' + + ' \"path\": \"../existingValue\"\n' + + ' }\n' + + ' },\n' + + ' \"safeCast\": true,\n' + + ' \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::test2::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' \"version\": \"ftdm:abcdefg123\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SomeClassWithAnArray\",\n' + + ' \"array\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::tests::OuterClass\",\n' + + ' \"existingValue\": \"someValue\",\n' + + ' \"innerObject\": {\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\"\n' + + ' }\n' + + ' }\n' + + ' ]\n' + + '}\n'), + '{\n' + + ' \"version\": \"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SomeClassWithAnArray\",\n' + + ' \"array\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::tests::OuterClass\",\n' + + ' \"existingValue\": \"someValue\",\n' + + ' \"innerObject\": {\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"abc\": \"someValue\"\n' + + ' }\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::test2::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::OuterClass\",\n' + + ' \"existingValue\": \"someValue\",\n' + + ' \"innerObject\": {\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"abc\": \"someValue\"\n' + + ' }\n' + + '}\n', 'ftdm:abcdefg123'), + '{\n' + + ' \"version\":\"ftdm:abcdefg123\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::OuterClass\",\n' + + ' \"existingValue\": \"someValue\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}\n' + + '}\n'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test3.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test3.pure new file mode 100644 index 00000000000..6854748bc93 --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test3.pure @@ -0,0 +1,107 @@ +// Copyright 2023 Goldman Sachs +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import meta::pure::changetoken::tests::test3::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::test3::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' \"@type\": \"meta::pure::changetoken::Versions\",\n' + + ' \"versions\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg123\"\n' + + ' },\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg456\",\n' + + ' \"prevVersion\": \"ftdm:abcdefg123\",\n' + + ' \"changeTokens\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::ChangeFieldType\",\n' + + ' \"fieldName\": \"abc\",\n' + + ' \"oldFieldType\": \"Integer[1]\",\n' + + ' \"newFieldType\": \"String[1]\",\n' + + ' \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::test3::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' \"version\": \"ftdm:abcdefg123\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SomeClassWithAnArray\",\n' + + ' \"array\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::tests::OuterClass\",\n' + + ' \"existingValue\": \"someValue\",\n' + + ' \"innerObject\": {\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"abc\": 123\n' + + ' }\n' + + ' }\n' + + ' ]\n' + + '}\n'), + '{\n' + + ' \"version\": \"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SomeClassWithAnArray\",\n' + + ' \"array\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::tests::OuterClass\",\n' + + ' \"existingValue\": \"someValue\",\n' + + ' \"innerObject\": {\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"abc\": \"123\"\n' + + ' }\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::test3::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' \"version\": \"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SomeClassWithAnArray\",\n' + + ' \"array\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::tests::OuterClass\",\n' + + ' \"existingValue\": \"someValue\",\n' + + ' \"innerObject\": {\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"abc\": \"123\"\n' + + ' }\n' + + ' }\n' + + ' ]\n' + + '}\n', 'ftdm:abcdefg123'), + '{\n' + + ' \"version\": \"ftdm:abcdefg123\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SomeClassWithAnArray\",\n' + + ' \"array\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::tests::OuterClass\",\n' + + ' \"existingValue\": \"someValue\",\n' + + ' \"innerObject\": {\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"abc\": 123\n' + + ' }\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test4.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test4.pure new file mode 100644 index 00000000000..391bad94247 --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test4.pure @@ -0,0 +1,107 @@ +// Copyright 2023 Goldman Sachs +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import meta::pure::changetoken::tests::test4::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::test4::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' \"@type\": \"meta::pure::changetoken::Versions\",\n' + + ' \"versions\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg123\"\n' + + ' },\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg456\",\n' + + ' \"prevVersion\": \"ftdm:abcdefg123\",\n' + + ' \"changeTokens\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::ChangeFieldType\",\n' + + ' \"fieldName\": \"abc\",\n' + + ' \"oldFieldType\": \"String[1]\",\n' + + ' \"newFieldType\": \"String[0..1]\",\n' + + ' \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::test4::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' \"version\": \"ftdm:abcdefg123\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SomeClassWithAnArray\",\n' + + ' \"array\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::tests::OuterClass\",\n' + + ' \"existingValue\": \"someValue\",\n' + + ' \"innerObject\": {\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"abc\": 123\n' + + ' }\n' + + ' }\n' + + ' ]\n' + + '}\n'), + '{\n' + + ' \"version\": \"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SomeClassWithAnArray\",\n' + + ' \"array\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::tests::OuterClass\",\n' + + ' \"existingValue\": \"someValue\",\n' + + ' \"innerObject\": {\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"abc\": 123\n' + + ' }\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::test4::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' \"version\": \"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SomeClassWithAnArray\",\n' + + ' \"array\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::tests::OuterClass\",\n' + + ' \"existingValue\": \"someValue\",\n' + + ' \"innerObject\": {\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"abc\": \"123\"\n' + + ' }\n' + + ' }\n' + + ' ]\n' + + '}\n', 'ftdm:abcdefg123'), + '{\n' + + ' \"version\": \"ftdm:abcdefg123\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SomeClassWithAnArray\",\n' + + ' \"array\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::tests::OuterClass\",\n' + + ' \"existingValue\": \"someValue\",\n' + + ' \"innerObject\": {\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"abc\": \"123\"\n' + + ' }\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_boolean.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_boolean.pure new file mode 100644 index 00000000000..7f1ef626774 --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_boolean.pure @@ -0,0 +1,108 @@ +// Copyright 2023 Goldman Sachs +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import meta::pure::changetoken::tests::boolean::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::boolean::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' \"@type\": \"meta::pure::changetoken::Versions\",\n' + + ' \"versions\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg123\"\n' + + ' },\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg456\",\n' + + ' \"prevVersion\": \"ftdm:abcdefg123\",\n' + + ' \"changeTokens\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::AddField\",\n' + + ' \"fieldName\": \"abc\",\n' + + ' \"fieldType\": \"Boolean[1]\",\n' + + ' \"defaultValue\": {\n' + + ' \"@type\": \"meta::pure::changetoken::ConstValue\",\n' + + ' \"value\": true\n' + + ' },\n' + + ' \"safeCast\": true,\n' + + ' \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::boolean::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}'), + '{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": true},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": true},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": true}]\n' + + ' ],\n' + + ' \"abc\": true\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::boolean::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": true},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": true},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": true}]\n' + + ' ],\n' + + ' \"abc\": true\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::boolean::testDowncastNonDefault(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": true},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": true},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": true}]\n' + + ' ],\n' + + ' \"abc\": false\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot remove non-default value:false'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_boolean_string.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_boolean_string.pure new file mode 100644 index 00000000000..95ffe54d3a1 --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_boolean_string.pure @@ -0,0 +1,108 @@ +// Copyright 2023 Goldman Sachs +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import meta::pure::changetoken::tests::boolean::string::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::boolean::string::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' \"@type\": \"meta::pure::changetoken::Versions\",\n' + + ' \"versions\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg123\"\n' + + ' },\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg456\",\n' + + ' \"prevVersion\": \"ftdm:abcdefg123\",\n' + + ' \"changeTokens\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::AddField\",\n' + + ' \"fieldName\": \"abc\",\n' + + ' \"fieldType\": \"Boolean[1]\",\n' + + ' \"defaultValue\": {\n' + + ' \"@type\": \"meta::pure::changetoken::ConstValue\",\n' + + ' \"value\": \"true\"\n' + + ' },\n' + + ' \"safeCast\": true,\n' + + ' \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::boolean::string::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}'), + '{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": true},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": true},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": true}]\n' + + ' ],\n' + + ' \"abc\": true\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::boolean::string::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": true},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": true},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": true}]\n' + + ' ],\n' + + ' \"abc\": true\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::boolean::string::testDowncastNonDefault(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": true},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": true},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": true}]\n' + + ' ],\n' + + ' \"abc\": false\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot remove non-default value:false'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_chain.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_chain.pure new file mode 100644 index 00000000000..b22645fcf3a --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_chain.pure @@ -0,0 +1,131 @@ +// Copyright 2023 Goldman Sachs +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import meta::pure::changetoken::tests::chain::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::chain::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' \"@type\": \"meta::pure::changetoken::Versions\",\n' + + ' \"versions\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg123\"\n' + + ' },\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg456\",\n' + + ' \"prevVersion\": \"ftdm:abcdefg123\",\n' + + ' \"changeTokens\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::AddField\",\n' + + ' \"fieldName\": \"abc\",\n' + + ' \"fieldType\": \"Integer[1]\",\n' + + ' \"defaultValue\": {\n' + + ' \"@type\": \"meta::pure::changetoken::ConstValue\",\n' + + ' \"value\": 100\n' + + ' },\n' + + ' \"safeCast\": true,\n' + + ' \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n' + + ' }\n' + + ' ]\n' + + ' },\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg789\",\n' + + ' \"prevVersion\": \"ftdm:abcdefg456\",\n' + + ' \"changeTokens\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::AddField\",\n' + + ' \"fieldName\": \"def\",\n' + + ' \"fieldType\": \"Integer[1]\",\n' + + ' \"defaultValue\": {\n' + + ' \"@type\": \"meta::pure::changetoken::ConstValue\",\n' + + ' \"value\": 200\n' + + ' },\n' + + ' \"safeCast\": true,\n' + + ' \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::chain::testVersions(): Any[*] +{ + expect(setupSuite()->versions(), '["ftdm:abcdefg123", "ftdm:abcdefg456", "ftdm:abcdefg789"]'); +} + +function <> meta::pure::changetoken::tests::chain::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}'), + '{\n' + + ' \"version\":\"ftdm:abcdefg789\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100, \"def\": 200},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100, \"def\": 200},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100, \"def\": 200}]\n' + + ' ],\n' + + ' \"abc\": 100, \"def\": 200\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::chain::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg789\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100, \"def\": 200},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100, \"def\": 200},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100, \"def\": 200}]\n' + + ' ],\n' + + ' \"abc\": 100, \"def\": 200\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::chain::testDowncastNonDefault(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg789\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100, \"def\": 200},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100, \"def\": 200},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100, \"def\": 200}]\n' + + ' ],\n' + + ' \"abc\": 100, \"def\": 300\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot remove non-default value:300'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_custom.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_custom.pure new file mode 100644 index 00000000000..bc26a570911 --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_custom.pure @@ -0,0 +1,108 @@ +// Copyright 2023 Goldman Sachs +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import meta::pure::changetoken::tests::custom::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::custom::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' \"@type\": \"meta::pure::changetoken::Versions\",\n' + + ' \"versions\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg123\"\n' + + ' },\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg456\",\n' + + ' \"prevVersion\": \"ftdm:abcdefg123\",\n' + + ' \"changeTokens\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::AddField\",\n' + + ' \"fieldName\": \"abc\",\n' + + ' \"fieldType\": \"Custom[1]\",\n' + + ' \"defaultValue\": {\n' + + ' \"@type\": \"meta::pure::changetoken::ConstValue\",\n' + + ' \"value\": \"{\\\"@type\\\":\\\"Custom\\\",\\\"value\\\":\\\"0d\\\"}\"\n' + + ' },\n' + + ' \"safeCast\": true,\n' + + ' \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}'), + '{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"0d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"0d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"0d\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"value\":\"0d\"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"0d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"0d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"0d\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"value\":\"0d\"}\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::testDowncastNonDefault(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"0d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"0d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"0d\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot remove non-default value:{@type=Custom, value=1d}'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_custom_array_boolean.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_custom_array_boolean.pure new file mode 100644 index 00000000000..a30a30bf497 --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_custom_array_boolean.pure @@ -0,0 +1,108 @@ +// Copyright 2024 Goldman Sachs +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import meta::pure::changetoken::tests::custom::array::boolean::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::custom::array::boolean::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' \"@type\": \"meta::pure::changetoken::Versions\",\n' + + ' \"versions\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg123\"\n' + + ' },\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg456\",\n' + + ' \"prevVersion\": \"ftdm:abcdefg123\",\n' + + ' \"changeTokens\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::AddField\",\n' + + ' \"fieldName\": \"abc\",\n' + + ' \"fieldType\": \"Boolean[*]\",\n' + + ' \"defaultValue\": {\n' + + ' \"@type\": \"meta::pure::changetoken::ConstValue\",\n' + + ' \"value\": [true]\n' + + ' },\n' + + ' \"safeCast\": true,\n' + + ' \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::array::boolean::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}'), + '{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [true]},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [true]},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [true]}]\n' + + ' ],\n' + + ' \"abc\": [true]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::array::boolean::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [true]},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [true]},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [true]}]\n' + + ' ],\n' + + ' \"abc\": [true]\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::array::boolean::testDowncastNonDefault(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [true]},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [true]},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [true]}]\n' + + ' ],\n' + + ' \"abc\":[false]\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot remove non-default value:[false]'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_custom_array_embedded.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_custom_array_embedded.pure new file mode 100644 index 00000000000..bb296834e89 --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_custom_array_embedded.pure @@ -0,0 +1,108 @@ +// Copyright 2024 Goldman Sachs +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import meta::pure::changetoken::tests::custom::array::embedded::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::custom::array::embedded::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' \"@type\": \"meta::pure::changetoken::Versions\",\n' + + ' \"versions\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg123\"\n' + + ' },\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg456\",\n' + + ' \"prevVersion\": \"ftdm:abcdefg123\",\n' + + ' \"changeTokens\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::AddField\",\n' + + ' \"fieldName\": \"abc\",\n' + + ' \"fieldType\": \"Integer[*]\",\n' + + ' \"defaultValue\": {\n' + + ' \"@type\": \"meta::pure::changetoken::ConstValue\",\n' + + ' \"value\": \"[1,2,3]\"\n' + + ' },\n' + + ' \"safeCast\": true,\n' + + ' \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::array::embedded::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}'), + '{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1,2,3]},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1,2,3]},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1,2,3]}]\n' + + ' ],\n' + + ' \"abc\": [1,2,3]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::array::embedded::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1,2,3]},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1,2,3]},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1,2,3]}]\n' + + ' ],\n' + + ' \"abc\": [1,2,3]\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::array::embedded::testDowncastNonDefault(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1,2,3]},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1,2,3]},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1,2,3]}]\n' + + ' ],\n' + + ' \"abc\":[5,6,7]\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot remove non-default value:[5, 6, 7]'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_custom_array_float.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_custom_array_float.pure new file mode 100644 index 00000000000..081a30f85ef --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_custom_array_float.pure @@ -0,0 +1,108 @@ +// Copyright 2024 Goldman Sachs +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import meta::pure::changetoken::tests::custom::array::float::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::custom::array::float::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' \"@type\": \"meta::pure::changetoken::Versions\",\n' + + ' \"versions\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg123\"\n' + + ' },\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg456\",\n' + + ' \"prevVersion\": \"ftdm:abcdefg123\",\n' + + ' \"changeTokens\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::AddField\",\n' + + ' \"fieldName\": \"abc\",\n' + + ' \"fieldType\": \"Float[*]\",\n' + + ' \"defaultValue\": {\n' + + ' \"@type\": \"meta::pure::changetoken::ConstValue\",\n' + + ' \"value\": [1.2, 3.4]\n' + + ' },\n' + + ' \"safeCast\": true,\n' + + ' \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::array::float::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}'), + '{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1.2, 3.4]},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1.2, 3.4]},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1.2, 3.4]}]\n' + + ' ],\n' + + ' \"abc\": [1.2, 3.4]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::array::float::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1.2, 3.4]},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1.2, 3.4]},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1.2, 3.4]}]\n' + + ' ],\n' + + ' \"abc\": [1.2, 3.4]\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::array::float::testDowncastNonDefault(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1.2, 3.4]},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1.2, 3.4]},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1.2, 3.4]}]\n' + + ' ],\n' + + ' \"abc\":[5.6, 7.8]\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot remove non-default value:[5.6, 7.8]'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_custom_array_integer.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_custom_array_integer.pure new file mode 100644 index 00000000000..f68ddbde6d4 --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_custom_array_integer.pure @@ -0,0 +1,108 @@ +// Copyright 2024 Goldman Sachs +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import meta::pure::changetoken::tests::custom::array::integer::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::custom::array::integer::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' \"@type\": \"meta::pure::changetoken::Versions\",\n' + + ' \"versions\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg123\"\n' + + ' },\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg456\",\n' + + ' \"prevVersion\": \"ftdm:abcdefg123\",\n' + + ' \"changeTokens\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::AddField\",\n' + + ' \"fieldName\": \"abc\",\n' + + ' \"fieldType\": \"Integer[*]\",\n' + + ' \"defaultValue\": {\n' + + ' \"@type\": \"meta::pure::changetoken::ConstValue\",\n' + + ' \"value\": [1,2,3]\n' + + ' },\n' + + ' \"safeCast\": true,\n' + + ' \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::array::integer::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}'), + '{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1,2,3]},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1,2,3]},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1,2,3]}]\n' + + ' ],\n' + + ' \"abc\": [1,2,3]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::array::integer::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1,2,3]},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1,2,3]},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1,2,3]}]\n' + + ' ],\n' + + ' \"abc\": [1,2,3]\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::array::integer::testDowncastNonDefault(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1,2,3]},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1,2,3]},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [1,2,3]}]\n' + + ' ],\n' + + ' \"abc\":[5,6,7]\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot remove non-default value:[5, 6, 7]'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_custom_array_object.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_custom_array_object.pure new file mode 100644 index 00000000000..459dada56ac --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_custom_array_object.pure @@ -0,0 +1,113 @@ +// Copyright 2024 Goldman Sachs +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import meta::pure::changetoken::tests::custom::array::object::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::custom::array::object::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' \"@type\": \"meta::pure::changetoken::Versions\",\n' + + ' \"versions\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg123\"\n' + + ' },\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg456\",\n' + + ' \"prevVersion\": \"ftdm:abcdefg123\",\n' + + ' \"changeTokens\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::AddField\",\n' + + ' \"fieldName\": \"abc\",\n' + + ' \"fieldType\": \"Custom[1..*]\",\n' + + ' \"defaultValue\": {\n' + + ' \"@type\": \"meta::pure::changetoken::ConstValue\",\n' + + ' \"value\": [\n' + + ' {\n' + + ' \"@type\": \"Custom\",\n' + + ' \"value\": 4.2\n' + + ' }\n' + + ' ]\n' + + ' },\n' + + ' \"safeCast\": true,\n' + + ' \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::array::object::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}'), + '{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [{\"@type\": \"Custom\",\"value\": 4.2}]},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [{\"@type\": \"Custom\",\"value\": 4.2}]},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [{\"@type\": \"Custom\",\"value\": 4.2}]}]\n' + + ' ],\n' + + ' \"abc\": [{\"@type\": \"Custom\",\"value\": 4.2}]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::array::object::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [{\"@type\": \"Custom\",\"value\": 4.2}]},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [{\"@type\": \"Custom\",\"value\": 4.2}]},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [{\"@type\": \"Custom\",\"value\": 4.2}]}]\n' + + ' ],\n' + + ' \"abc\": [{\"@type\": \"Custom\",\"value\": 4.2}]\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::array::object::testDowncastNonDefault(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [{\"@type\": \"Custom\",\"value\": 4.2}]},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [{\"@type\": \"Custom\",\"value\": 4.2}]},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [{\"@type\": \"Custom\",\"value\": 4.2}]}]\n' + + ' ],\n' + + ' \"abc\":[{\"@type\": \"Custom\",\"value\": 8.8}]\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot remove non-default value:[{@type=Custom, value=8.8}]'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_custom_array_string.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_custom_array_string.pure new file mode 100644 index 00000000000..e65ea29e22a --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_custom_array_string.pure @@ -0,0 +1,111 @@ +// Copyright 2024 Goldman Sachs +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import meta::pure::changetoken::tests::custom::array::string::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::custom::array::string::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' \"@type\": \"meta::pure::changetoken::Versions\",\n' + + ' \"versions\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg123\"\n' + + ' },\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg456\",\n' + + ' \"prevVersion\": \"ftdm:abcdefg123\",\n' + + ' \"changeTokens\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::AddField\",\n' + + ' \"fieldName\": \"abc\",\n' + + ' \"fieldType\": \"String[1..*]\",\n' + + ' \"defaultValue\": {\n' + + ' \"@type\": \"meta::pure::changetoken::ConstValue\",\n' + + ' \"value\": [\n' + + ' \"Foo\",\n' + + ' \"Bar\"\n' + + ' ]\n' + + ' },\n' + + ' \"safeCast\": true,\n' + + ' \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::array::string::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}'), + '{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [\"Foo\", \"Bar\"]},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [\"Foo\", \"Bar\"]},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [\"Foo\", \"Bar\"]}]\n' + + ' ],\n' + + ' \"abc\": [\"Foo\", \"Bar\"]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::array::string::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [\"Foo\", \"Bar\"]},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [\"Foo\", \"Bar\"]},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [\"Foo\", \"Bar\"]}]\n' + + ' ],\n' + + ' \"abc\": [\"Foo\", \"Bar\"]\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::array::string::testDowncastNonDefault(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [\"Foo\", \"Bar\"]},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [\"Foo\", \"Bar\"]},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": [\"Foo\", \"Bar\"]}]\n' + + ' ],\n' + + ' \"abc\":[\"Something\",\"Else\"]\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot remove non-default value:[Something, Else]'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_custom_empty.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_custom_empty.pure new file mode 100644 index 00000000000..f8b7c2c379e --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_custom_empty.pure @@ -0,0 +1,108 @@ +// Copyright 2024 Goldman Sachs +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import meta::pure::changetoken::tests::custom::array::empty::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::custom::array::empty::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' \"@type\": \"meta::pure::changetoken::Versions\",\n' + + ' \"versions\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg123\"\n' + + ' },\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg456\",\n' + + ' \"prevVersion\": \"ftdm:abcdefg123\",\n' + + ' \"changeTokens\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::AddField\",\n' + + ' \"fieldName\": \"abc\",\n' + + ' \"fieldType\": \"Custom[*]\",\n' + + ' \"defaultValue\": {\n' + + ' \"@type\": \"meta::pure::changetoken::ConstValue\",\n' + + ' \"value\": []\n' + + ' },\n' + + ' \"safeCast\": true,\n' + + ' \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::array::empty::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}'), + '{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": []},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": []},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": []}]\n' + + ' ],\n' + + ' \"abc\": []\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::array::empty::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": []},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": []},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": []}]\n' + + ' ],\n' + + ' \"abc\": []\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::array::empty::testDowncastNonDefault(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": []},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": []},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": []}]\n' + + ' ],\n' + + ' \"abc\": [\"2023-06-22T18:30:01Z\"]\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot remove non-default value:[2023-06-22T18:30:01Z]'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_custom_map.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_custom_map.pure new file mode 100644 index 00000000000..a75a5fb234e --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_custom_map.pure @@ -0,0 +1,83 @@ +// Copyright 2024 Goldman Sachs +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import meta::pure::changetoken::tests::custom::map::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::custom::map::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + let versions = meta::pure::changetoken::tests::getVersionsCustomMap(); + setupSuiteFromVersions($versions); +} + +function <> meta::pure::changetoken::tests::custom::map::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}'), + '{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::map::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::map::testDowncastNonDefault(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.0}, \"value\":1}\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot remove non-default value:{@type=Custom, restricted=true, range={min=-1, round=0.0, max=1, @type=intMinMax}, value=1}'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_custom_nested.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_custom_nested.pure new file mode 100644 index 00000000000..9c016375924 --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_custom_nested.pure @@ -0,0 +1,108 @@ +// Copyright 2023 Goldman Sachs +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import meta::pure::changetoken::tests::custom::nested::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::custom::nested::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' \"@type\": \"meta::pure::changetoken::Versions\",\n' + + ' \"versions\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg123\"\n' + + ' },\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg456\",\n' + + ' \"prevVersion\": \"ftdm:abcdefg123\",\n' + + ' \"changeTokens\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::AddField\",\n' + + ' \"fieldName\": \"abc\",\n' + + ' \"fieldType\": \"Custom[1]\",\n' + + ' \"defaultValue\": {\n' + + ' \"@type\": \"meta::pure::changetoken::ConstValue\",\n' + + ' \"value\": \"{\\\"@type\\\":\\\"Custom\\\",\\\"restricted\\\":true,\\\"value\\\":0,\\\"range\\\":{\\\"@type\\\":\\\"intMinMax\\\",\\\"min\\\":-1,\\\"max\\\":1,\\\"round\\\":0.5}}\"\n' + + ' },\n' + + ' \"safeCast\": true,\n' + + ' \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::nested::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}'), + '{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::nested::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::nested::testDowncastNonDefault(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.0}, \"value\":1}\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot remove non-default value:{@type=Custom, restricted=true, range={min=-1, round=0.0, max=1, @type=intMinMax}, value=1}'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_custom_nested_no_escaping.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_custom_nested_no_escaping.pure new file mode 100644 index 00000000000..dd6984f622d --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_custom_nested_no_escaping.pure @@ -0,0 +1,109 @@ +// Copyright 2024 Goldman Sachs +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import meta::pure::changetoken::tests::custom::nested::no::escaping::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::custom::nested::no::escaping::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' \"@type\": \"meta::pure::changetoken::Versions\",\n' + + ' \"versions\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg123\"\n' + + ' },\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg456\",\n' + + ' \"prevVersion\": \"ftdm:abcdefg123\",\n' + + ' \"changeTokens\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::AddField\",\n' + + ' \"fieldName\": \"abc\",\n' + + ' \"fieldType\": \"Custom[1]\",\n' + + ' \"defaultValue\": {\n' + + ' \"@type\": \"meta::pure::changetoken::ConstValue\",\n' + + ' \"value\": \"{\\\"@type\\\":\\\"Custom\\\",\\\"restricted\\\":true,\\\"value\\\":0,\\\"range\\\":{\\\"@type\\\":\\\"intMinMax\\\",\\\"min\\\":-1,\\\"max\\\":1,\\\"round\\\":0.5}}\"\n' + + ' },\n' + + ' \"safeCast\": true,\n' + + ' \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n', + true, false, false); +} + +function <> meta::pure::changetoken::tests::custom::nested::no::escaping::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}'), + '{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"{\\\"@type\\\":\\\"Custom\\\",\\\"restricted\\\":true,\\\"value\\\":0,\\\"range\\\":{\\\"@type\\\":\\\"intMinMax\\\",\\\"min\\\":-1,\\\"max\\\":1,\\\"round\\\":0.5}}\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"{\\\"@type\\\":\\\"Custom\\\",\\\"restricted\\\":true,\\\"value\\\":0,\\\"range\\\":{\\\"@type\\\":\\\"intMinMax\\\",\\\"min\\\":-1,\\\"max\\\":1,\\\"round\\\":0.5}}\"},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"{\\\"@type\\\":\\\"Custom\\\",\\\"restricted\\\":true,\\\"value\\\":0,\\\"range\\\":{\\\"@type\\\":\\\"intMinMax\\\",\\\"min\\\":-1,\\\"max\\\":1,\\\"round\\\":0.5}}\"}]\n' + + ' ],\n' + + ' \"abc\": \"{\\\"@type\\\":\\\"Custom\\\",\\\"restricted\\\":true,\\\"value\\\":0,\\\"range\\\":{\\\"@type\\\":\\\"intMinMax\\\",\\\"min\\\":-1,\\\"max\\\":1,\\\"round\\\":0.5}}\"\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::nested::no::escaping::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"{\\\"@type\\\":\\\"Custom\\\",\\\"restricted\\\":true,\\\"value\\\":0,\\\"range\\\":{\\\"@type\\\":\\\"intMinMax\\\",\\\"min\\\":-1,\\\"max\\\":1,\\\"round\\\":0.5}}\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"{\\\"@type\\\":\\\"Custom\\\",\\\"restricted\\\":true,\\\"value\\\":0,\\\"range\\\":{\\\"@type\\\":\\\"intMinMax\\\",\\\"min\\\":-1,\\\"max\\\":1,\\\"round\\\":0.5}}\"},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"{\\\"@type\\\":\\\"Custom\\\",\\\"restricted\\\":true,\\\"value\\\":0,\\\"range\\\":{\\\"@type\\\":\\\"intMinMax\\\",\\\"min\\\":-1,\\\"max\\\":1,\\\"round\\\":0.5}}\"}]\n' + + ' ],\n' + + ' \"abc\": \"{\\\"@type\\\":\\\"Custom\\\",\\\"restricted\\\":true,\\\"value\\\":0,\\\"range\\\":{\\\"@type\\\":\\\"intMinMax\\\",\\\"min\\\":-1,\\\"max\\\":1,\\\"round\\\":0.5}}\"\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::nested::no::escaping::testDowncastNonDefault(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"{\\\"@type\\\":\\\"Custom\\\",\\\"restricted\\\":true,\\\"value\\\":0,\\\"range\\\":{\\\"@type\\\":\\\"intMinMax\\\",\\\"min\\\":-1,\\\"max\\\":1,\\\"round\\\":0.5}}\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"{\\\"@type\\\":\\\"Custom\\\",\\\"restricted\\\":true,\\\"value\\\":0,\\\"range\\\":{\\\"@type\\\":\\\"intMinMax\\\",\\\"min\\\":-1,\\\"max\\\":1,\\\"round\\\":0.5}}\"},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"{\\\"@type\\\":\\\"Custom\\\",\\\"restricted\\\":true,\\\"value\\\":0,\\\"range\\\":{\\\"@type\\\":\\\"intMinMax\\\",\\\"min\\\":-1,\\\"max\\\":1,\\\"round\\\":0.5}}\"}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.0}, \"value\":1}\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot remove non-default value:{@type=Custom, restricted=true, range={min=-1, round=0.0, max=1, @type=intMinMax}, value=1}'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_custom_null.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_custom_null.pure new file mode 100644 index 00000000000..cd60bbf0c54 --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_custom_null.pure @@ -0,0 +1,107 @@ +// Copyright 2024 Goldman Sachs +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import meta::pure::changetoken::tests::custom::null::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::custom::null::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' \"@type\": \"meta::pure::changetoken::Versions\",\n' + + ' \"versions\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg123\"\n' + + ' },\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg456\",\n' + + ' \"prevVersion\": \"ftdm:abcdefg123\",\n' + + ' \"changeTokens\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::AddField\",\n' + + ' \"fieldName\": \"abc\",\n' + + ' \"fieldType\": \"Custom[0..1]\",\n' + + ' \"defaultValue\": {\n' + + ' \"@type\": \"meta::pure::changetoken::ConstValue\",\n' + + ' \"value\": null\n' + + ' },\n' + + ' \"safeCast\": true,\n' + + ' \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::null::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}'), + '{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null}]\n' + + ' ],\n' + + ' \"abc\": null\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::null::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::null::testDowncastNonDefault(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ],\n' + + ' \"abc\": \"2023-06-22T18:30:01Z\"\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot remove non-default value:2023-06-22T18:30:01Z'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_custom_null_keyword.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_custom_null_keyword.pure new file mode 100644 index 00000000000..74cd10e128b --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_custom_null_keyword.pure @@ -0,0 +1,107 @@ +// Copyright 2024 Goldman Sachs +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import meta::pure::changetoken::tests::custom::null::keyword::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::custom::null::keyword::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' \"@type\": \"meta::pure::changetoken::Versions\",\n' + + ' \"versions\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg123\"\n' + + ' },\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg456\",\n' + + ' \"prevVersion\": \"ftdm:abcdefg123\",\n' + + ' \"changeTokens\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::AddField\",\n' + + ' \"fieldName\": \"abc\",\n' + + ' \"fieldType\": \"Custom[0..1]\",\n' + + ' \"defaultValue\": {\n' + + ' \"@type\": \"meta::pure::changetoken::ConstValue\",\n' + + ' \"value\": \"null\"\n' + + ' },\n' + + ' \"safeCast\": true,\n' + + ' \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::null::keyword::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}'), + '{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null}]\n' + + ' ],\n' + + ' \"abc\": null\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::null::keyword::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::null::keyword::testDowncastNonDefault(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ],\n' + + ' \"abc\": \"2023-06-22T18:30:01Z\"\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot remove non-default value:2023-06-22T18:30:01Z'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_custom_null_string.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_custom_null_string.pure new file mode 100644 index 00000000000..1553b250fcd --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_custom_null_string.pure @@ -0,0 +1,107 @@ +// Copyright 2024 Goldman Sachs +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import meta::pure::changetoken::tests::custom::null::string::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::custom::null::string::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' \"@type\": \"meta::pure::changetoken::Versions\",\n' + + ' \"versions\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg123\"\n' + + ' },\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg456\",\n' + + ' \"prevVersion\": \"ftdm:abcdefg123\",\n' + + ' \"changeTokens\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::AddField\",\n' + + ' \"fieldName\": \"abc\",\n' + + ' \"fieldType\": \"Custom[0..1]\",\n' + + ' \"defaultValue\": {\n' + + ' \"@type\": \"meta::pure::changetoken::ConstValue\",\n' + + ' \"value\": \"\"\n' + + ' },\n' + + ' \"safeCast\": true,\n' + + ' \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::null::string::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}'), + '{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": null}]\n' + + ' ],\n' + + ' \"abc\": null\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::null::string::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::null::string::testDowncastNonDefault(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ],\n' + + ' \"abc\": \"2023-06-22T18:30:01Z\"\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot remove non-default value:2023-06-22T18:30:01Z'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_custom_object.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_custom_object.pure new file mode 100644 index 00000000000..96246e515ea --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_custom_object.pure @@ -0,0 +1,118 @@ +// Copyright 2023 Goldman Sachs +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import meta::pure::changetoken::tests::custom::object::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::custom::object::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' \"@type\": \"meta::pure::changetoken::Versions\",\n' + + ' \"versions\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg123\"\n' + + ' },\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg456\",\n' + + ' \"prevVersion\": \"ftdm:abcdefg123\",\n' + + ' \"changeTokens\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::AddField\",\n' + + ' \"fieldName\": \"abc\",\n' + + ' \"fieldType\": \"Custom[1]\",\n' + + ' \"defaultValue\": {\n' + + ' \"@type\": \"meta::pure::changetoken::ConstValue\",\n' + + ' \"value\": {\n' + + ' \"range\": {\n' + + ' \"min\": -1,\n' + + ' \"max\": 1,\n' + + ' \"@type\": \"intMinMax\",\n' + + ' \"round\": 0.5\n' + + ' },\n' + + ' \"@type\": \"Custom\",\n' + + ' \"restricted\": true,\n' + + ' \"value\": 0\n' + + ' }\n' + + ' },\n' + + ' \"safeCast\": true,\n' + + ' \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}'); +} + +function <> meta::pure::changetoken::tests::custom::object::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}'), + '{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::object::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::object::testDowncastNonDefault(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.0}, \"value\":1}\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot remove non-default value:{@type=Custom, restricted=true, range={min=-1, round=0.0, max=1, @type=intMinMax}, value=1}'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_custom_object_nested_version.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_custom_object_nested_version.pure new file mode 100644 index 00000000000..068e27dc37e --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_custom_object_nested_version.pure @@ -0,0 +1,119 @@ +// Copyright 2024 Goldman Sachs +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import meta::pure::changetoken::tests::custom::object::nested::version::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::custom::object::nested::version::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' \"@type\": \"meta::pure::changetoken::Versions\",\n' + + ' \"versions\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg123\"\n' + + ' },\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg456\",\n' + + ' \"prevVersion\": \"ftdm:abcdefg123\",\n' + + ' \"changeTokens\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::AddField\",\n' + + ' \"fieldName\": \"abc\",\n' + + ' \"fieldType\": \"Custom[1]\",\n' + + ' \"defaultValue\": {\n' + + ' \"@type\": \"meta::pure::changetoken::ConstValue\",\n' + + ' \"value\": {\n' + + ' \"range\": {\n' + + ' \"min\": -1,\n' + + ' \"max\": 1,\n' + + ' \"@type\": \"intMinMax\",\n' + + ' \"round\": 0.5\n' + + ' },\n' + + ' \"@type\": \"Custom\",\n' + + ' \"restricted\": true,\n' + + ' \"value\": 0\n' + + ' }\n' + + ' },\n' + + ' \"safeCast\": true,\n' + + ' \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n', + true, true, true); +} + +function <> meta::pure::changetoken::tests::custom::object::nested::version::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"version\":\"ftdm:abcdefg123\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"version\":\"ftdm:abcdefg123\"}, \n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"version\":\"ftdm:abcdefg123\"}]\n' + + ' ]\n' + + '}'), + '{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"version\":\"ftdm:abcdefg456\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"version\":\"ftdm:abcdefg456\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"version\":\"ftdm:abcdefg456\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::object::nested::version::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"version\":\"ftdm:abcdefg456\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"version\":\"ftdm:abcdefg456\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"version\":\"ftdm:abcdefg456\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"version\":\"ftdm:abcdefg123\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"version\":\"ftdm:abcdefg123\"}, \n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"version\":\"ftdm:abcdefg123\"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::custom::object::nested::version::testDowncastNonDefault(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"version\":\"ftdm:abcdefg456\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"version\":\"ftdm:abcdefg456\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"version\":\"ftdm:abcdefg456\", \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.5}, \"value\":0}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"restricted\":true, \"range\":{\"min\":-1, \"max\":1, \"@type\":\"intMinMax\", \"round\":0.0}, \"value\":1}\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot remove non-default value:{@type=Custom, restricted=true, range={min=-1, round=0.0, max=1, @type=intMinMax}, value=1}'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_custom_primitive.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_custom_primitive.pure new file mode 100644 index 00000000000..dac7be2f40a --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_custom_primitive.pure @@ -0,0 +1,108 @@ +// Copyright 2023 Goldman Sachs +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import meta::pure::changetoken::tests::primitive::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::primitive::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' \"@type\": \"meta::pure::changetoken::Versions\",\n' + + ' \"versions\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg123\"\n' + + ' },\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg456\",\n' + + ' \"prevVersion\": \"ftdm:abcdefg123\",\n' + + ' \"changeTokens\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::AddField\",\n' + + ' \"fieldName\": \"abc\",\n' + + ' \"fieldType\": \"Custom[1]\",\n' + + ' \"defaultValue\": {\n' + + ' \"@type\": \"meta::pure::changetoken::ConstValue\",\n' + + ' \"value\": \"1970-01-01T00:00:01Z\"\n' + + ' },\n' + + ' \"safeCast\": true,\n' + + ' \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::primitive::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}'), + '{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"1970-01-01T00:00:01Z\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"1970-01-01T00:00:01Z\"},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"1970-01-01T00:00:01Z\"}]\n' + + ' ],\n' + + ' \"abc\": \"1970-01-01T00:00:01Z\"\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::primitive::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"1970-01-01T00:00:01Z\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"1970-01-01T00:00:01Z\"},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"1970-01-01T00:00:01Z\"}]\n' + + ' ],\n' + + ' \"abc\": \"1970-01-01T00:00:01Z\"\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::primitive::testDowncastNonDefault(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"1970-01-01T00:00:01Z\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"1970-01-01T00:00:01Z\"},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"1970-01-01T00:00:01Z\"}]\n' + + ' ],\n' + + ' \"abc\": \"2023-06-22T18:30:01Z\"\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot remove non-default value:2023-06-22T18:30:01Z'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_custom_primitive_string.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_custom_primitive_string.pure new file mode 100644 index 00000000000..f53d5e8cccd --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_custom_primitive_string.pure @@ -0,0 +1,108 @@ +// Copyright 2023 Goldman Sachs +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import meta::pure::changetoken::tests::primitive::string::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::primitive::string::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' \"@type\": \"meta::pure::changetoken::Versions\",\n' + + ' \"versions\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg123\"\n' + + ' },\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg456\",\n' + + ' \"prevVersion\": \"ftdm:abcdefg123\",\n' + + ' \"changeTokens\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::AddField\",\n' + + ' \"fieldName\": \"abc\",\n' + + ' \"fieldType\": \"Custom[1]\",\n' + + ' \"defaultValue\": {\n' + + ' \"@type\": \"meta::pure::changetoken::ConstValue\",\n' + + ' \"value\": \"\\\"1970-01-01T00:00:01Z\\\"\"\n' + + ' },\n' + + ' \"safeCast\": true,\n' + + ' \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::primitive::string::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}'), + '{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"1970-01-01T00:00:01Z\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"1970-01-01T00:00:01Z\"},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"1970-01-01T00:00:01Z\"}]\n' + + ' ],\n' + + ' \"abc\": \"1970-01-01T00:00:01Z\"\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::primitive::string::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"1970-01-01T00:00:01Z\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"1970-01-01T00:00:01Z\"},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"1970-01-01T00:00:01Z\"}]\n' + + ' ],\n' + + ' \"abc\": \"1970-01-01T00:00:01Z\"\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::primitive::string::testDowncastNonDefault(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"1970-01-01T00:00:01Z\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"1970-01-01T00:00:01Z\"},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"1970-01-01T00:00:01Z\"}]\n' + + ' ],\n' + + ' \"abc\": \"2023-06-22T18:30:01Z\"\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot remove non-default value:2023-06-22T18:30:01Z'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_custom_primitive_string_no_escaping.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_custom_primitive_string_no_escaping.pure new file mode 100644 index 00000000000..08c710451de --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_custom_primitive_string_no_escaping.pure @@ -0,0 +1,109 @@ +// Copyright 2024 Goldman Sachs +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import meta::pure::changetoken::tests::primitive::string::no::escaping::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::primitive::string::no::escaping::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' \"@type\": \"meta::pure::changetoken::Versions\",\n' + + ' \"versions\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg123\"\n' + + ' },\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg456\",\n' + + ' \"prevVersion\": \"ftdm:abcdefg123\",\n' + + ' \"changeTokens\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::AddField\",\n' + + ' \"fieldName\": \"abc\",\n' + + ' \"fieldType\": \"Custom[1]\",\n' + + ' \"defaultValue\": {\n' + + ' \"@type\": \"meta::pure::changetoken::ConstValue\",\n' + + ' \"value\": \"\\\"1970-01-01T00:00:01Z\\\"\"\n' + + ' },\n' + + ' \"safeCast\": true,\n' + + ' \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n', + true, false, false); +} + +function <> meta::pure::changetoken::tests::primitive::string::no::escaping::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}'), + '{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"\\\"1970-01-01T00:00:01Z\\\"\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"\\\"1970-01-01T00:00:01Z\\\"\"},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"\\\"1970-01-01T00:00:01Z\\\"\"}]\n' + + ' ],\n' + + ' \"abc\": \"\\\"1970-01-01T00:00:01Z\\\"\"\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::primitive::string::no::escaping::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"\\\"1970-01-01T00:00:01Z\\\"\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"\\\"1970-01-01T00:00:01Z\\\"\"},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"\\\"1970-01-01T00:00:01Z\\\"\"}]\n' + + ' ],\n' + + ' \"abc\": \"\\\"1970-01-01T00:00:01Z\\\"\"\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::primitive::string::no::escaping::testDowncastNonDefault(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"\\\"1970-01-01T00:00:01Z\\\"\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"\\\"1970-01-01T00:00:01Z\\\"\"},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"\\\"1970-01-01T00:00:01Z\\\"\"}]\n' + + ' ],\n' + + ' \"abc\": \"2023-06-22T18:30:01Z\"\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot remove non-default value:2023-06-22T18:30:01Z'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_double.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_double.pure new file mode 100644 index 00000000000..11d3253cb4d --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_double.pure @@ -0,0 +1,108 @@ +// Copyright 2023 Goldman Sachs +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import meta::pure::changetoken::tests::double::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::double::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' \"@type\": \"meta::pure::changetoken::Versions\",\n' + + ' \"versions\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg123\"\n' + + ' },\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg456\",\n' + + ' \"prevVersion\": \"ftdm:abcdefg123\",\n' + + ' \"changeTokens\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::AddField\",\n' + + ' \"fieldName\": \"abc\",\n' + + ' \"fieldType\": \"double[1]\",\n' + + ' \"defaultValue\": {\n' + + ' \"@type\": \"meta::pure::changetoken::ConstValue\",\n' + + ' \"value\": 123.45\n' + + ' },\n' + + ' \"safeCast\": true,\n' + + ' \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::double::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}'), + '{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 123.45},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 123.45},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 123.45}]\n' + + ' ],\n' + + ' \"abc\": 123.45\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::double::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 123.45},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 123.45},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 123.45}]\n' + + ' ],\n' + + ' \"abc\": 123.45\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::double::testDowncastNonDefault(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 123.45},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 123.45},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 123.45}]\n' + + ' ],\n' + + ' \"abc\": 67.89\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot remove non-default value:67.89'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_double_string.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_double_string.pure new file mode 100644 index 00000000000..70ffc6568c7 --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_double_string.pure @@ -0,0 +1,108 @@ +// Copyright 2023 Goldman Sachs +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import meta::pure::changetoken::tests::double::string::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::double::string::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' \"@type\": \"meta::pure::changetoken::Versions\",\n' + + ' \"versions\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg123\"\n' + + ' },\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg456\",\n' + + ' \"prevVersion\": \"ftdm:abcdefg123\",\n' + + ' \"changeTokens\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::AddField\",\n' + + ' \"fieldName\": \"abc\",\n' + + ' \"fieldType\": \"double[1]\",\n' + + ' \"defaultValue\": {\n' + + ' \"@type\": \"meta::pure::changetoken::ConstValue\",\n' + + ' \"value\": \"123.45\"\n' + + ' },\n' + + ' \"safeCast\": true,\n' + + ' \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::double::string::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}'), + '{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 123.45},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 123.45},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 123.45}]\n' + + ' ],\n' + + ' \"abc\": 123.45\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::double::string::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 123.45},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 123.45},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 123.45}]\n' + + ' ],\n' + + ' \"abc\": 123.45\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::double::string::testDowncastNonDefault(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 123.45},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 123.45},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 123.45}]\n' + + ' ],\n' + + ' \"abc\": 67.89\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot remove non-default value:67.89'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_from_json.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_from_json.pure new file mode 100644 index 00000000000..769095ddd01 --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_from_json.pure @@ -0,0 +1,130 @@ +// Copyright 2023 Goldman Sachs +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import meta::pure::changetoken::tests::from::json::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::from::json::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' \"@type\": \"meta::pure::changetoken::Versions\",\n' + + ' \"versions\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg123\"\n' + + ' },\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg456\",\n' + + ' \"prevVersion\": \"ftdm:abcdefg123\",\n' + + ' \"changeTokens\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::AddField\",\n' + + ' \"class\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"fieldName\": \"abc\",\n' + + ' \"fieldType\": \"Integer[1]\",\n' + + ' \"safeCast\": true,\n' + + ' \"defaultValue\": {\n' + + ' \"@type\": \"meta::pure::changetoken::ConstValue\",\n' + + ' \"value\": 100\n' + + ' }\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::from::json::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}'), + '{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100}]\n' + + ' ],\n' + + ' \"abc\": 100\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::from::json::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100}]\n' + + ' ],\n' + + ' \"abc\": 100\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::from::json::testDowncastNull(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::from::json::testDowncastNonDefault(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100}]\n' + + ' ],\n' + + ' \"abc\": 300\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot remove non-default value:300'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_from_versions.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_from_versions.pure new file mode 100644 index 00000000000..a7c4bd03481 --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_from_versions.pure @@ -0,0 +1,110 @@ +// Copyright 2023 Goldman Sachs +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import meta::pure::changetoken::tests::from::versions::*; +import meta::pure::changetoken::tests::*; +import meta::pure::changetoken::*; + +function meta::pure::changetoken::tests::from::versions::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + let abcdefg123 = ^Version(version='ftdm:abcdefg123'); + let value = ^ConstValue(value=100); + let addField = ^AddField(class='meta::pure::changetoken::tests::SampleClass', fieldName='abc', fieldType='Integer[1]', safeCast=true, defaultValue=$value); + let abcdefg456 = ^Version(version='ftdm:abcdefg456', prevVersion='ftdm:abcdefg123', changeTokens=$addField); + let versions = ^Versions(versions=[$abcdefg123, $abcdefg456]); + setupSuiteFromVersions($versions); +} + +function <> meta::pure::changetoken::tests::from::versions::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}'), + '{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100}]\n' + + ' ],\n' + + ' \"abc\": 100\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::from::versions::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100}]\n' + + ' ],\n' + + ' \"abc\": 100\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::from::versions::testDowncastNull(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::from::versions::testDowncastNonDefault(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100}]\n' + + ' ],\n' + + ' \"abc\": 300\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot remove non-default value:300'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_integer_string.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_integer_string.pure new file mode 100644 index 00000000000..1d2b4195225 --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_integer_string.pure @@ -0,0 +1,108 @@ +// Copyright 2023 Goldman Sachs +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import meta::pure::changetoken::tests::integer::string::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::integer::string::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' \"@type\": \"meta::pure::changetoken::Versions\",\n' + + ' \"versions\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg123\"\n' + + ' },\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg456\",\n' + + ' \"prevVersion\": \"ftdm:abcdefg123\",\n' + + ' \"changeTokens\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::AddField\",\n' + + ' \"fieldName\": \"abc\",\n' + + ' \"fieldType\": \"Integer[1]\",\n' + + ' \"defaultValue\": {\n' + + ' \"@type\": \"meta::pure::changetoken::ConstValue\",\n' + + ' \"value\": \"100\"\n' + + ' },\n' + + ' \"safeCast\": true,\n' + + ' \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::integer::string::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}'), + '{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100}]\n' + + ' ],\n' + + ' \"abc\": 100\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::integer::string::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100}]\n' + + ' ],\n' + + ' \"abc\": 100\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::integer::string::testDowncastNonDefault(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100}]\n' + + ' ],\n' + + ' \"abc\": 300\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot remove non-default value:300'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_move.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_move.pure new file mode 100644 index 00000000000..55244870fb9 --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_move.pure @@ -0,0 +1,202 @@ +// Copyright 2023 Goldman Sachs +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import meta::pure::changetoken::tests::move::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::move::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' \"@type\": \"meta::pure::changetoken::Versions\",\n' + + ' \"versions\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg123\"\n' + + ' },\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg456\",\n' + + ' \"prevVersion\": \"ftdm:abcdefg123\",\n' + + ' \"changeTokens\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::AddField\",\n' + + ' \"fieldName\": \"xyz\",\n' + + ' \"fieldType\": \"SampleNestedClass[1]\",\n' + + ' \"defaultValue\": {\n' + + ' \"@type\": \"meta::pure::changetoken::ConstValue\",\n' + + ' \"value\": \"{\\\"@type\\\":\\\"SampleNestedClass\\\",\\\"step\\\":0,\\\"active\\\":true}\"\n' + + ' },\n' + + ' \"safeCast\": true,\n' + + ' \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n' + + ' },\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::RenameField\",\n' + + ' \"oldFieldName\": [\n' + + ' \"abc\"\n' + + ' ],\n' + + ' \"newFieldName\": [\n' + + ' \"xyz\",\n' + + ' \"def\"\n' + + ' ],\n' + + ' \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::move::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n' + + '}'), + '{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"SampleNestedClass\", \"active\":true, \"step\":0, \"def\": {\"@type\":\"Custom\", \"value\":\"1d\"}}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"SampleNestedClass\", \"active\":true, \"step\":0, \"def\": {\"@type\":\"Custom\", \"value\":\"2d\"}}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"SampleNestedClass\", \"active\":true, \"step\":0, \"def\": {\"@type\":\"Custom\", \"value\":\"3d\"}}}]\n' + + ' ],\n' + + ' \"xyz\": {\"@type\":\"SampleNestedClass\", \"active\":true, \"step\":0, \"def\": {\"@type\":\"Custom\", \"value\":\"4d\"}}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::move::testUpcastType(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n' + + '}'), + '{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::move::testUpcastMissing(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n' + + ' ],\n' + + ' \"def\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n' + + '}'), + '{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"SampleNestedClass\", \"active\":true, \"step\":0}, \"def\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"SampleNestedClass\", \"active\":true, \"step\":0}, \"def\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"SampleNestedClass\", \"active\":true, \"step\":0}, \"def\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n' + + ' ],\n' + + ' \"xyz\": {\"@type\":\"SampleNestedClass\", \"active\":true, \"step\":0}, \"def\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::move::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"SampleNestedClass\", \"active\":true, \"step\":0, \"def\": {\"@type\":\"Custom\", \"value\":\"1d\"}}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"SampleNestedClass\", \"active\":true, \"step\":0, \"def\": {\"@type\":\"Custom\", \"value\":\"2d\"}}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"SampleNestedClass\", \"active\":true, \"step\":0, \"def\": {\"@type\":\"Custom\", \"value\":\"3d\"}}}]\n' + + ' ],\n' + + ' \"xyz\": {\"@type\":\"SampleNestedClass\", \"active\":true, \"step\":0, \"def\": {\"@type\":\"Custom\", \"value\":\"4d\"}}\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::move::testDowncastType(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n' + + ' ],\n' + + ' \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n' + + ' ],\n' + + ' \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::move::testDowncastMissing(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n' + + ' ],\n' + + ' \"def\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n' + + ' ],\n' + + ' \"def\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n' + + '}\n'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_move_extract.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_move_extract.pure new file mode 100644 index 00000000000..3a01442e2ea --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_move_extract.pure @@ -0,0 +1,117 @@ +// Copyright 2023 Goldman Sachs +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import meta::pure::changetoken::tests::move::extract::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::move::extract::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' \"@type\": \"meta::pure::changetoken::Versions\",\n' + + ' \"versions\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg123\"\n' + + ' },\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg456\",\n' + + ' \"prevVersion\": \"ftdm:abcdefg123\",\n' + + ' \"changeTokens\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::RenameField\",\n' + + ' \"oldFieldName\": [\n' + + ' \"names\",\n' + + ' \"first\"\n' + + ' ],\n' + + ' \"newFieldName\": [\n' + + ' \"firstName\"\n' + + ' ],\n' + + ' \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n' + + ' },\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::RenameField\",\n' + + ' \"oldFieldName\": [\n' + + ' \"names\",\n' + + ' \"last\"\n' + + ' ],\n' + + ' \"newFieldName\": [\n' + + ' \"lastName\"\n' + + ' ],\n' + + ' \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n' + + ' },\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::RemoveField\",\n' + + ' \"fieldName\": \"names\",\n' + + ' \"fieldType\": \"NamesClass[1]\",\n' + + ' \"defaultValue\": {\n' + + ' \"@type\": \"meta::pure::changetoken::ConstValue\",\n' + + ' \"value\": \"{\\\"@type\\\":\\\"NamesClass\\\",\\\"middle\\\":\\\"\\\"}\"\n' + + ' },\n' + + ' \"safeCast\": true,\n' + + ' \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::move::extract::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"names\": {\"@type\":\"NamesClass\", \"first\":\"1d\", \"middle\":\"\", \"last\":\"2d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"names\": {\"@type\":\"NamesClass\", \"first\":\"3d\", \"middle\":\"\", \"last\":\"4d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"names\": {\"@type\":\"NamesClass\", \"first\":\"5d\", \"middle\":\"\", \"last\":\"6d\"}}]\n' + + ' ],\n' + + ' \"names\": {\"@type\":\"NamesClass\", \"first\":\"7d\", \"middle\":\"\", \"last\":\"8d\"}\n' + + '}'), + '{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"firstName\":\"1d\", \"lastName\":\"2d\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"firstName\":\"3d\", \"lastName\":\"4d\"},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"firstName\":\"5d\", \"lastName\":\"6d\"}]\n' + + ' ],\n' + + ' \"firstName\":\"7d\", \"lastName\":\"8d\"\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::move::extract::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"firstName\":\"1d\", \"lastName\":\"2d\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"firstName\":\"3d\", \"lastName\":\"4d\"},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"firstName\":\"5d\", \"lastName\":\"6d\"}]\n' + + ' ],\n' + + ' \"firstName\":\"7d\", \"lastName\":\"8d\"\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"names\": {\"@type\":\"NamesClass\", \"first\":\"1d\", \"middle\":\"\", \"last\":\"2d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"names\": {\"@type\":\"NamesClass\", \"first\":\"3d\", \"middle\":\"\", \"last\":\"4d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"names\": {\"@type\":\"NamesClass\", \"first\":\"5d\", \"middle\":\"\", \"last\":\"6d\"}}]\n' + + ' ],\n' + + ' \"names\": {\"@type\":\"NamesClass\", \"first\":\"7d\", \"middle\":\"\", \"last\":\"8d\"}\n' + + '}\n'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_move_nested.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_move_nested.pure new file mode 100644 index 00000000000..91176e6ed68 --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_move_nested.pure @@ -0,0 +1,234 @@ +// Copyright 2023 Goldman Sachs +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import meta::pure::changetoken::tests::move::nested::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::move::nested::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' \"@type\": \"meta::pure::changetoken::Versions\",\n' + + ' \"versions\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg123\"\n' + + ' },\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg456\",\n' + + ' \"prevVersion\": \"ftdm:abcdefg123\",\n' + + ' \"changeTokens\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::RenameField\",\n' + + ' \"oldFieldName\": [\n' + + ' \"abc\",\n' + + ' \"value\"\n' + + ' ],\n' + + ' \"newFieldName\": [\n' + + ' \"xyz\",\n' + + ' \"value\"\n' + + ' ],\n' + + ' \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::move::nested::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"String\", \"value\":\"1d\"}, \"xyz\": {\"@type\":\"String\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"String\", \"value\":\"2d\"}, \"xyz\": {\"@type\":\"String\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"String\", \"value\":\"3d\"}, \"xyz\": {\"@type\":\"String\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"String\", \"value\":\"4d\"}, \"xyz\": {\"@type\":\"String\"}\n' + + '}'), + '{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"String\", \"value\":\"1d\"}, \"abc\": {\"@type\":\"String\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"String\", \"value\":\"2d\"}, \"abc\": {\"@type\":\"String\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"String\", \"value\":\"3d\"}, \"abc\": {\"@type\":\"String\"}}]\n' + + ' ],\n' + + ' \"xyz\": {\"@type\":\"String\", \"value\":\"4d\"}, \"abc\": {\"@type\":\"String\"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::move::nested::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"String\", \"value\":\"1d\"}, \"abc\": {\"@type\":\"String\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"String\", \"value\":\"2d\"}, \"abc\": {\"@type\":\"String\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"String\", \"value\":\"3d\"}, \"abc\": {\"@type\":\"String\"}}]\n' + + ' ],\n' + + ' \"xyz\": {\"@type\":\"String\", \"value\":\"4d\"}, \"abc\": {\"@type\":\"String\"}\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"String\", \"value\":\"1d\"}, \"xyz\": {\"@type\":\"String\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"String\", \"value\":\"2d\"}, \"xyz\": {\"@type\":\"String\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"String\", \"value\":\"3d\"}, \"xyz\": {\"@type\":\"String\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"String\", \"value\":\"4d\"}, \"xyz\": {\"@type\":\"String\"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::move::nested::testUpcastSame(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"String\", \"value\":\"1d\"}, \"xyz\": {\"@type\":\"String\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"String\", \"value\":\"2d\"}, \"xyz\": {\"@type\":\"String\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"String\", \"value\":\"3d\"}, \"xyz\": {\"@type\":\"String\", \"value\":\"3d\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"String\", \"value\":\"4d\"}, \"xyz\": {\"@type\":\"String\"}\n' + + '}'), + '{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"String\", \"value\":\"1d\"}, \"abc\": {\"@type\":\"String\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"String\", \"value\":\"2d\"}, \"abc\": {\"@type\":\"String\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"String\", \"value\":\"3d\"}, \"abc\": {\"@type\":\"String\"}}]\n' + + ' ],\n' + + ' \"xyz\": {\"@type\":\"String\", \"value\":\"4d\"}, \"abc\": {\"@type\":\"String\"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::move::nested::testDowncastSame(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"String\", \"value\":\"1d\"}, \"abc\": {\"@type\":\"String\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"String\", \"value\":\"2d\"}, \"abc\": {\"@type\":\"String\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"String\", \"value\":\"3d\"}, \"abc\": {\"@type\":\"String\", \"value\":\"3d\"}}]\n' + + ' ],\n' + + ' \"xyz\": {\"@type\":\"String\", \"value\":\"4d\"}, \"abc\": {\"@type\":\"String\"}\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"String\", \"value\":\"1d\"}, \"xyz\": {\"@type\":\"String\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"String\", \"value\":\"2d\"}, \"xyz\": {\"@type\":\"String\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"String\", \"value\":\"3d\"}, \"xyz\": {\"@type\":\"String\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"String\", \"value\":\"4d\"}, \"xyz\": {\"@type\":\"String\"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::move::nested::testUpcastDifferent(): Any[*] +{ + exception(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"String\", \"value\":\"1d\"}, \"xyz\": {\"@type\":\"String\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"String\", \"value\":\"2d\"}, \"xyz\": {\"@type\":\"String\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"String\", \"value\":\"3d\"}, \"xyz\": {\"@type\":\"String\", \"value\":\"5d\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"String\", \"value\":\"4d\"}, \"xyz\": {\"@type\":\"String\"}\n' + + '}'), + 'Cannot overwrite with different value:5d'); +} + +function <> meta::pure::changetoken::tests::move::nested::testDowncastDifferent(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"String\", \"value\":\"1d\"}, \"abc\": {\"@type\":\"String\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"String\", \"value\":\"2d\"}, \"abc\": {\"@type\":\"String\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"String\", \"value\":\"3d\"}, \"abc\": {\"@type\":\"String\", \"value\":\"6d\"}}]\n' + + ' ],\n' + + ' \"xyz\": {\"@type\":\"String\", \"value\":\"4d\"}, \"abc\": {\"@type\":\"String\"}\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot overwrite with different value:6d'); +} + +function <> meta::pure::changetoken::tests::move::nested::testUpcastInvalidDestination(): Any[*] +{ + exception(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"String\", \"value\":\"1d\"}, \"xyz\": {\"@type\":\"String\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"String\", \"value\":\"2d\"}, \"xyz\": {\"@type\":\"String\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"String\", \"value\":\"3d\"}, \"xyz\": \"invalid\"}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"String\", \"value\":\"4d\"}, \"xyz\": {\"@type\":\"String\"}\n' + + '}'), + 'Destination is not a map: xyz'); +} + +function <> meta::pure::changetoken::tests::move::nested::testDowncastInvalidDestination(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"String\", \"value\":\"1d\"}, \"abc\": {\"@type\":\"String\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"String\", \"value\":\"2d\"}, \"abc\": {\"@type\":\"String\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"String\", \"value\":\"3d\"}, \"abc\": \"invalid\"}]\n' + + ' ],\n' + + ' \"xyz\": {\"@type\":\"String\", \"value\":\"4d\"}, \"abc\": {\"@type\":\"String\"}\n' + + '}', 'ftdm:abcdefg123'), + 'Destination is not a map: abc'); +} + +function <> meta::pure::changetoken::tests::move::nested::testUpcastInvalidSource(): Any[*] +{ + exception(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"String\", \"value\":\"1d\"}, \"xyz\": {\"@type\":\"String\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"String\", \"value\":\"2d\"}, \"xyz\": {\"@type\":\"String\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"invalid\", \"xyz\": {\"@type\":\"String\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"String\", \"value\":\"4d\"}, \"xyz\": {\"@type\":\"String\"}\n' + + '}'), + 'Source is not a map: abc'); +} + +function <> meta::pure::changetoken::tests::move::nested::testDowncastInvalidSource(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"String\", \"value\":\"1d\"}, \"abc\": {\"@type\":\"String\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"String\", \"value\":\"2d\"}, \"abc\": {\"@type\":\"String\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": \"invalid\", \"abc\": {\"@type\":\"String\"}}]\n' + + ' ],\n' + + ' \"xyz\": {\"@type\":\"String\", \"value\":\"4d\"}, \"abc\": {\"@type\":\"String\"}\n' + + '}', 'ftdm:abcdefg123'), + 'Source is not a map: xyz'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_remove.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_remove.pure new file mode 100644 index 00000000000..51fa2b2ceb0 --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_remove.pure @@ -0,0 +1,130 @@ +// Copyright 2023 Goldman Sachs +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import meta::pure::changetoken::tests::remove::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::remove::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' \"@type\": \"meta::pure::changetoken::Versions\",\n' + + ' \"versions\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg123\"\n' + + ' },\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg456\",\n' + + ' \"prevVersion\": \"ftdm:abcdefg123\",\n' + + ' \"changeTokens\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::RemoveField\",\n' + + ' \"fieldName\": \"abc\",\n' + + ' \"fieldType\": \"Integer[1]\",\n' + + ' \"defaultValue\": {\n' + + ' \"@type\": \"meta::pure::changetoken::ConstValue\",\n' + + ' \"value\": 100\n' + + ' },\n' + + ' \"safeCast\": true,\n' + + ' \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::remove::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100}]\n' + + ' ],\n' + + ' \"abc\": 100\n' + + '}'), + '{\n' + + ' \"version\":\"ftdm:abcdefg456\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::remove::testUpcastNull(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}'), + '{\n' + + ' \"version\":\"ftdm:abcdefg456\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::remove::testUpcastNonDefault(): Any[*] +{ + exception(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100}]\n' + + ' ],\n' + + ' \"abc\": 300\n' + + '}'), + 'Cannot remove non-default value:300'); +} + +function <> meta::pure::changetoken::tests::remove::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' \"version\":\"ftdm:abcdefg123\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100}]\n' + + ' ],\n' + + ' \"abc\": 100\n' + + '}\n'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_rename.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_rename.pure new file mode 100644 index 00000000000..0683009e0a6 --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_rename.pure @@ -0,0 +1,268 @@ +// Copyright 2023 Goldman Sachs +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import meta::pure::changetoken::tests::rename::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::rename::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' \"@type\": \"meta::pure::changetoken::Versions\",\n' + + ' \"versions\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg123\"\n' + + ' },\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg456\",\n' + + ' \"prevVersion\": \"ftdm:abcdefg123\",\n' + + ' \"changeTokens\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::RenameField\",\n' + + ' \"oldFieldName\": [\n' + + ' \"abc\"\n' + + ' ],\n' + + ' \"newFieldName\": [\n' + + ' \"xyz\"\n' + + ' ],\n' + + ' \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n' + + '}'), + '{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n' + + ' ],\n' + + ' \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::testUpcastType(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n' + + '}'), + '{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::testUpcastMissing(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n' + + ' ],\n' + + ' \"def\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n' + + '}'), + '{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n' + + ' ],\n' + + ' \"def\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n' + + ' ],\n' + + ' \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::testDowncastType(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n' + + ' ],\n' + + ' \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n' + + ' ],\n' + + ' \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::testDowncastMissing(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n' + + ' ],\n' + + ' \"def\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n' + + ' ],\n' + + ' \"def\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::testUpcastExistingTheSame(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n' + + '}'), + '{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n' + + ' ],\n' + + ' \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::testDowncastExistingTheSame(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"5d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"5d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"6d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"6d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"7d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"7d\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"value\":\"8d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"8d\"}\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"5d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"6d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"7d\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"value\":\"8d\"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::testUpcastExistingTheDifferent(): Any[*] +{ + exception(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"9d\"}\n' + + '}'), + 'Cannot overwrite with different value:{@type=Custom, value=9d}'); +} + +function <> meta::pure::changetoken::tests::rename::testDowncastExistingTheDifferent(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"5d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"5d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"6d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"6d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"7d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"7d\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"value\":\"8d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"9d\"}\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot overwrite with different value:{@type=Custom, value=8d}'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_rename_field_renamed_class.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_rename_field_renamed_class.pure new file mode 100644 index 00000000000..a281a73e99f --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_rename_field_renamed_class.pure @@ -0,0 +1,273 @@ +// Copyright 2023 Goldman Sachs +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import meta::pure::changetoken::tests::rename::field::renamed::class::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::rename::field::renamed::class::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' \"@type\": \"meta::pure::changetoken::Versions\",\n' + + ' \"versions\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg123\"\n' + + ' },\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg456\",\n' + + ' \"prevVersion\": \"ftdm:abcdefg123\",\n' + + ' \"changeTokens\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::RenameField\",\n' + + ' \"oldFieldName\": [\n' + + ' \"abc\"\n' + + ' ],\n' + + ' \"newFieldName\": [\n' + + ' \"xyz\"\n' + + ' ],\n' + + ' \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n' + + ' },\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::RenamedClass\",\n' + + ' \"newName\": \"meta::pure::changetoken::tests::nested::NewSampleClass\",\n' + + ' \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::field::renamed::class::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n' + + '}'), + '{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n' + + ' ],\n' + + ' \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::field::renamed::class::testUpcastType(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n' + + '}'), + '{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::field::renamed::class::testUpcastMissing(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n' + + ' ],\n' + + ' \"def\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n' + + '}'), + '{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n' + + ' ],\n' + + ' \"def\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::field::renamed::class::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n' + + ' ],\n' + + ' \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::field::renamed::class::testDowncastType(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n' + + ' ],\n' + + ' \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n' + + ' ],\n' + + ' \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::field::renamed::class::testDowncastMissing(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n' + + ' ],\n' + + ' \"def\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n' + + ' ],\n' + + ' \"def\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::field::renamed::class::testUpcastExistingTheSame(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n' + + '}'), + '{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n' + + ' ],\n' + + ' \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::field::renamed::class::testDowncastExistingTheSame(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"5d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"5d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"6d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"6d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"7d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"7d\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"value\":\"8d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"8d\"}\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"5d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"6d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"7d\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"value\":\"8d\"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::field::renamed::class::testUpcastExistingTheDifferent(): Any[*] +{ + exception(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"9d\"}\n' + + '}'), + 'Cannot overwrite with different value:{@type=Custom, value=9d}'); +} + +function <> meta::pure::changetoken::tests::rename::field::renamed::class::testDowncastExistingTheDifferent(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"5d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"5d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"6d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"6d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"7d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"7d\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"value\":\"8d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"9d\"}\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot overwrite with different value:{@type=Custom, value=8d}'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_rename_nested_property.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_rename_nested_property.pure new file mode 100644 index 00000000000..aacdbe66fbc --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_rename_nested_property.pure @@ -0,0 +1,270 @@ +// Copyright 2023 Goldman Sachs +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import meta::pure::changetoken::tests::rename::nested::property::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::rename::nested::property::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' \"@type\": \"meta::pure::changetoken::Versions\",\n' + + ' \"versions\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg123\"\n' + + ' },\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg456\",\n' + + ' \"prevVersion\": \"ftdm:abcdefg123\",\n' + + ' \"changeTokens\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::RenameField\",\n' + + ' \"oldFieldName\": [\n' + + ' \"abc\",\n' + + ' \"value\"\n' + + ' ],\n' + + ' \"newFieldName\": [\n' + + ' \"abc\",\n' + + ' \"valueCustom\"\n' + + ' ],\n' + + ' \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::nested::property::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n' + + '}'), + '{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"valueCustom\":\"1d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"valueCustom\":\"2d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"valueCustom\":\"3d\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"valueCustom\":\"4d\"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::nested::property::testUpcastType(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"1d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"2d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"3d\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"4d\"}\n' + + '}'), + '{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"1d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"2d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"3d\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"4d\"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::nested::property::testUpcastMissing(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"valueOther\":\"1d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"valueOther\":\"2d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"valueOther\":\"3d\"}}]\n' + + ' ],\n' + + ' \"def\": {\"@type\":\"Custom\", \"valueOther\":\"4d\"}\n' + + '}'), + '{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"valueOther\":\"1d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"valueOther\":\"2d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"valueOther\":\"3d\"}}]\n' + + ' ],\n' + + ' \"def\": {\"@type\":\"Custom\", \"valueOther\":\"4d\"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::nested::property::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"valueCustom\":\"4d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"valueCustom\":\"3d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"valueCustom\":\"2d\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"valueCustom\":\"1d\"}\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::nested::property::testDowncastType(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"4d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"3d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"2d\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"1d\"}\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"4d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"3d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"2d\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"1d\"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::nested::property::testDowncastMissing(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"valueOther\":\"4d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"valueOther\":\"2d\"}}]\n' + + ' ],\n' + + ' \"def\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"valueOther\":\"4d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"valueOther\":\"2d\"}}]\n' + + ' ],\n' + + ' \"def\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::nested::property::testUpcastExistingTheSame(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\", \"valueCustom\":\"1d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\", \"valueCustom\":\"2d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\", \"valueCustom\":\"3d\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\", \"valueCustom\":\"4d\"}\n' + + '}'), + '{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"valueCustom\":\"1d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"valueCustom\":\"2d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"valueCustom\":\"3d\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"valueCustom\":\"4d\"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::nested::property::testDowncastExistingTheSame(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"5d\", \"valueCustom\":\"5d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"6d\", \"valueCustom\":\"6d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"7d\", \"valueCustom\":\"7d\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"value\":\"8d\", \"valueCustom\":\"8d\"}\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"5d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"6d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"7d\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"value\":\"8d\"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::nested::property::testUpcastExistingTheDifferent(): Any[*] +{ + exception(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\", \"valueCustom\":\"1d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\", \"valueCustom\":\"2d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\", \"valueCustom\":\"3d\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\", \"valueCustom\":\"9d\"}\n' + + '}'), + 'Cannot overwrite with different value:9d'); +} + +function <> meta::pure::changetoken::tests::rename::nested::property::testDowncastExistingTheDifferent(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"5d\", \"valueCustom\":\"5d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"6d\", \"valueCustom\":\"6d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"7d\", \"valueCustom\":\"7d\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"value\":\"8d\", \"valueCustom\":\"9d\"}\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot overwrite with different value:8d'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_rename_property.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_rename_property.pure new file mode 100644 index 00000000000..bfbc5d893bb --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_rename_property.pure @@ -0,0 +1,268 @@ +// Copyright 2023 Goldman Sachs +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import meta::pure::changetoken::tests::rename::property::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::rename::property::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' \"@type\": \"meta::pure::changetoken::Versions\",\n' + + ' \"versions\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg123\"\n' + + ' },\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg456\",\n' + + ' \"prevVersion\": \"ftdm:abcdefg123\",\n' + + ' \"changeTokens\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::RenameField\",\n' + + ' \"oldFieldName\": [\n' + + ' \"value\"\n' + + ' ],\n' + + ' \"newFieldName\": [\n' + + ' \"valueCustom\"\n' + + ' ],\n' + + ' \"class\": \"Custom\"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::property::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n' + + '}'), + '{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"valueCustom\":\"1d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"valueCustom\":\"2d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"valueCustom\":\"3d\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"valueCustom\":\"4d\"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::property::testUpcastType(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"1d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"2d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"3d\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"4d\"}\n' + + '}'), + '{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"1d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"2d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"3d\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"OtherCustom\", \"value\":\"4d\"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::property::testUpcastMissing(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"valueOther\":\"1d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"valueOther\":\"2d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"valueOther\":\"3d\"}}]\n' + + ' ],\n' + + ' \"def\": {\"@type\":\"Custom\", \"valueOther\":\"4d\"}\n' + + '}'), + '{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"valueOther\":\"1d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"valueOther\":\"2d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"valueOther\":\"3d\"}}]\n' + + ' ],\n' + + ' \"def\": {\"@type\":\"Custom\", \"valueOther\":\"4d\"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::property::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"Custom\", \"valueCustom\":\"4d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"Custom\", \"valueCustom\":\"3d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"Custom\", \"valueCustom\":\"2d\"}}]\n' + + ' ],\n' + + ' \"xyz\": {\"@type\":\"Custom\", \"valueCustom\":\"1d\"}\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n' + + ' ],\n' + + ' \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::property::testDowncastType(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"OtherCustom\", \"value\":\"4d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"OtherCustom\", \"value\":\"3d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"OtherCustom\", \"value\":\"2d\"}}]\n' + + ' ],\n' + + ' \"xyz\": {\"@type\":\"OtherCustom\", \"value\":\"1d\"}\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"OtherCustom\", \"value\":\"4d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"OtherCustom\", \"value\":\"3d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"OtherCustom\", \"value\":\"2d\"}}]\n' + + ' ],\n' + + ' \"xyz\": {\"@type\":\"OtherCustom\", \"value\":\"1d\"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::property::testDowncastMissing(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"valueOther\":\"4d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"valueOther\":\"2d\"}}]\n' + + ' ],\n' + + ' \"def\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"valueOther\":\"4d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"valueOther\":\"2d\"}}]\n' + + ' ],\n' + + ' \"def\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::property::testUpcastExistingTheSame(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\", \"valueCustom\":\"1d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\", \"valueCustom\":\"2d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\", \"valueCustom\":\"3d\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\", \"valueCustom\":\"4d\"}\n' + + '}'), + '{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"valueCustom\":\"1d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"valueCustom\":\"2d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"valueCustom\":\"3d\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"valueCustom\":\"4d\"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::property::testDowncastExistingTheSame(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"5d\", \"valueCustom\":\"5d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"6d\", \"valueCustom\":\"6d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"7d\", \"valueCustom\":\"7d\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"value\":\"8d\", \"valueCustom\":\"8d\"}\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"5d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"6d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"7d\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"value\":\"8d\"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::rename::property::testUpcastExistingTheDifferent(): Any[*] +{ + exception(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\", \"valueCustom\":\"1d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\", \"valueCustom\":\"2d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\", \"valueCustom\":\"3d\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\", \"valueCustom\":\"9d\"}\n' + + '}'), + 'Cannot overwrite with different value:9d'); +} + +function <> meta::pure::changetoken::tests::rename::property::testDowncastExistingTheDifferent(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"5d\", \"valueCustom\":\"5d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"6d\", \"valueCustom\":\"6d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"7d\", \"valueCustom\":\"7d\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"value\":\"8d\", \"valueCustom\":\"9d\"}\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot overwrite with different value:8d'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_renamed_class.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_renamed_class.pure new file mode 100644 index 00000000000..cbff138d028 --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_renamed_class.pure @@ -0,0 +1,137 @@ +// Copyright 2023 Goldman Sachs +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import meta::pure::changetoken::tests::renamed::class::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::renamed::class::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' \"@type\": \"meta::pure::changetoken::Versions\",\n' + + ' \"versions\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg123\"\n' + + ' },\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg456\",\n' + + ' \"prevVersion\": \"ftdm:abcdefg123\",\n' + + ' \"changeTokens\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::RenamedClass\",\n' + + ' \"newName\": \"meta::pure::changetoken::tests::nested::NewSampleClass\",\n' + + ' \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::renamed::class::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n' + + '}'), + '{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::renamed::class::testUpcastType(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n' + + '}'), + '{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::renamed::class::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n' + + ' ],\n' + + ' \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n' + + ' ],\n' + + ' \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::renamed::class::testDowncastType(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n' + + ' ],\n' + + ' \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n' + + ' ],\n' + + ' \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n' + + '}\n'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_renamed_class_rename_field.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_renamed_class_rename_field.pure new file mode 100644 index 00000000000..d68279f690d --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_renamed_class_rename_field.pure @@ -0,0 +1,273 @@ +// Copyright 2023 Goldman Sachs +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import meta::pure::changetoken::tests::renamed::class::rename::field::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::renamed::class::rename::field::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' \"@type\": \"meta::pure::changetoken::Versions\",\n' + + ' \"versions\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg123\"\n' + + ' },\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg456\",\n' + + ' \"prevVersion\": \"ftdm:abcdefg123\",\n' + + ' \"changeTokens\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::RenamedClass\",\n' + + ' \"newName\": \"meta::pure::changetoken::tests::nested::NewSampleClass\",\n' + + ' \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n' + + ' },\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::RenameField\",\n' + + ' \"oldFieldName\": [\n' + + ' \"abc\"\n' + + ' ],\n' + + ' \"newFieldName\": [\n' + + ' \"xyz\"\n' + + ' ],\n' + + ' \"class\": \"meta::pure::changetoken::tests::nested::NewSampleClass\"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::renamed::class::rename::field::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n' + + '}'), + '{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n' + + ' ],\n' + + ' \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::renamed::class::rename::field::testUpcastType(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n' + + '}'), + '{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::renamed::class::rename::field::testUpcastMissing(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n' + + ' ],\n' + + ' \"def\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n' + + '}'), + '{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n' + + ' ],\n' + + ' \"def\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::renamed::class::rename::field::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n' + + ' ],\n' + + ' \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::renamed::class::rename::field::testDowncastType(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n' + + ' ],\n' + + ' \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::OtherClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::OtherClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n' + + ' ],\n' + + ' \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::renamed::class::rename::field::testDowncastMissing(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n' + + ' ],\n' + + ' \"def\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"4d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"3d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"def\": {\"@type\":\"Custom\", \"value\":\"2d\"}}]\n' + + ' ],\n' + + ' \"def\": {\"@type\":\"Custom\", \"value\":\"1d\"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::renamed::class::rename::field::testUpcastExistingTheSame(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n' + + '}'), + '{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n' + + ' ],\n' + + ' \"xyz\": {\"@type\":\"Custom\", \"value\":\"4d\"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::renamed::class::rename::field::testDowncastExistingTheSame(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"5d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"5d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"6d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"6d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"7d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"7d\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"value\":\"8d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"8d\"}\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"5d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"6d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"7d\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"value\":\"8d\"}\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::renamed::class::rename::field::testUpcastExistingTheDifferent(): Any[*] +{ + exception(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"1d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"1d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"2d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"2d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"3d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"3d\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"value\":\"4d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"9d\"}\n' + + '}'), + 'Cannot overwrite with different value:{@type=Custom, value=9d}'); +} + +function <> meta::pure::changetoken::tests::renamed::class::rename::field::testDowncastExistingTheDifferent(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"5d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"5d\"}},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"6d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"6d\"}},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::nested::NewSampleClass\", \"abc\": {\"@type\":\"Custom\", \"value\":\"7d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"7d\"}}]\n' + + ' ],\n' + + ' \"abc\": {\"@type\":\"Custom\", \"value\":\"8d\"}, \"xyz\": {\"@type\":\"Custom\", \"value\":\"9d\"}\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot overwrite with different value:{@type=Custom, value=8d}'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_string.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_string.pure new file mode 100644 index 00000000000..283a8f73a2c --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_string.pure @@ -0,0 +1,108 @@ +// Copyright 2023 Goldman Sachs +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import meta::pure::changetoken::tests::string::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::string::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' \"@type\": \"meta::pure::changetoken::Versions\",\n' + + ' \"versions\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg123\"\n' + + ' },\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg456\",\n' + + ' \"prevVersion\": \"ftdm:abcdefg123\",\n' + + ' \"changeTokens\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::AddField\",\n' + + ' \"fieldName\": \"abc\",\n' + + ' \"fieldType\": \"String[1]\",\n' + + ' \"defaultValue\": {\n' + + ' \"@type\": \"meta::pure::changetoken::ConstValue\",\n' + + ' \"value\": \"one \\\" two\"\n' + + ' },\n' + + ' \"safeCast\": true,\n' + + ' \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::string::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}'), + '{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"one \\\" two\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"one \\\" two\"},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"one \\\" two\"}]\n' + + ' ],\n' + + ' \"abc\": \"one \\\" two\"\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::string::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"one \\\" two\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"one \\\" two\"},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"one \\\" two\"}]\n' + + ' ],\n' + + ' \"abc\": \"one \\\" two\"\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::string::testDowncastNonDefault(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"one \\\" two\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"one \\\" two\"},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"one \\\" two\"}]\n' + + ' ],\n' + + ' \"abc\": \"two \\\" one\"\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot remove non-default value:two \" one'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_string_quotes.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_string_quotes.pure new file mode 100644 index 00000000000..51031934d5b --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_string_quotes.pure @@ -0,0 +1,108 @@ +// Copyright 2023 Goldman Sachs +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import meta::pure::changetoken::tests::string::quotes::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::string::quotes::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' \"@type\": \"meta::pure::changetoken::Versions\",\n' + + ' \"versions\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg123\"\n' + + ' },\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg456\",\n' + + ' \"prevVersion\": \"ftdm:abcdefg123\",\n' + + ' \"changeTokens\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::AddField\",\n' + + ' \"fieldName\": \"abc\",\n' + + ' \"fieldType\": \"String[1]\",\n' + + ' \"defaultValue\": {\n' + + ' \"@type\": \"meta::pure::changetoken::ConstValue\",\n' + + ' \"value\": \"\\\"one \\\\\\\" two\\\"\"\n' + + ' },\n' + + ' \"safeCast\": true,\n' + + ' \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::string::quotes::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}'), + '{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"one \\\" two\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"one \\\" two\"},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"one \\\" two\"}]\n' + + ' ],\n' + + ' \"abc\": \"one \\\" two\"\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::string::quotes::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"one \\\" two\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"one \\\" two\"},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"one \\\" two\"}]\n' + + ' ],\n' + + ' \"abc\": \"one \\\" two\"\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' \"version\":\"ftdm:abcdefg123\", \n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::string::quotes::testDowncastNonDefault(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' \"version\":\"ftdm:abcdefg456\",\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"one \\\" two\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"one \\\" two\"},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": \"one \\\" two\"}]\n' + + ' ],\n' + + ' \"abc\": \"two \\\" one\"\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot remove non-default value:two \" one'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_version_custom.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_version_custom.pure new file mode 100644 index 00000000000..455474effbe --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_version_custom.pure @@ -0,0 +1,130 @@ +// Copyright 2024 Goldman Sachs +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import meta::pure::changetoken::tests::version::custom::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::version::custom::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' \"$type$\": \"meta::pure::changetoken::Versions\",\n' + + ' \"versions\": [\n' + + ' {\n' + + ' \"$type$\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg123\"\n' + + ' },\n' + + ' {\n' + + ' \"$type$\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg456\",\n' + + ' \"prevVersion\": \"ftdm:abcdefg123\",\n' + + ' \"changeTokens\": [\n' + + ' {\n' + + ' \"$type$\": \"meta::pure::changetoken::AddField\",\n' + + ' \"fieldName\": \"abc\",\n' + + ' \"fieldType\": \"Integer[1]\",\n' + + ' \"defaultValue\": {\n' + + ' \"$type$\": \"meta::pure::changetoken::ConstValue\",\n' + + ' \"value\": 100\n' + + ' },\n' + + ' \"safeCast\": true,\n' + + ' \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n', '$type$', '$version$'); +} + +function <> meta::pure::changetoken::tests::version::custom::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' \"$version$\":\"ftdm:abcdefg123\", \n' + + ' \"$type$\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"$type$\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"$type$\": \"meta::pure::changetoken::tests::SampleClass\"}, \n' + + ' [{\"$type$\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}'), + '{\n' + + ' \"$version$\":\"ftdm:abcdefg456\",\n' + + ' \"$type$\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"$type$\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"$type$\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n' + + ' [{\"$type$\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100}]\n' + + ' ],\n' + + ' \"abc\": 100\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::version::custom::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' \"$version$\":\"ftdm:abcdefg456\",\n' + + ' \"$type$\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"$type$\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"$type$\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n' + + ' [{\"$type$\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100}]\n' + + ' ],\n' + + ' \"abc\": 100\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' \"$version$\":\"ftdm:abcdefg123\", \n' + + ' \"$type$\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"$type$\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"$type$\": \"meta::pure::changetoken::tests::SampleClass\"}, \n' + + ' [{\"$type$\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::version::custom::testDowncastNull(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' \"$version$\":\"ftdm:abcdefg456\",\n' + + ' \"$type$\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"$type$\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"$type$\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' [{\"$type$\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' \"$version$\":\"ftdm:abcdefg123\", \n' + + ' \"$type$\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"$type$\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"$type$\": \"meta::pure::changetoken::tests::SampleClass\"}, \n' + + ' [{\"$type$\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::version::custom::testDowncastNonDefault(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' \"$version$\":\"ftdm:abcdefg456\",\n' + + ' \"$type$\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"$type$\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"$type$\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n' + + ' [{\"$type$\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100}]\n' + + ' ],\n' + + ' \"abc\": 300\n' + + '}', 'ftdm:abcdefg123'), + 'Cannot remove non-default value:300'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_version_null.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_version_null.pure new file mode 100644 index 00000000000..23a23f76445 --- /dev/null +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_test_version_null.pure @@ -0,0 +1,123 @@ +// Copyright 2024 Goldman Sachs +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import meta::pure::changetoken::tests::null::*; +import meta::pure::changetoken::tests::*; + +function meta::pure::changetoken::tests::null::setupSuite(): meta::external::language::java::metamodel::Class[1] +{ + setupSuiteFromJson('{\n' + + ' \"@type\": \"meta::pure::changetoken::Versions\",\n' + + ' \"versions\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg123\"\n' + + ' },\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::Version\",\n' + + ' \"version\": \"ftdm:abcdefg456\",\n' + + ' \"prevVersion\": \"ftdm:abcdefg123\",\n' + + ' \"changeTokens\": [\n' + + ' {\n' + + ' \"@type\": \"meta::pure::changetoken::AddField\",\n' + + ' \"fieldName\": \"abc\",\n' + + ' \"fieldType\": \"Integer[1]\",\n' + + ' \"defaultValue\": {\n' + + ' \"@type\": \"meta::pure::changetoken::ConstValue\",\n' + + ' \"value\": 100\n' + + ' },\n' + + ' \"safeCast\": true,\n' + + ' \"class\": \"meta::pure::changetoken::tests::SampleClass\"\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' ]\n' + + '}\n', '@type', []); +} + +function <> meta::pure::changetoken::tests::null::testUpcast(): Any[*] +{ + expect(setupSuite()->upcast('{\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}', 'ftdm:abcdefg123'), + '{\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100}]\n' + + ' ],\n' + + ' \"abc\": 100\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::null::testDowncast(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100}]\n' + + ' ],\n' + + ' \"abc\": 100\n' + + '}', 'ftdm:abcdefg123', 'ftdm:abcdefg456'), + '{\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::null::testDowncastNull(): Any[*] +{ + expect(setupSuite()->downcast('{\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}', 'ftdm:abcdefg123', 'ftdm:abcdefg456'), + '{\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}, \n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\"}]\n' + + ' ]\n' + + '}\n'); +} + +function <> meta::pure::changetoken::tests::null::testDowncastNonDefault(): Any[*] +{ + exception(setupSuite()->downcast('{\n' + + ' \"@type\": \"meta::pure::changetoken::tests::SampleClass\",\n' + + ' \"innerObject\": {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n' + + ' \"innerNestedArray\":[\n' + + ' {\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100},\n' + + ' [{\"@type\": \"meta::pure::changetoken::tests::SampleClass\", \"abc\": 100}]\n' + + ' ],\n' + + ' \"abc\": 300\n' + + '}', 'ftdm:abcdefg123', 'ftdm:abcdefg456'), + 'Cannot remove non-default value:300'); +} diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_util.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_util.pure index 2724c52f0c5..381c28bc9b9 100644 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_util.pure +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/cast_generation_util.pure @@ -68,7 +68,7 @@ function meta::pure::changetoken::cast_generation::toMultiplicity(type: String[1 ))))); } -function <> meta::pure::changetoken::cast_generation::inlineJsonValue(json: JSONElement[1]): Code[1] +function meta::pure::changetoken::cast_generation::inlineJsonValue(json: JSONElement[1]): Code[1] { $json->match([ b: JSONBoolean[1] | j_boolean($b.value), diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/changetoken_test.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/changetoken_test.pure index 42cc5d71f44..bdff5301665 100644 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/changetoken_test.pure +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/changetoken_test.pure @@ -49,7 +49,7 @@ Class <> meta::pure::changetoken::tests::SampleClass } // This is test Versions: AddField with ConstValue(^Map()->put('@type', 'Custom')->put('restricted', true)->put('value', 0)->put('range', ^Map()->put('@type', 'intMinMax')->put('min', -1)->put('max', 1)->put('round', 0.5))) -function <> meta::pure::changetoken::tests::getVersionsCustomMap():Versions[1] +function meta::pure::changetoken::tests::getVersionsCustomMap():Versions[1] { ^Versions( versions=[ diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/diff_generation.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/diff_generation.pure index d4817838de0..720b42038bc 100644 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/diff_generation.pure +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/diff_generation.pure @@ -37,7 +37,7 @@ function <> meta::pure::changetoken::diff_generation::getClasses $entities->packageClassesRecursive(); } -function <> meta::pure::changetoken::diff_generation::generateDiffFromVersionsAndClasses(versions: Versions[1], newClasses: Class[*], oldClasses: Class[*], propertyRenames: Map>[0..1], classRenames: Map[0..1], defaultValues: Map>[0..1], typeKeyName: String[1], versionKeyName: String[0..1]): Versions[1] +function meta::pure::changetoken::diff_generation::generateDiffFromVersionsAndClasses(versions: Versions[1], newClasses: Class[*], oldClasses: Class[*], propertyRenames: Map>[0..1], classRenames: Map[0..1], defaultValues: Map>[0..1], typeKeyName: String[1], versionKeyName: String[0..1]): Versions[1] { let prevVersion = if($versions.versions->size() > 0, | $versions.versions->at($versions.versions->size() - 1).version, | []); let version = ^Version( @@ -158,7 +158,7 @@ function <> meta::pure::changetoken::diff_generation::getAddFiel fieldName = $cp.second.name->toOne(), fieldType = stripVersionQualifier(printGenericType($cp.second.genericType)) + '[' + printMultiplicity($cp.second.multiplicity) + ']', safeCast = true, - defaultValue = ^ConstValue(value = lookupOrAny($defaultValues, stripPath($cp.first), $cp.second.name->toOne(), if($cp.second.defaultValue->isEmpty(), | generateDefault($cp.second, $typeKeyName, $versionKeyName), | $cp.second.defaultValue.functionDefinition->toOne()->cast(@Function<{->Any[*]}>)->eval()->serializeAny($cp.second, $typeKeyName, $versionKeyName)), $cp.second, $typeKeyName, $versionKeyName)) + defaultValue = ^ConstValue(value = lookupOrAny($defaultValues, stripPath($cp.first), $cp.second.name->toOne(), if($cp.second.defaultValue->isEmpty(), | generateDefault($cp.second, $typeKeyName, $versionKeyName), | $cp.second.defaultValue.functionDefinition.expressionSequence->evaluateAndDeactivate()->serializeAny($cp.second, $typeKeyName, $versionKeyName)), $cp.second, $typeKeyName, $versionKeyName)) )); } @@ -218,9 +218,19 @@ function <> meta::pure::changetoken::diff_generation::getRenamed ))); } -function <> meta::pure::changetoken::diff_generation::serializeAny(any: Any[*], property: Property[1], typeKeyName: String[1], versionKeyName: String[0..1]): JSONElement[1] +function <> meta::pure::changetoken::diff_generation::serializeAny(any: Any[*], property: Property[0..1], typeKeyName: String[1], versionKeyName: String[0..1]): JSONElement[1] { let values = $any->map(i | $i->match([ + i: InstanceValue[1] | serializeAny($i.values, [], $typeKeyName, $versionKeyName), + s: SimpleFunctionExpression[1] | $s.genericType.rawType->match([ + p: PrimitiveType[1] | serializeAny(minus($s.parametersValues->at(0)->cast(@InstanceValue).values->cast(@Number)), [], $typeKeyName, $versionKeyName), + en: Enumeration[1] | let e = $en->enumValues()->filter(v:Enum[1]| $v->id()==$s.parametersValues->at(1)->cast(@InstanceValue).values->cast(@String))->toOne()->cast(@Enum); ^JSONString(value = stripVersionQualifier($e->type()->toOne()->elementToPath() + '.' + $e->id()));, + c: Class[1] | newJSONObject([newJSONKeyValue($typeKeyName, ^JSONString(value = stripVersionQualifier($c->elementToPath()->toString())))] + ->concatenate($s.parametersValues->at(2)->cast(@InstanceValue).values->cast(@KeyExpression)->map(x | newJSONKeyValue($x.key->cast(@InstanceValue).values->toOne()->toString(), serializeAny($x.expression, $c.properties->filter(p | $p.name == $x.key->cast(@InstanceValue).values->toOne()->toString())->toOne()->cast(@Property), $typeKeyName, $versionKeyName)))) + ->concatenate($c.properties->filter(p | $p.name != $versionKeyName) + ->filter(p | $s.parametersValues->at(2)->cast(@InstanceValue).values->cast(@KeyExpression)->map(x | $x.key->cast(@InstanceValue).values->toOne()->toString())->contains($p.name->toOne())->not()) + ->map(p | newJSONKeyValue($p.name->toOne(), generateDefault($p, $typeKeyName, $versionKeyName))))) + ]), s: String[1] | ^JSONString(value = $s), d: Date[1] | ^JSONString(value = $d->toString()), d: DateTime[1] | ^JSONString(value = $d->toString()), @@ -235,7 +245,10 @@ function <> meta::pure::changetoken::diff_generation::serializeA l: List[1] | $l->expandValue($typeKeyName)->cast(@JSONArray).values, a: Any[1] | let c = $a->class(); newJSONObject([newJSONKeyValue($typeKeyName, ^JSONString(value = stripVersionQualifier($c->elementToPath()->toString())))]->concatenate($c.properties->filter(p | $p.name != $versionKeyName)->map(p | newJSONKeyValue($p.name->toOne(), serializeAny($p->eval($a), $p, $typeKeyName, $versionKeyName))))); ])); - if($property.multiplicity == PureOne || $property.multiplicity == PureZero || $property.multiplicity == ZeroOne, | if($property.multiplicity == PureZero || $property.multiplicity == ZeroOne && $values->size() == 0, | ^JSONNull(), | $values->toOne('Expecting one for property: ' + $property.name->toOne())), | ^JSONArray(values = $values)); + let ret = if($property != [], | if($property.multiplicity == PureOne || $property.multiplicity == PureZero || $property.multiplicity == ZeroOne, | if($property.multiplicity == PureZero || $property.multiplicity == ZeroOne && $values->size() == 0, | ^JSONNull(), | $values->toOne('Expecting one for property')), + | if($values->size() == 1 && $values->toOne()->instanceOf(JSONArray), | $values, | ^JSONArray(values = $values))), + | if($values->size() == 1, | $values->toOne(), | ^JSONArray(values = $values))); + $ret->toOne(); } function <> meta::pure::changetoken::diff_generation::generateDefault(property: Property[1], typeKeyName: String[1], versionKeyName: String[0..1]): JSONElement[1] diff --git a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/diff_generation_test.pure b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/diff_generation_test.pure index 462c89224e3..8ee28204cbb 100644 --- a/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/diff_generation_test.pure +++ b/legend-engine-xts-changetoken/legend-engine-xt-changetoken-pure/src/main/resources/core_pure_changetoken/diff_generation_test.pure @@ -14,6 +14,7 @@ import meta::json::*; import meta::pure::changetoken::*; +import meta::pure::changetoken::cast_generation::*; import meta::pure::changetoken::diff_generation::*; import meta::pure::changetoken::tests::*; @@ -274,3 +275,16 @@ function <> meta::pure::changetoken::tests::testGetTokens(): Boolean[ let tokens = getHashTokens($classes, 'version'); assertEquals(['meta::pure::changetoken::tests::OldSampleClass', 'xyz', 'String[1]'], $tokens); } + +function <> meta::pure::changetoken::tests::testInterpreted(): Boolean[1] +{ + let oldScope = []; + let newScope = meta::legend::compileLegendGrammar('Class xxx::new::entities::vX_X_X::XXX{abc : String[1] = \'UNKNOWN\';} Class xxx::new::entities::vX_X_X::YYY{def : xxx::new::entities::vX_X_X::XXX[1] = ^xxx::new::entities::vX_X_X::XXX(abc=\'INVALID\'); ghi : xxx::new::entities::vX_X_X::XXX[1];}')->cast(@Class); + let oldVersions = ^Versions(versions = [^Version(version = 'da39a3ee5e6b4b0d3255bfef95601890afd80709')]); + let newVersions = $oldVersions->generateDiffFromVersionsAndClasses($newScope, $oldScope, [], [], [], '@type', 'version'); + let jsonVersions = $newVersions->versionsToJson('@type'); + let expectedJson = '{"@type":"meta::pure::changetoken::Versions","versions":[{"@type":"meta::pure::changetoken::Version","version":"da39a3ee5e6b4b0d3255bfef95601890afd80709"},{"@type":"meta::pure::changetoken::Version","changeTokens":[{"@type":"meta::pure::changetoken::AddedClass","class":"xxx::XXX"},{"@type":"meta::pure::changetoken::AddField","class":"xxx::XXX","defaultValue":{"@type":"meta::pure::changetoken::ConstValue","value":"UNKNOWN"},"fieldName":"abc","fieldType":"String[1]","safeCast":true},{"@type":"meta::pure::changetoken::AddedClass","class":"xxx::YYY"},{"@type":"meta::pure::changetoken::AddField","class":"xxx::YYY","defaultValue":{"@type":"meta::pure::changetoken::ConstValue","value":{"@type":"xxx::XXX","abc":"INVALID"}},"fieldName":"def","fieldType":"xxx::XXX[1]","safeCast":true},{"@type":"meta::pure::changetoken::AddField","class":"xxx::YYY","defaultValue":{"@type":"meta::pure::changetoken::ConstValue","value":{"@type":"xxx::XXX","abc":""}},"fieldName":"ghi","fieldType":"xxx::XXX[1]","safeCast":true}],"prevVersion":"da39a3ee5e6b4b0d3255bfef95601890afd80709","version":"65896f85895f1305e1c69d233118d0da1402ee4d"}]}'; + assertEquals($expectedJson->parseJSON()->sort()->toCompactJSONString(), $jsonVersions->parseJSON()->sort()->toCompactJSONString()); + let class = setupSuiteFromVersions($newVersions)->upcast('{"version":"da39a3ee5e6b4b0d3255bfef95601890afd80709","@type":"xxx::XXX"}'); + $class->expect('{"version":"65896f85895f1305e1c69d233118d0da1402ee4d","@type":"xxx::XXX","abc":"UNKNOWN"}'); +}