From 7d5c114075eae1e4b4e47dbce77beef40ab9c450 Mon Sep 17 00:00:00 2001 From: Niko Stotz Date: Sat, 29 Jun 2024 12:27:33 +0200 Subject: [PATCH 1/4] added dynamic ContainmentTests_Annotation (translated from C#) --- .../shapes/dynamic/ShapesDynamic.java | 43 + .../test/ContainmentTests_Annotation.java | 1188 +++++++ .../m2/dynamic/test/DynamicNodeTestsBase.java | 286 ++ .../lionweb/utils/tests/CollectionAssert.java | 20 + .../test/java/lionweb/utils/tests/INode.java | 6 + .../java/lionweb/utils/tests/IdTests.java | 112 + .../resources/languages/defChunks/shapes.json | 2771 +++++++++++++++++ 7 files changed, 4426 insertions(+) create mode 100644 core/src/test/java/examples/shapes/dynamic/ShapesDynamic.java create mode 100644 core/src/test/java/lionweb/core/m2/dynamic/test/ContainmentTests_Annotation.java create mode 100644 core/src/test/java/lionweb/core/m2/dynamic/test/DynamicNodeTestsBase.java create mode 100644 core/src/test/java/lionweb/utils/tests/CollectionAssert.java create mode 100644 core/src/test/java/lionweb/utils/tests/INode.java create mode 100644 core/src/test/java/lionweb/utils/tests/IdTests.java create mode 100644 core/src/test/resources/languages/defChunks/shapes.json diff --git a/core/src/test/java/examples/shapes/dynamic/ShapesDynamic.java b/core/src/test/java/examples/shapes/dynamic/ShapesDynamic.java new file mode 100644 index 00000000..cfe62bf9 --- /dev/null +++ b/core/src/test/java/examples/shapes/dynamic/ShapesDynamic.java @@ -0,0 +1,43 @@ +// Copyright 2024 TRUMPF Laser SE and other contributors +// +// 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. +// +// SPDX-FileCopyrightText: 2024 TRUMPF Laser SE and other contributors +// SPDX-License-Identifier: Apache-2.0 + +package examples.shapes.dynamic; + +import io.lionweb.lioncore.java.serialization.JsonSerialization; + +import java.io.IOException; +import java.io.InputStream; + +/** + * Entrypoint for working with the Shapes example language. + */ +public class ShapesDynamic { + public static final io.lionweb.lioncore.java.language.Language Language; + + static { + try (InputStream inputStream = ShapesDynamic.class.getResourceAsStream("/languages/defChunks/shapes.json")) { + Language = JsonSerialization + .getStandardSerialization() + .loadLanguage(inputStream); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + +// public static final INodeFactory Factory = Language.getFactory(); +} + diff --git a/core/src/test/java/lionweb/core/m2/dynamic/test/ContainmentTests_Annotation.java b/core/src/test/java/lionweb/core/m2/dynamic/test/ContainmentTests_Annotation.java new file mode 100644 index 00000000..3bddf202 --- /dev/null +++ b/core/src/test/java/lionweb/core/m2/dynamic/test/ContainmentTests_Annotation.java @@ -0,0 +1,1188 @@ +// Copyright 2024 TRUMPF Laser SE and other contributors +// +// 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. +// +// SPDX-FileCopyrightText: 2024 TRUMPF Laser SE and other contributors +// SPDX-License-Identifier: Apache-2.0 + +package lionweb.core.m2.dynamic.test; + + +import com.google.common.collect.Lists; +import lionweb.utils.tests.CollectionAssert; +import io.lionweb.lioncore.java.model.AnnotationInstance; +import io.lionweb.lioncore.java.model.impl.AbstractClassifierInstance; +import org.junit.Assert; +import org.junit.Test; + +import java.util.Collections; + +public class ContainmentTests_Annotation extends DynamicNodeTestsBase { +// #region Single + + @Test + public void Single_Add() { + AbstractClassifierInstance parent = newLine("g"); + AnnotationInstance bom = newBillOfMaterials("myId"); + parent.addAnnotation(bom); + Assert.assertEquals(parent, bom.getParent()); + Assert.assertTrue(parent.getAnnotations().contains(bom)); + } + +// @Test +// public void Single_Reflective() +// { +// AbstractClassifierInstance parent = newLine("g"); +// AbstractClassifierInstance bom = newBillOfMaterials("myId"); +// Assert.assertThrows(InvalidValueException>(() -> parent.Set(null, bom)); +// Assert.assertEquals(null, bom.getParent()); +// Assert.assertFalse(parent.getAnnotations().contains(bom)); +// } + +// #region Insert + +// @Test +// public void Single_Insert_Empty() +// { +// AbstractClassifierInstance parent = newLine("g"); +// AnnotationInstance bom = newBillOfMaterials("myId"); +// parent.InsertAnnotations(0, [bom]); +// Assert.assertEquals(parent, bom.getParent()); +// Assert.assertTrue(parent.getAnnotations().contains(bom)); +// } + +// @Test +// public void Single_Insert_Empty_UnderBounds() +// { +// AbstractClassifierInstance parent = newLine("g"); +// AnnotationInstance bom = newBillOfMaterials("myId"); +// Assert.assertThrows(ArgumentOutOfRangeException>(() -> parent.InsertAnnotations(-1, [bom])); +// Assert.assertNull(bom.getParent()); +// Assert.assertFalse(parent.getAnnotations().contains(bom)); +// } + +// @Test +// public void Single_Insert_Empty_OverBounds() +// { +// AbstractClassifierInstance parent = newLine("g"); +// AnnotationInstance bom = newBillOfMaterials("myId"); +// Assert.assertThrows(ArgumentOutOfRangeException>(() -> parent.InsertAnnotations(1, [bom])); +// Assert.assertNull(bom.getParent()); +// Assert.assertFalse(parent.getAnnotations().contains(bom)); +// } + +// @Test +// public void Single_Insert_One_Before() +// { +// AnnotationInstance doc = newDocumentation("cId"); +// AbstractClassifierInstance parent = newLine("g"); +// parent.addAnnotation(doc); +// AnnotationInstance bom = newBillOfMaterials("myId"); +// parent.InsertAnnotations(0, [bom]); +// Assert.assertEquals(parent, doc.getParent()); +// Assert.assertEquals(parent, bom.getParent()); +// Assert.assertTrue(parent.getAnnotations().contains(bom)); +// CollectionAssert.AreEqual(Lists.newArrayList( bom, doc }, parent.getAnnotations()); +// } + +// @Test +// public void Single_Insert_One_After() +// { +// AnnotationInstance doc = newDocumentation("cId"); +// AbstractClassifierInstance parent = newLine("g"); +// parent.addAnnotation(doc); +// AnnotationInstance bom = newBillOfMaterials("myId"); +// parent.InsertAnnotations(1, [bom]); +// Assert.assertEquals(parent, doc.getParent()); +// Assert.assertEquals(parent, bom.getParent()); +// Assert.assertTrue(parent.getAnnotations().contains(bom)); +// CollectionAssert.AreEqual(Lists.newArrayList( doc, bom }, parent.getAnnotations()); +// } + +// @Test +// public void Single_Insert_Two_Before() +// { +// AnnotationInstance docA = newDocumentation("cIdA"); +// AnnotationInstance docB = newDocumentation("cIdB"); +// AbstractClassifierInstance parent = newLine("g"); +// parent.addAnnotation(docA, docB); +// AnnotationInstance bom = newBillOfMaterials("myId"); +// parent.InsertAnnotations(0, [bom]); +// Assert.assertEquals(parent, docA.getParent()); +// Assert.assertEquals(parent, docB.getParent()); +// Assert.assertEquals(parent, bom.getParent()); +// Assert.assertTrue(parent.getAnnotations().contains(bom)); +// CollectionAssert.AreEqual(Lists.newArrayList( bom, docA, docB }, parent.getAnnotations()); +// } + +// @Test +// public void Single_Insert_Two_Between() +// { +// AnnotationInstance docA = newDocumentation("cIdA"); +// AnnotationInstance docB = newDocumentation("cIdB"); +// AbstractClassifierInstance parent = newLine("g"); +// parent.addAnnotation(docA, docB]); +// AnnotationInstance bom = newBillOfMaterials("myId"); +// parent.InsertAnnotations(1, [bom]); +// Assert.assertEquals(parent, docA.getParent()); +// Assert.assertEquals(parent, docB.getParent()); +// Assert.assertEquals(parent, bom.getParent()); +// Assert.assertTrue(parent.getAnnotations().contains(bom)); +// CollectionAssert.AreEqual(Lists.newArrayList( docA, bom, docB }, parent.getAnnotations()); +// } + +// @Test +// public void Single_Insert_Two_After() +// { +// AnnotationInstance docA = newDocumentation("cIdA"); +// AnnotationInstance docB = newDocumentation("cIdB"); +// AbstractClassifierInstance parent = newLine("g"); +// parent.addAnnotation(docA, docB]); +// AnnotationInstance bom = newBillOfMaterials("myId"); +// parent.InsertAnnotations(2, [bom]); +// Assert.assertEquals(parent, docA.getParent()); +// Assert.assertEquals(parent, docB.getParent()); +// Assert.assertEquals(parent, bom.getParent()); +// Assert.assertTrue(parent.getAnnotations().contains(bom)); +// CollectionAssert.AreEqual(Lists.newArrayList( docA, docB, bom }, parent.getAnnotations()); +// } + +// #endregion + +// #region Remove + + @Test + public void Single_Remove_Empty() { + AbstractClassifierInstance parent = newLine("g"); + AnnotationInstance bom = newBillOfMaterials("myId"); + parent.removeAnnotation(bom); + Assert.assertNull(bom.getParent()); + Assert.assertFalse(parent.getAnnotations().contains(bom)); + } + + @Test + public void Single_Remove_NotContained() { + AnnotationInstance doc = newDocumentation("myC"); + AbstractClassifierInstance parent = newLine("cs"); + parent.addAnnotation(doc); + AnnotationInstance bom = newBillOfMaterials("myId"); + parent.removeAnnotation(bom); + Assert.assertEquals(parent, doc.getParent()); + Assert.assertNull(bom.getParent()); + Assert.assertEquals(Lists.newArrayList(doc), parent.getAnnotations()); + } + + @Test + public void Single_Remove_Only() { + AnnotationInstance bom = newBillOfMaterials("myId"); + AbstractClassifierInstance parent = newLine("g"); + parent.addAnnotation(bom); + parent.removeAnnotation(bom); + Assert.assertNull(bom.getParent()); + Assert.assertEquals(Collections.emptyList(), parent.getAnnotations()); + } + + @Test + public void Single_Remove_First() { + AnnotationInstance doc = newDocumentation("cId"); + AnnotationInstance bom = newBillOfMaterials("myId"); + AbstractClassifierInstance parent = newLine("g"); + parent.addAnnotation(bom); + parent.addAnnotation(doc); + parent.removeAnnotation(bom); + Assert.assertEquals(parent, doc.getParent()); + Assert.assertNull(bom.getParent()); + CollectionAssert.AreEqual(Lists.newArrayList(doc), parent.getAnnotations()); + } + + @Test + public void Single_Remove_Last() { + AnnotationInstance doc = newDocumentation("cId"); + AnnotationInstance bom = newBillOfMaterials("myId"); + AbstractClassifierInstance parent = newLine("g"); + parent.addAnnotation(doc); + parent.addAnnotation(bom); + parent.removeAnnotation(bom); + Assert.assertEquals(parent, doc.getParent()); + Assert.assertNull(bom.getParent()); + CollectionAssert.AreEqual(Lists.newArrayList(doc), parent.getAnnotations()); + } + + @Test + public void Single_Remove_Between() { + AnnotationInstance docA = newDocumentation("cIdA"); + AnnotationInstance docB = newDocumentation("cIdB"); + AnnotationInstance bom = newBillOfMaterials("myId"); + AbstractClassifierInstance parent = newLine("g"); + parent.addAnnotation(docA); + parent.addAnnotation(bom); + parent.addAnnotation(docB); + parent.removeAnnotation(bom); + Assert.assertEquals(parent, docA.getParent()); + Assert.assertEquals(parent, docB.getParent()); + Assert.assertNull(bom.getParent()); + CollectionAssert.AreEqual(Lists.newArrayList(docA, docB), parent.getAnnotations()); + } + +// #endregion + +// #endregion + +// #region Null + + @Test + public void Null() { + AbstractClassifierInstance parent = newLine("g"); + Assert.assertThrows(NullPointerException.class, () -> parent.addAnnotation(null)); + } + +// @Test +// public void Null_Reflective() +// { +// AbstractClassifierInstance parent = newLine("g"); +// Assert.assertThrows(InvalidValueException>(() -> parent.Set(null, null)); +// } + +// @Test +// public void Null_Insert_Empty() +// { +// AbstractClassifierInstance parent = newLine("g"); +// Assert.assertThrows(InvalidValueException>(() -> parent.InsertAnnotations(0, null)); +// } + +// @Test +// public void Null_Insert_Empty_OutOfBounds() +// { +// AbstractClassifierInstance parent = newLine("g"); +// Assert.assertThrows(ArgumentOutOfRangeException>(() -> parent.InsertAnnotations(1, null)); +// } + + @Test + public void Null_Remove_Empty() { + AbstractClassifierInstance parent = newLine("g"); + Assert.assertThrows(NullPointerException.class, () -> parent.removeAnnotation(null)); + } + +// #endregion + +// #region EmptyCollection + +// @Test +// public void EmptyArray() +// { +// AbstractClassifierInstance parent = newLine("g"); +// AbstractClassifierInstance[] values = new AbstractClassifierInstance[0]; +// parent.addAnnotation(values); +// Assert.assertTrue(parent.getAnnotations().size() == 0); +// } + +// @Test +// public void EmptyArray_Reflective() +// { +// AbstractClassifierInstance parent = newLine("g"); +// AbstractClassifierInstance[] values = new AbstractClassifierInstance[0]; +// parent.Set(null, values); +// Assert.assertTrue(parent.getAnnotations().size() == 0); +// } + +// @Test +// public void Insert_EmptyArray() +// { +// AbstractClassifierInstance parent = newLine("g"); +// AbstractClassifierInstance[] values = new AbstractClassifierInstance[0]; +// parent.InsertAnnotations(0, values); +// Assert.assertTrue(parent.getAnnotations().size() == 0); +// } + +// @Test +// public void Remove_EmptyArray() +// { +// AbstractClassifierInstance parent = newLine("g"); +// AbstractClassifierInstance[] values = new AbstractClassifierInstance[0]; +// parent.RemoveAnnotations(values); +// Assert.assertTrue(parent.getAnnotations().size() == 0); +// } + +// @Test +// public void EmptyUntypedList_Reflective() +// { +// AbstractClassifierInstance parent = newLine("g"); +// ArrayList values = new ArrayList(); +// parent.Set(null, values); +// Assert.assertTrue(parent.getAnnotations().size() == 0); +// } + +// @Test +// public void EmptyListMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newLine("g"); +// ArrayList values = new ArrayList(); +// parent.Set(null, values); +// Assert.assertTrue(parent.getAnnotations().size() == 0); +// } + +// @Test +// public void EmptySet_Reflective() +// { +// AbstractClassifierInstance parent = newLine("g"); +// HashSet values = new HashSet(); +// parent.Set(null, values); +// Assert.assertTrue(parent.getAnnotations().size() == 0); +// } + +// #endregion + +// #region NullCollection + +// @Test +// public void NullArray() +// { +// AbstractClassifierInstance parent = newLine("g"); +// AbstractClassifierInstance[] values = new AbstractClassifierInstance[] { null }; +// Assert.assertThrows(InvalidValueException>(() -> parent.addAnnotation(values)); +// Assert.assertTrue(parent.getAnnotations().size() == 0); +// } + +// @Test +// public void NullArray_Reflective() +// { +// AbstractClassifierInstance parent = newLine("g"); +// AbstractClassifierInstance[] values = new AbstractClassifierInstance[] { null }; +// Assert.assertThrows(InvalidValueException>( +// () -> parent.Set(null, values)); +// Assert.assertTrue(parent.getAnnotations().size() == 0); +// } + +// @Test +// public void Insert_NullArray() +// { +// AbstractClassifierInstance parent = newLine("g"); +// AbstractClassifierInstance[] values = new AbstractClassifierInstance[] { null }; +// Assert.assertThrows(InvalidValueException>(() -> parent.InsertAnnotations(0, values)); +// Assert.assertTrue(parent.getAnnotations().size() == 0); +// } + +// @Test +// public void Remove_NullArray() +// { +// AbstractClassifierInstance parent = newLine("g"); +// AbstractClassifierInstance[] values = new AbstractClassifierInstance[] { null }; +// Assert.assertThrows(InvalidValueException>(() -> parent.RemoveAnnotations(values)); +// Assert.assertTrue(parent.getAnnotations().size() == 0); +// } + +// @Test +// public void NullUntypedList_Reflective() +// { +// AbstractClassifierInstance parent = newLine("g"); +// AbstractClassifierInstance values = new ArrayList() { null }; +// Assert.assertThrows(InvalidValueException>( +// () -> parent.Set(null, values)); +// Assert.assertTrue(parent.getAnnotations().size() == 0); +// } + +// @Test +// public void NullListMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newLine("g"); +// AbstractClassifierInstance values = new List() { null }; +// Assert.assertThrows(InvalidValueException>( +// () -> parent.Set(null, values)); +// Assert.assertTrue(parent.getAnnotations().size() == 0); +// } + +// @Test +// public void NullSet_Reflective() +// { +// AbstractClassifierInstance parent = newLine("g"); +// AbstractClassifierInstance values = new HashSet() { null }; +// Assert.assertThrows(InvalidValueException>( +// () -> parent.Set(null, values)); +// Assert.assertTrue(parent.getAnnotations().size() == 0); +// } + +// #endregion + +// #region SingleCollection + +// @Test +// public void SingleArray() +// { +// AbstractClassifierInstance parent = newLine("g"); +// AnnotationInstance value = newBillOfMaterials("s"); +// AnnotationInstance[] values = new AnnotationInstance[]{ value }; +// parent.addAnnotation(values); +// Assert.assertEquals(parent, value.getParent()); +// Assert.assertTrue(parent.getAnnotations().contains(value)); +// } + +// @Test +// public void SingleArray_Reflective() +// { +// AbstractClassifierInstance parent = newLine("g"); +// AnnotationInstance value = newBillOfMaterials("s"); +// AnnotationInstance[] values = new AnnotationInstance[]{ value }; +// parent.Set(null, values); +// Assert.assertEquals(parent, value.getParent()); +// Assert.assertTrue(parent.getAnnotations().contains(value)); +// } + +// @Test +// public void SingleArray_Existing_Reflective() +// { +// AnnotationInstance doc = newDocumentation("cc"); +// AbstractClassifierInstance parent = newLine("g"); +// parent.addAnnotation(]); +// AnnotationInstance value = newBillOfMaterials("s"); +// AnnotationInstance[] values = new AnnotationInstance[]{ value }; +// parent.Set(null, values); +// Assert.assertNull(doc.getParent()); +// Assert.assertEquals(parent, value.getParent()); +// CollectionAssert.AreEqual(Lists.newArrayList( value }, parent.getAnnotations()); +// } + +// @Test +// public void Insert_SingleArray() +// { +// AbstractClassifierInstance parent = newLine("g"); +// AnnotationInstance value = newBillOfMaterials("s"); +// AnnotationInstance[] values = new AnnotationInstance[]{ value }; +// parent.InsertAnnotations(0, values); +// Assert.assertEquals(parent, value.getParent()); +// Assert.assertTrue(parent.getAnnotations().contains(value)); +// } + +// #region Remove + +// @Test +// public void SingleArray_Remove_Empty() +// { +// AbstractClassifierInstance parent = newLine("g"); +// AnnotationInstance bom = newBillOfMaterials("myId"); +// AnnotationInstance[] values = new AnnotationInstance[]{ bom }; +// parent.RemoveAnnotations(values); +// Assert.assertNull(bom.getParent()); +// Assert.assertFalse(parent.getAnnotations().contains(bom)); +// } + +// @Test +// public void SingleArray_Remove_Only() +// { +// AnnotationInstance bom = newBillOfMaterials("myId"); +// AbstractClassifierInstance parent = newLine("g"); +// parent.addAnnotation(bom]); +// AnnotationInstance[] values = new AnnotationInstance[]{ bom }; +// parent.RemoveAnnotations(values); +// Assert.assertNull(bom.getParent()); +// CollectionAssert.AreEqual(Lists.newArrayList( }, parent.getAnnotations()); +// } + +// @Test +// public void SingleArray_Remove_First() +// { +// AnnotationInstance doc = newDocumentation("cId"); +// AnnotationInstance bom = newBillOfMaterials("myId"); +// AbstractClassifierInstance parent = newLine("g"); +// parent.addAnnotation(bom, doc]); +// AnnotationInstance[] values = new AnnotationInstance[]{ bom }; +// parent.RemoveAnnotations(values); +// Assert.assertEquals(parent, doc.getParent()); +// Assert.assertNull(bom.getParent()); +// CollectionAssert.AreEqual(Lists.newArrayList( doc }, parent.getAnnotations()); +// } + +// @Test +// public void SingleArray_Remove_Last() +// { +// AnnotationInstance doc = newDocumentation("cId"); +// AnnotationInstance bom = newBillOfMaterials("myId"); +// AbstractClassifierInstance parent = newLine("g"); +// parent.addAnnotation(doc, bom]); +// AnnotationInstance[] values = new AnnotationInstance[]{ bom }; +// parent.RemoveAnnotations(values); +// Assert.assertEquals(parent, doc.getParent()); +// Assert.assertNull(bom.getParent()); +// CollectionAssert.AreEqual(Lists.newArrayList( doc }, parent.getAnnotations()); +// } + +// @Test +// public void SingleArray_Remove_Between() +// { +// AnnotationInstance docA = newDocumentation("cIdA"); +// AnnotationInstance docB = newDocumentation("cIdB"); +// AnnotationInstance bom = newBillOfMaterials("myId"); +// AbstractClassifierInstance parent = newLine("g"); +// parent.addAnnotation(docA, bom, docB]); +// AnnotationInstance[] values = new AnnotationInstance[]{ bom }; +// parent.RemoveAnnotations(values); +// Assert.assertEquals(parent, docA.getParent()); +// Assert.assertEquals(parent, docB.getParent()); +// Assert.assertNull(bom.getParent()); +// CollectionAssert.AreEqual(Lists.newArrayList( docA, docB }, parent.getAnnotations()); +// } + +// #endregion + +// @Test +// public void SingleUntypedArray_Reflective() +// { +// AbstractClassifierInstance parent = newLine("g"); +// AnnotationInstance value = newBillOfMaterials("s"); +// Object[] values = new Object[] { value }; +// parent.Set(null, values); +// Assert.assertEquals(parent, value.getParent()); +// Assert.assertTrue(parent.getAnnotations().contains(value)); +// } + +// @Test +// public void SingleUntypedList_Reflective() +// { +// AbstractClassifierInstance parent = newLine("g"); +// AnnotationInstance value = newBillOfMaterials("s"); +// AbstractClassifierInstance values = new ArrayList() { value }; +// parent.Set(null, values); +// Assert.assertEquals(parent, value.getParent()); +// Assert.assertTrue(parent.getAnnotations().contains(value)); +// } + +// @Test +// public void SingleListMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newLine("g"); +// AnnotationInstance value = newBillOfMaterials("s"); +// AbstractClassifierInstance values = new ArrayList() { value }; +// parent.Set(null, values); +// Assert.assertEquals(parent, value.getParent()); +// Assert.assertTrue(parent.getAnnotations().contains(value)); +// } + +// @Test +// public void SingleSet_Reflective() +// { +// AbstractClassifierInstance parent = newLine("g"); +// AnnotationInstance value = newBillOfMaterials("s"); +// AbstractClassifierInstance values = new HashSet() { value }; +// parent.Set(null, values); +// Assert.assertEquals(parent, value.getParent()); +// Assert.assertTrue(parent.getAnnotations().contains(value)); +// } + +// @Test +// public void SingleListNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newLine("g"); +// AbstractClassifierInstance value = newCoord("c"); +// AbstractClassifierInstance values = new ArrayList() { value }; +// Assert.assertThrows(InvalidValueException>( +// () -> parent.Set(null, values)); +// Assert.assertTrue(parent.getAnnotations().size() == 0); +// } + +// @Test +// public void SingleUntypedListNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newLine("g"); +// AbstractClassifierInstance value = newCoord("c"); +// AbstractClassifierInstance values = new ArrayList() { value }; +// Assert.assertThrows(InvalidValueException>( +// () -> parent.Set(null, values)); +// Assert.assertTrue(parent.getAnnotations().size() == 0); +// } + +// @Test +// public void SingleUntypedArrayNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newLine("g"); +// AbstractClassifierInstance value = newCoord("c"); +// Object[] values = new Object[] { value }; +// Assert.assertThrows(InvalidValueException>( +// () -> parent.Set(null, values)); +// Assert.assertTrue(parent.getAnnotations().size() == 0); +// } + +// #endregion + +// #region MultipleCollection + +// @Test +// public void MultipleArray() +// { +// AbstractClassifierInstance parent = newLine("g"); +// AnnotationInstance valueA = newBillOfMaterials("sA"); +// AnnotationInstance valueB = newBillOfMaterials("sB"); +// AnnotationInstance[] values = new AnnotationInstance[]{ valueA, valueB }; +// parent.addAnnotation(values); +// Assert.assertEquals(parent, valueA.getParent()); +// Assert.assertTrue(parent.getAnnotations().contains(valueA)); +// Assert.assertEquals(parent, valueB.getParent()); +// Assert.assertTrue(parent.getAnnotations().contains(valueB)); +// } + +// @Test +// public void MultipleArray_Reflective() +// { +// AbstractClassifierInstance parent = newLine("g"); +// AnnotationInstance valueA = newBillOfMaterials("sA"); +// AnnotationInstance valueB = newBillOfMaterials("sB"); +// AnnotationInstance[] values = new AnnotationInstance[]{ valueA, valueB }; +// parent.Set(null, values); +// Assert.assertEquals(parent, valueA.getParent()); +// Assert.assertTrue(parent.getAnnotations().contains(valueA)); +// Assert.assertEquals(parent, valueB.getParent()); +// Assert.assertTrue(parent.getAnnotations().contains(valueB)); +// } + +// #region Insert + +// @Test +// public void Multiple_Insert_ListMatchingType() +// { +// AbstractClassifierInstance parent = newLine("g"); +// AnnotationInstance valueA = newBillOfMaterials("sA"); +// AnnotationInstance valueB = newBillOfMaterials("sB"); +// AbstractClassifierInstance values = new ArrayList { valueA, valueB }; +// parent.InsertAnnotations(0, values); +// Assert.assertEquals(parent, valueA.getParent()); +// Assert.assertEquals(parent, valueB.getParent()); +// CollectionAssert.AreEqual(Lists.newArrayList( valueA, valueB }, parent.getAnnotations()); +// } + +// @Test +// public void Multiple_Insert_Set() +// { +// AbstractClassifierInstance parent = newLine("g"); +// AnnotationInstance valueA = newBillOfMaterials("sA"); +// AnnotationInstance valueB = newBillOfMaterials("sB"); +// AbstractClassifierInstance values = new HashSet { valueA, valueB }; +// parent.InsertAnnotations(0, values); +// Assert.assertEquals(parent, valueA.getParent()); +// Assert.assertEquals(parent, valueB.getParent()); +// CollectionAssert.AreEqual(Lists.newArrayList( valueA, valueB }, parent.getAnnotations()); +// } + +// @Test +// public void Multiple_Insert_SingleEnumerable() +// { +// AbstractClassifierInstance parent = newLine("g"); +// AnnotationInstance valueA = newBillOfMaterials("sA"); +// AnnotationInstance valueB = newBillOfMaterials("sB"); +// AbstractClassifierInstance values = new SingleEnumerable { valueA, valueB }; +// parent.InsertAnnotations(0, values); +// Assert.assertEquals(parent, valueA.getParent()); +// Assert.assertEquals(parent, valueB.getParent()); +// CollectionAssert.AreEqual(Lists.newArrayList( valueA, valueB }, parent.getAnnotations()); +// } + +// @Test +// public void Multiple_Insert_Empty() +// { +// AbstractClassifierInstance parent = newLine("g"); +// AnnotationInstance valueA = newBillOfMaterials("sA"); +// AnnotationInstance valueB = newBillOfMaterials("sB"); +// AnnotationInstance[] values = new AnnotationInstance[]{ valueA, valueB }; +// parent.InsertAnnotations(0, values); +// Assert.assertEquals(parent, valueA.getParent()); +// Assert.assertEquals(parent, valueB.getParent()); +// CollectionAssert.AreEqual(Lists.newArrayList( valueA, valueB }, parent.getAnnotations()); +// } + +// @Test +// public void Multiple_Insert_One_Before() +// { +// AnnotationInstance doc = newDocumentation("cId"); +// AbstractClassifierInstance parent = newLine("g"); +// parent.addAnnotation(doc]); +// AnnotationInstance valueA = newBillOfMaterials("sA"); +// AnnotationInstance valueB = newBillOfMaterials("sB"); +// AnnotationInstance[] values = new AnnotationInstance[]{ valueA, valueB }; +// parent.InsertAnnotations(0, values); +// Assert.assertEquals(parent, doc.getParent()); +// Assert.assertEquals(parent, valueA.getParent()); +// Assert.assertEquals(parent, valueB.getParent()); +// CollectionAssert.AreEqual(Lists.newArrayList( valueA, valueB, doc }, parent.getAnnotations()); +// } + +// @Test +// public void Multiple_Insert_One_After() +// { +// AnnotationInstance doc = newDocumentation("cId"); +// AbstractClassifierInstance parent = newLine("g"); +// parent.addAnnotation(doc]); +// AnnotationInstance valueA = newBillOfMaterials("sA"); +// AnnotationInstance valueB = newBillOfMaterials("sB"); +// AnnotationInstance[] values = new AnnotationInstance[]{ valueA, valueB }; +// parent.InsertAnnotations(1, values); +// Assert.assertEquals(parent, doc.getParent()); +// Assert.assertEquals(parent, valueA.getParent()); +// Assert.assertEquals(parent, valueB.getParent()); +// CollectionAssert.AreEqual(Lists.newArrayList( doc, valueA, valueB }, parent.getAnnotations()); +// } + +// @Test +// public void Multiple_Insert_Two_Before() +// { +// AnnotationInstance docA = newDocumentation("cIdA"); +// AnnotationInstance docB = newDocumentation("cIdB"); +// AbstractClassifierInstance parent = newLine("g"); +// parent.addAnnotation(docA, docB]); +// AnnotationInstance valueA = newBillOfMaterials("sA"); +// AnnotationInstance valueB = newBillOfMaterials("sB"); +// AnnotationInstance[] values = new AnnotationInstance[]{ valueA, valueB }; +// parent.InsertAnnotations(0, values); +// Assert.assertEquals(parent, docA.getParent()); +// Assert.assertEquals(parent, docB.getParent()); +// Assert.assertEquals(parent, valueA.getParent()); +// Assert.assertEquals(parent, valueB.getParent()); +// CollectionAssert.AreEqual(Lists.newArrayList( valueA, valueB, docA, docB }, parent.getAnnotations()); +// } + +// @Test +// public void Multiple_Insert_Two_Between() +// { +// AnnotationInstance docA = newDocumentation("cIdA"); +// AnnotationInstance docB = newDocumentation("cIdB"); +// AbstractClassifierInstance parent = newLine("g"); +// parent.addAnnotation(docA, docB]); +// AnnotationInstance valueA = newBillOfMaterials("sA"); +// AnnotationInstance valueB = newBillOfMaterials("sB"); +// AnnotationInstance[] values = new AnnotationInstance[]{ valueA, valueB }; +// parent.InsertAnnotations(1, values); +// Assert.assertEquals(parent, docA.getParent()); +// Assert.assertEquals(parent, docB.getParent()); +// Assert.assertEquals(parent, valueA.getParent()); +// Assert.assertEquals(parent, valueB.getParent()); +// CollectionAssert.AreEqual(Lists.newArrayList( docA, valueA, valueB, docB }, parent.getAnnotations()); +// } + +// @Test +// public void Multiple_Insert_Two_After() +// { +// AnnotationInstance docA = newDocumentation("cIdA"); +// AnnotationInstance docB = newDocumentation("cIdB"); +// AbstractClassifierInstance parent = newLine("g"); +// parent.addAnnotation(docA, docB]); +// AnnotationInstance valueA = newBillOfMaterials("sA"); +// AnnotationInstance valueB = newBillOfMaterials("sB"); +// AnnotationInstance[] values = new AnnotationInstance[]{ valueA, valueB }; +// parent.InsertAnnotations(2, values); +// Assert.assertEquals(parent, docA.getParent()); +// Assert.assertEquals(parent, docB.getParent()); +// Assert.assertEquals(parent, valueA.getParent()); +// Assert.assertEquals(parent, valueB.getParent()); +// CollectionAssert.AreEqual(Lists.newArrayList( docA, docB, valueA, valueB }, parent.getAnnotations()); +// } + +// #endregion + +// #region Remove + +// @Test +// public void Multiple_Remove_ListMatchingType() +// { +// AbstractClassifierInstance parent = newLine("g"); +// AnnotationInstance valueA = newBillOfMaterials("sA"); +// AnnotationInstance valueB = newBillOfMaterials("sB"); +// AbstractClassifierInstance values = new ArrayList() { valueA, valueB }; +// parent.RemoveAnnotations(values); +// Assert.assertNull(valueA.getParent()); +// Assert.assertNull(valueB.getParent()); +// Assert.assertFalse(parent.getAnnotations().contains(valueA)); +// Assert.assertFalse(parent.getAnnotations().contains(valueB)); +// } + +// @Test +// public void Multiple_Remove_Set() +// { +// AbstractClassifierInstance parent = newLine("g"); +// AnnotationInstance valueA = newBillOfMaterials("sA"); +// AnnotationInstance valueB = newBillOfMaterials("sB"); +// AbstractClassifierInstance values = new HashSet() { valueA, valueB }; +// parent.RemoveAnnotations(values); +// Assert.assertNull(valueA.getParent()); +// Assert.assertNull(valueB.getParent()); +// Assert.assertFalse(parent.getAnnotations().contains(valueA)); +// Assert.assertFalse(parent.getAnnotations().contains(valueB)); +// } + +// @Test +// public void Multiple_Remove_SingleEnumerable() +// { +// AbstractClassifierInstance parent = newLine("g"); +// AnnotationInstance valueA = newBillOfMaterials("sA"); +// AnnotationInstance valueB = newBillOfMaterials("sB"); +// AbstractClassifierInstance values = new SingleEnumerable() { valueA, valueB }; +// parent.RemoveAnnotations(values); +// Assert.assertNull(valueA.getParent()); +// Assert.assertNull(valueB.getParent()); +// Assert.assertFalse(parent.getAnnotations().contains(valueA)); +// Assert.assertFalse(parent.getAnnotations().contains(valueB)); +// } + +// @Test +// public void Multiple_Remove_Empty() +// { +// AbstractClassifierInstance parent = newLine("g"); +// AnnotationInstance valueA = newBillOfMaterials("sA"); +// AnnotationInstance valueB = newBillOfMaterials("sB"); +// AnnotationInstance[] values = new AnnotationInstance[]{ valueA, valueB }; +// parent.RemoveAnnotations(values); +// Assert.assertNull(valueA.getParent()); +// Assert.assertNull(valueB.getParent()); +// Assert.assertFalse(parent.getAnnotations().contains(valueA)); +// Assert.assertFalse(parent.getAnnotations().contains(valueB)); +// } + +// @Test +// public void Multiple_Remove_NonContained() +// { +// AnnotationInstance docA = newDocumentation("cA"); +// AnnotationInstance docB = newDocumentation("cB"); +// AbstractClassifierInstance parent = newLine("cs"); +// parent.addAnnotation(docA, docB]); +// AnnotationInstance valueA = newBillOfMaterials("sA"); +// AnnotationInstance valueB = newBillOfMaterials("sB"); +// AnnotationInstance[] values = new AnnotationInstance[]{ valueA, valueB }; +// parent.RemoveAnnotations(values); +// Assert.assertEquals(parent, docA.getParent()); +// Assert.assertEquals(parent, docB.getParent()); +// Assert.assertNull(valueA.getParent()); +// Assert.assertNull(valueB.getParent()); +// CollectionAssert.AreEqual(Lists.newArrayList( docA, docB }, parent.getAnnotations()); +// } + +// @Test +// public void Multiple_Remove_HalfContained() +// { +// AnnotationInstance docA = newDocumentation("cA"); +// AnnotationInstance docB = newDocumentation("cB"); +// AbstractClassifierInstance parent = newLine("cs"); +// parent.addAnnotation(docA, docB]); +// AnnotationInstance valueA = newBillOfMaterials("sA"); +// AnnotationInstance[] values = new AnnotationInstance[]{ valueA, docA }; +// parent.RemoveAnnotations(values); +// Assert.assertEquals(parent, docB.getParent()); +// Assert.assertNull(valueA.getParent()); +// Assert.assertNull(docA.getParent()); +// CollectionAssert.AreEqual(Lists.newArrayList( docB }, parent.getAnnotations()); +// } + +// @Test +// public void Multiple_Remove_Only() +// { +// AnnotationInstance valueA = newBillOfMaterials("sA"); +// AnnotationInstance valueB = newBillOfMaterials("sB"); +// AbstractClassifierInstance parent = newLine("g"); +// parent.addAnnotation(valueA, valueB]); +// AnnotationInstance[] values = new AnnotationInstance[]{ valueA, valueB }; +// parent.RemoveAnnotations(values); +// Assert.assertNull(valueA.getParent()); +// Assert.assertNull(valueB.getParent()); +// CollectionAssert.AreEqual(Lists.newArrayList( }, parent.getAnnotations()); +// } + +// @Test +// public void Multiple_Remove_First() +// { +// AnnotationInstance doc = newDocumentation("cId"); +// AnnotationInstance valueA = newBillOfMaterials("sA"); +// AnnotationInstance valueB = newBillOfMaterials("sB"); +// AbstractClassifierInstance parent = newLine("g"); +// parent.addAnnotation(valueA, valueB, doc]); +// AnnotationInstance[] values = new AnnotationInstance[]{ valueA, valueB }; +// parent.RemoveAnnotations(values); +// Assert.assertEquals(parent, doc.getParent()); +// Assert.assertNull(valueA.getParent()); +// Assert.assertNull(valueB.getParent()); +// CollectionAssert.AreEqual(Lists.newArrayList( doc }, parent.getAnnotations()); +// } + +// @Test +// public void Multiple_Remove_Last() +// { +// AnnotationInstance doc = newDocumentation("cId"); +// AnnotationInstance valueA = newBillOfMaterials("sA"); +// AnnotationInstance valueB = newBillOfMaterials("sB"); +// AbstractClassifierInstance parent = newLine("g"); +// parent.addAnnotation(doc, valueA, valueB]); +// AnnotationInstance[] values = new AnnotationInstance[]{ valueA, valueB }; +// parent.RemoveAnnotations(values); +// Assert.assertEquals(parent, doc.getParent()); +// Assert.assertNull(valueA.getParent()); +// Assert.assertNull(valueB.getParent()); +// CollectionAssert.AreEqual(Lists.newArrayList( doc }, parent.getAnnotations()); +// } + +// @Test +// public void Multiple_Remove_Between() +// { +// AnnotationInstance docA = newDocumentation("cIdA"); +// AnnotationInstance docB = newDocumentation("cIdB"); +// AnnotationInstance valueA = newBillOfMaterials("sA"); +// AnnotationInstance valueB = newBillOfMaterials("sB"); +// AbstractClassifierInstance parent = newLine("g"); +// parent.addAnnotation(docA, valueA, valueB, docB]); +// AnnotationInstance[] values = new AnnotationInstance[]{ valueA, valueB }; +// parent.RemoveAnnotations(values); +// Assert.assertEquals(parent, docA.getParent()); +// Assert.assertEquals(parent, docB.getParent()); +// Assert.assertNull(valueA.getParent()); +// Assert.assertNull(valueB.getParent()); +// CollectionAssert.AreEqual(Lists.newArrayList( docA, docB }, parent.getAnnotations()); +// } + +// @Test +// public void Multiple_Remove_Mixed() +// { +// AnnotationInstance docA = newDocumentation("cIdA"); +// AnnotationInstance docB = newDocumentation("cIdB"); +// AnnotationInstance valueA = newBillOfMaterials("sA"); +// AnnotationInstance valueB = newBillOfMaterials("sB"); +// AbstractClassifierInstance parent = newLine("g"); +// parent.addAnnotation(valueA, docA, valueB, docB]); +// AnnotationInstance[] values = new AnnotationInstance[]{ valueA, valueB }; +// parent.RemoveAnnotations(values); +// Assert.assertEquals(parent, docA.getParent()); +// Assert.assertEquals(parent, docB.getParent()); +// Assert.assertNull(valueA.getParent()); +// Assert.assertNull(valueB.getParent()); +// CollectionAssert.AreEqual(Lists.newArrayList( docA, docB }, parent.getAnnotations()); +// } + +// #endregion + +// @Test +// public void MultipleUntypedArray_Reflective() +// { +// AbstractClassifierInstance parent = newLine("g"); +// AnnotationInstance valueA = newBillOfMaterials("sA"); +// AnnotationInstance valueB = newBillOfMaterials("sB"); +// Object[] values = new Object[] { valueA, valueB }; +// parent.Set(null, values); +// Assert.assertEquals(parent, valueA.getParent()); +// Assert.assertTrue(parent.getAnnotations().contains(valueA)); +// Assert.assertEquals(parent, valueB.getParent()); +// Assert.assertTrue(parent.getAnnotations().contains(valueB)); +// } + +// @Test +// public void MultipleUntypedList_Reflective() +// { +// AbstractClassifierInstance parent = newLine("g"); +// AnnotationInstance valueA = newBillOfMaterials("sA"); +// AnnotationInstance valueB = newBillOfMaterials("sB"); +// AbstractClassifierInstance values = new ArrayList() { valueA, valueB }; +// parent.Set(null, values); +// Assert.assertEquals(parent, valueA.getParent()); +// Assert.assertTrue(parent.getAnnotations().contains(valueA)); +// Assert.assertEquals(parent, valueB.getParent()); +// Assert.assertTrue(parent.getAnnotations().contains(valueB)); +// } + +// @Test +// public void MultipleListMatchingType() +// { +// AbstractClassifierInstance parent = newLine("g"); +// AnnotationInstance valueA = newBillOfMaterials("sA"); +// AnnotationInstance valueB = newBillOfMaterials("sB"); +// AbstractClassifierInstance values = new ArrayList() { valueA, valueB }; +// parent.addAnnotation(values); +// Assert.assertEquals(parent, valueA.getParent()); +// Assert.assertTrue(parent.getAnnotations().contains(valueA)); +// Assert.assertEquals(parent, valueB.getParent()); +// Assert.assertTrue(parent.getAnnotations().contains(valueB)); +// } + +// @Test +// public void MultipleListMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newLine("g"); +// AnnotationInstance valueA = newBillOfMaterials("sA"); +// AnnotationInstance valueB = newBillOfMaterials("sB"); +// AbstractClassifierInstance values = new ArrayList() { valueA, valueB }; +// parent.Set(null, values); +// Assert.assertEquals(parent, valueA.getParent()); +// Assert.assertTrue(parent.getAnnotations().contains(valueA)); +// Assert.assertEquals(parent, valueB.getParent()); +// Assert.assertTrue(parent.getAnnotations().contains(valueB)); +// } + +// @Test +// public void MultipleSet() +// { +// AbstractClassifierInstance parent = newLine("g"); +// AnnotationInstance valueA = newBillOfMaterials("sA"); +// AnnotationInstance valueB = newBillOfMaterials("sB"); +// AbstractClassifierInstance values = new HashSet() { valueA, valueB }; +// parent.addAnnotation(values); +// Assert.assertEquals(parent, valueA.getParent()); +// Assert.assertTrue(parent.getAnnotations().contains(valueA)); +// Assert.assertEquals(parent, valueB.getParent()); +// Assert.assertTrue(parent.getAnnotations().contains(valueB)); +// } + +// @Test +// public void MultipleSet_Reflective() +// { +// AbstractClassifierInstance parent = newLine("g"); +// AnnotationInstance valueA = newBillOfMaterials("sA"); +// AnnotationInstance valueB = newBillOfMaterials("sB"); +// AbstractClassifierInstance values = new HashSet() { valueA, valueB }; +// parent.Set(null, values); +// Assert.assertEquals(parent, valueA.getParent()); +// Assert.assertTrue(parent.getAnnotations().contains(valueA)); +// Assert.assertEquals(parent, valueB.getParent()); +// Assert.assertTrue(parent.getAnnotations().contains(valueB)); +// } + +// @Test +// public void MultipleSingleEnumerable() +// { +// AbstractClassifierInstance parent = newLine("g"); +// AnnotationInstance valueA = newBillOfMaterials("sA"); +// AnnotationInstance valueB = newBillOfMaterials("sB"); +// AbstractClassifierInstance values = new SingleEnumerable { valueA, valueB }; +// parent.addAnnotation(values); +// Assert.assertEquals(parent, valueA.getParent()); +// Assert.assertTrue(parent.getAnnotations().contains(valueA)); +// Assert.assertEquals(parent, valueB.getParent()); +// Assert.assertTrue(parent.getAnnotations().contains(valueB)); +// } + +// @Test +// public void MultipleSingleEnumerable_Reflective() +// { +// AbstractClassifierInstance parent = newLine("g"); +// AnnotationInstance valueA = newBillOfMaterials("sA"); +// AnnotationInstance valueB = newBillOfMaterials("sB"); +// AbstractClassifierInstance values = new SingleEnumerable { valueA, valueB }; +// parent.Set(null, values); +// Assert.assertEquals(parent, valueA.getParent()); +// Assert.assertTrue(parent.getAnnotations().contains(valueA)); +// Assert.assertEquals(parent, valueB.getParent()); +// Assert.assertTrue(parent.getAnnotations().contains(valueB)); +// } + +// @Test +// public void MultipleListNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newLine("g"); +// AbstractClassifierInstance valueA = newCoord("cA"); +// AbstractClassifierInstance valueB = newCoord("cB"); +// AbstractClassifierInstance values = new ArrayList() { valueA, valueB }; +// Assert.assertThrows(InvalidValueException>( +// () -> parent.Set(null, values)); +// Assert.assertTrue(parent.getAnnotations().size() == 0); +// } + +// @Test +// public void MultipleUntypedListNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newLine("g"); +// AbstractClassifierInstance valueA = newCoord("cA"); +// AbstractClassifierInstance valueB = newCoord("cB"); +// AbstractClassifierInstance values = new ArrayList() { valueA, valueB }; +// Assert.assertThrows(InvalidValueException>( +// () -> parent.Set(null, values)); +// Assert.assertTrue(parent.getAnnotations().size() == 0); +// } + +// @Test +// public void MultipleUntypedArrayNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newLine("g"); +// AbstractClassifierInstance valueA = newCoord("cA"); +// AbstractClassifierInstance valueB = newCoord("cB"); +// Object[] values = new Object[] { valueA, valueB }; +// Assert.assertThrows(InvalidValueException>( +// () -> parent.Set(null, values)); +// Assert.assertTrue(parent.getAnnotations().size() == 0); +// } + +// @Test +// public void SingleList_NotAnnotating() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// AnnotationInstance value = newDocumentation("sA"); +// AbstractClassifierInstance values = new ArrayList() { value }; +// Assert.assertThrows(InvalidValueException>(() -> parent.addAnnotation(values)); +// Assert.assertNull(value.getParent()); +// Assert.assertFalse(parent.getAnnotations().contains(value)); +// } + +// @Test +// public void SingleList_NotAnnotating_Reflective() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// AnnotationInstance value = newDocumentation("sA"); +// AbstractClassifierInstance values = new ArrayList() { value }; +// Assert.assertThrows(InvalidValueException>(() -> parent.Set(null, values)); +// Assert.assertNull(value.getParent()); +// Assert.assertFalse(parent.getAnnotations().contains(value)); +// } + +// @Test +// public void SingleList_NotAnnotating_Insert() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// AnnotationInstance value = newDocumentation("sA"); +// AbstractClassifierInstance values = new ArrayList() { value }; +// Assert.assertThrows(InvalidValueException>(() -> parent.InsertAnnotations(0, values)); +// Assert.assertNull(value.getParent()); +// Assert.assertFalse(parent.getAnnotations().contains(value)); +// } + +// @Test +// public void SingleList_NotAnnotating_Remove() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// AnnotationInstance value = newDocumentation("sA"); +// AbstractClassifierInstance values = new ArrayList() { value }; +// parent.RemoveAnnotations(values); +// Assert.assertNull(value.getParent()); +// Assert.assertFalse(parent.getAnnotations().contains(value)); +// } + +// @Test +// public void Result_Reflective() +// { +// AbstractClassifierInstance parent = newLine("g"); +// AnnotationInstance valueA = newBillOfMaterials("sA"); +// AnnotationInstance valueB = newBillOfMaterials("sB"); +// AnnotationInstance[] values = new AnnotationInstance[]{ valueA, valueB }; +// parent.Set(null, values); +// AbstractClassifierInstance result = parent.Get(null); +// CollectionAssert.AreEqual(new List() {valueA, valueB}, (result as IList).ToList()); +// } + +// @Test +// public void ResultUnmodifiable_Set() +// { +// AbstractClassifierInstance parent = newLine("g"); +// AnnotationInstance valueA = newBillOfMaterials("sA"); +// AnnotationInstance valueB = newBillOfMaterials("sB"); +// AnnotationInstance[] values = new AnnotationInstance[]{ valueA, valueB }; +// parent.Set(null, values); +// AbstractClassifierInstance result = parent.Get(null); +// Assert.IsInstanceOfType>(result); +// } + +// @Test +// public void ResultUnmodifiable_Unset() +// { +// AbstractClassifierInstance parent = newLine("g"); +// AbstractClassifierInstance result = parent.Get(null); +// Assert.IsInstanceOfType>(result); +// } + +// #endregion +} \ No newline at end of file diff --git a/core/src/test/java/lionweb/core/m2/dynamic/test/DynamicNodeTestsBase.java b/core/src/test/java/lionweb/core/m2/dynamic/test/DynamicNodeTestsBase.java new file mode 100644 index 00000000..f4f7f2e0 --- /dev/null +++ b/core/src/test/java/lionweb/core/m2/dynamic/test/DynamicNodeTestsBase.java @@ -0,0 +1,286 @@ +// Copyright 2024 TRUMPF Laser SE and other contributors +// +// 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. +// +// SPDX-FileCopyrightText: 2024 TRUMPF Laser SE and other contributors +// SPDX-License-Identifier: Apache-2.0 + +package lionweb.core.m2.dynamic.test; + +import examples.shapes.dynamic.ShapesDynamic; +import io.lionweb.lioncore.java.language.*; +import io.lionweb.lioncore.java.model.impl.DynamicAnnotationInstance; +import io.lionweb.lioncore.java.model.impl.DynamicClassifierInstance; +import io.lionweb.lioncore.java.model.impl.DynamicNode; +import io.lionweb.lioncore.java.serialization.Instantiator; +import org.junit.Before; + +import java.util.List; + +public abstract class DynamicNodeTestsBase { + protected Language _lang; + protected Instantiator instantiator; + + @Before + public void LoadLanguage() { + _lang = ShapesDynamic.Language; + instantiator = new Instantiator().enableDynamicNodes(); + } + + protected > DynamicClassifierInstance CreateNode(String id, T classifier) { + if (classifier instanceof Concept) { + return (DynamicClassifierInstance) new DynamicNode(id, (Concept) classifier); + } + if(classifier instanceof Annotation) { + return (DynamicClassifierInstance) new DynamicAnnotationInstance(id, (Annotation) classifier); + } + throw new IllegalStateException(); + } + + protected Classifier getClassifierByKey(String key) { + return _lang.getElements() + .stream() + .filter(e -> e instanceof Classifier) + .map(e -> (Classifier) e) + .filter(e -> e.getKey().equals(key)) + .findFirst() + .orElse(null); + } + + protected Feature getFeatureByKey(Classifier classifier, String key) { + return ((List ) classifier.allFeatures()) + .stream() + .filter(f -> f.getKey().equals(key)) + .findFirst() + .orElse(null); + } + + protected DynamicNode newReferenceGeometry(String id) { + DynamicNode node = (DynamicNode) CreateNode(id, getClassifierByKey("key-ReferenceGeometry")); + if (node == null) { + throw new AssertionError(); + } + return node; + } + + protected DynamicNode newLine(String id) { + DynamicNode node = (DynamicNode) CreateNode(id, getClassifierByKey("key-Line")); + if (node == null) { + throw new AssertionError(); + } + return node; + } + + protected DynamicNode newCoord(String id) { + DynamicNode node = (DynamicNode) CreateNode(id, getClassifierByKey("key-Coord")); + if (node == null) { + throw new AssertionError(); + } + return node; + } + + protected DynamicAnnotationInstance newBillOfMaterials(String id) { + DynamicAnnotationInstance node = (DynamicAnnotationInstance) CreateNode(id, getClassifierByKey("key-BillOfMaterials")); + if (node == null) { + throw new AssertionError(); + } + return node; + } + + protected DynamicAnnotationInstance newDocumentation(String id) { + DynamicAnnotationInstance node = (DynamicAnnotationInstance) CreateNode(id, getClassifierByKey("key-Documentation")); + if (node == null) { + throw new AssertionError(); + } + return node; + } + + protected DynamicNode newGeometry(String id) { + DynamicNode node = (DynamicNode) CreateNode(id, getClassifierByKey("key-Geometry")); + if (node == null) { + throw new AssertionError(); + } + return node; + } + + protected DynamicNode newCircle(String id) { + DynamicNode node = (DynamicNode) CreateNode(id, getClassifierByKey("key-Circle")); + if (node == null) { + throw new AssertionError(); + } + return node; + } + + protected DynamicNode newCompositeShape(String id) { + DynamicNode node = (DynamicNode) CreateNode(id, getClassifierByKey("key-CompositeShape")); + if (node == null) { + throw new AssertionError(); + } + return node; + } + + protected DynamicNode newOffsetDuplicate(String id) { + DynamicNode node = (DynamicNode) CreateNode(id, getClassifierByKey("key-OffsetDuplicate")); + if (node == null) { + throw new AssertionError(); + } + return node; + } + + protected DynamicNode newMaterialGroup(String id) { + DynamicNode node = (DynamicNode) CreateNode(id, getClassifierByKey("key-MaterialGroup")); + if (node == null) { + throw new AssertionError(); + } + return node; + } + + protected Feature ReferenceGeometry_shapes() { + return getFeatureByKey(getClassifierByKey("key-ReferenceGeometry"), "key-shapes-references"); + } + + protected Feature Geometry_shapes() { + return getFeatureByKey(getClassifierByKey("key-Geometry"), "key-shapes"); + } + + protected Feature CompositeShape_parts() { + return getFeatureByKey(getClassifierByKey("key-CompositeShape"), "key-parts"); + } + + protected Feature CompositeShape_disabledParts() { + return getFeatureByKey(getClassifierByKey("key-CompositeShape"), "key-disabled-parts"); + } + + protected Feature CompositeShape_evilPart() { + return getFeatureByKey(getClassifierByKey("key-CompositeShape"), "key-evil-part"); + } + + protected Feature Geometry_documentation() { + return getFeatureByKey(getClassifierByKey("key-Geometry"), "key-documentation"); + } + + protected Feature OffsetDuplicate_offset() { + return getFeatureByKey(getClassifierByKey("key-OffsetDuplicate"), "key-offset"); + } + + protected Feature Documentation_technical() + { + return getFeatureByKey(getClassifierByKey("key-Documentation"), "key-technical"); + } + + protected Feature MaterialGroup_matterState() + { + return getFeatureByKey(getClassifierByKey("key-MaterialGroup"), "key-matter-state"); + } + + protected Feature MaterialGroup_defaultShape() + { + return getFeatureByKey(getClassifierByKey("key-MaterialGroup"), "key-default-shape"); + } + + protected Feature Circle_r() + { + return getFeatureByKey(getClassifierByKey("key-Circle"), "key-r"); + } + + protected Feature Circle_center() + { + return getFeatureByKey(getClassifierByKey("key-Circle"), "key-center"); + } + + protected Feature Line_start() + { + return getFeatureByKey(getClassifierByKey("key-Line"), "key-start"); + } + + protected Feature Line_end() + { + return getFeatureByKey(getClassifierByKey("key-Line"), "key-end"); + } + + protected Feature Documentation_text() + { + return getFeatureByKey(getClassifierByKey("key-Documentation"), "key-text"); + } + + protected Feature MaterialGroup_materials() + { + return getFeatureByKey(getClassifierByKey("key-MaterialGroup"), "key-group-materials"); + } + + protected Feature OffsetDuplicate_altSource() + { + return getFeatureByKey(getClassifierByKey("key-OffsetDuplicate"), "key-alt-source"); + } + + protected Feature OffsetDuplicate_source() + { + return getFeatureByKey(getClassifierByKey("key-OffsetDuplicate"), "key-source"); + } + + protected Feature OffsetDuplicate_docs() + { + return getFeatureByKey(getClassifierByKey("key-OffsetDuplicate"), "key-docs"); + } + + protected Feature OffsetDuplicate_secretDocs() + { + return getFeatureByKey(getClassifierByKey("key-OffsetDuplicate"), "key-secret-docs"); + } + + protected Feature BillOfMaterials_groups() + { + return getFeatureByKey(getClassifierByKey("key-BillOfMaterials"), "key-groups"); + } + + protected Feature BillOfMaterials_altGroups() + { + return getFeatureByKey(getClassifierByKey("key-BillOfMaterials"), "key-alt-groups"); + } + + protected Feature BillOfMaterials_defaultGroup() + { + return getFeatureByKey(getClassifierByKey("key-BillOfMaterials"), "key-default-group"); + } + + protected Feature Shape_shapeDocs() + { + return getFeatureByKey(getClassifierByKey("key-Shape"), "key-shape-docs"); + } + +// protected Enum MatterState_Gas() +// { +// return getGetFactory().GetEnumerationLiteral( +// MatterState +// .Literals +// .First(l => l.Key == "key-gas") +// ); +// } +// +// protected Enum MatterState_Liquid() +// { +// return getGetFactory().GetEnumerationLiteral( +// MatterState +// .Literals +// .First(l => l.Key == "key-liquid") +// ); +// } +// +// private Enumeration MatterState() { +// _lang +// .Enumerations() +// .First(e = > e.Key == "key-MatterState"); +// } + +} + diff --git a/core/src/test/java/lionweb/utils/tests/CollectionAssert.java b/core/src/test/java/lionweb/utils/tests/CollectionAssert.java new file mode 100644 index 00000000..6478d535 --- /dev/null +++ b/core/src/test/java/lionweb/utils/tests/CollectionAssert.java @@ -0,0 +1,20 @@ +package lionweb.utils.tests; + +import org.junit.Assert; + +import javax.annotation.Nonnull; +import java.util.Iterator; +import java.util.List; + +public class CollectionAssert { + public static void AreEqual(@Nonnull List expected, @Nonnull List actual) { + Assert.assertEquals("size differs", expected.size(), actual.size()); + Iterator expectedIterator = expected.iterator(); + Iterator actualIterator = actual.iterator(); + int index = 0; + while (expectedIterator.hasNext() && actualIterator.hasNext()) { + Assert.assertEquals("difference at index "+ index, expectedIterator.next(), actualIterator.next()); + index++; + } + } +} diff --git a/core/src/test/java/lionweb/utils/tests/INode.java b/core/src/test/java/lionweb/utils/tests/INode.java new file mode 100644 index 00000000..dcb27567 --- /dev/null +++ b/core/src/test/java/lionweb/utils/tests/INode.java @@ -0,0 +1,6 @@ +package lionweb.utils.tests; + +import io.lionweb.lioncore.java.model.Node; + +public interface INode extends Node { +} diff --git a/core/src/test/java/lionweb/utils/tests/IdTests.java b/core/src/test/java/lionweb/utils/tests/IdTests.java new file mode 100644 index 00000000..afcd07ba --- /dev/null +++ b/core/src/test/java/lionweb/utils/tests/IdTests.java @@ -0,0 +1,112 @@ +// Copyright 2024 TRUMPF Laser SE and other contributors +// +// 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. +// +// SPDX-FileCopyrightText: 2024 TRUMPF Laser SE and other contributors +// SPDX-License-Identifier: Apache-2.0 + +package lionweb.utils.tests; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; + +public class IdTests { +// @Test +// public void SetId_Constructor() { +// Line line = new Line("myId"); +// assertEquals("myId", line.GetId()); +// } +// +// @Test +// public void SetId_Dynamic() { +// DynamicNode line = new DynamicNode("myId", ShapesLanguage.Instance.Line); +// assertEquals("myId", line.GetId()); +// } +// +// @Test +// public void SetId_Factory() { +// Line line = ShapesLanguage.Instance.GetFactory().NewLine("myId"); +// assertEquals("myId", line.GetId()); +// } +// +// @Test +// public void SetId_Factory_Reflective() { +// INode line = ShapesLanguage.Instance.GetFactory().CreateNode("myId", ShapesLanguage.Instance.Line); +// assertEquals("myId", line.GetId()); +// } +// +// @Test +// public void SetId_Constructor_null() { +// assertThrows(InvalidIdException.class, () -> new Line(null)); +// } +// +// @Test +// public void SetId_Dynamic_null() { +// assertThrows(InvalidIdException.class, () -> new DynamicNode(null, ShapesLanguage.Instance.Line)); +// } +// +// @Test +// public void SetId_Factory_null() { +// assertThrows(InvalidIdException.class, () -> ShapesLanguage.Instance.GetFactory().NewLine(null)); +// } +// +// @Test +// public void SetId_Factory_Reflective_null() { +// assertThrows(InvalidIdException.class, () -> +// ShapesLanguage.Instance.GetFactory().CreateNode(null, ShapesLanguage.Instance.Line)); +// } +// +// @Test +// public void SetId_Constructor_invalid_dot() { +// assertThrows(InvalidIdException.class, () -> { +// Line line = new Line("my.id"); +// line.setEnd(null); +// }); +// } +// +// @Test +// public void SetId_Factory_invalid_dot() { +// assertThrows(InvalidIdException.class, () -> ShapesLanguage.Instance.GetFactory().NewLine("my.id")); +// } +// +// @Test +// public void SetId_Factory_Reflective_invalid_dot() { +// assertThrows(InvalidIdException.class, () -> +// ShapesLanguage.Instance.GetFactory().CreateNode("my.id", ShapesLanguage.Instance.Line)); +// } +// +// @Test +// public void SetId_Constructor_invalid_equal() { +// assertThrows(InvalidIdException.class, () -> new Line("myid=")); +// } +// +// @Test +// public void SetId_Factory_invalid_equal() { +// assertThrows(InvalidIdException.class, () -> ShapesLanguage.Instance.GetFactory().NewLine("myid=")); +// } +// +// @Test +// public void SetId_Factory_Reflective_invalid_equal() { +// assertThrows(InvalidIdException.class, () -> +// ShapesLanguage.Instance.GetFactory().CreateNode("myid=", ShapesLanguage.Instance.Line)); +// } +// +// @Test +// public void GetId() { +// Line line = new Line("myId"); +// assertEquals("myId", line.GetId()); +// assertEquals("myId", ((IReadableNode)line).GetId()); +// assertEquals("myId", ((IWritableNode)line).GetId()); +// } +} + diff --git a/core/src/test/resources/languages/defChunks/shapes.json b/core/src/test/resources/languages/defChunks/shapes.json new file mode 100644 index 00000000..86ceb126 --- /dev/null +++ b/core/src/test/resources/languages/defChunks/shapes.json @@ -0,0 +1,2771 @@ +{ + "serializationFormatVersion": "2023.1", + "languages": [ + { + "key": "LionCore-M3", + "version": "2023.1" + } + ], + "nodes": [ + { + "id": "id-Shapes", + "classifier": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Language" + }, + "properties": [ + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "IKeyed-key" + }, + "value": "key-Shapes" + }, + { + "property": { + "language": "LionCore-builtins", + "version": "2023.1", + "key": "LionCore-builtins-INamed-name" + }, + "value": "ShapesLanguage" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Language-version" + }, + "value": "1" + } + ], + "containments": [ + { + "containment": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Language-entities" + }, + "children": [ + "id-Circle", + "id-Coord", + "id-Geometry", + "id-IShape", + "id-Line", + "id-OffsetDuplicate", + "id-Shape", + "id-CompositeShape", + "id-ReferenceGeometry", + "id-Documentation", + "id-BillOfMaterials", + "id-MaterialGroup", + "id-MatterState", + "id-Time" + ] + } + ], + "references": [ + { + "reference": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Language-dependsOn" + }, + "targets": [] + } + ], + "annotations": [], + "parent": null + }, + { + "id": "id-Circle", + "classifier": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Concept" + }, + "properties": [ + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "IKeyed-key" + }, + "value": "key-Circle" + }, + { + "property": { + "language": "LionCore-builtins", + "version": "2023.1", + "key": "LionCore-builtins-INamed-name" + }, + "value": "Circle" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Concept-abstract" + }, + "value": "false" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Concept-partition" + }, + "value": "false" + } + ], + "containments": [ + { + "containment": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Classifier-features" + }, + "children": [ + "id-r", + "id-center" + ] + } + ], + "references": [ + { + "reference": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Concept-extends" + }, + "targets": [ + { + "resolveInfo": "Shape", + "reference": "id-Shape" + } + ] + }, + { + "reference": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Concept-implements" + }, + "targets": [] + } + ], + "annotations": [], + "parent": "id-Shapes" + }, + { + "id": "id-r", + "classifier": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Property" + }, + "properties": [ + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "IKeyed-key" + }, + "value": "key-r" + }, + { + "property": { + "language": "LionCore-builtins", + "version": "2023.1", + "key": "LionCore-builtins-INamed-name" + }, + "value": "r" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Feature-optional" + }, + "value": "false" + } + ], + "containments": [], + "references": [ + { + "reference": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Property-type" + }, + "targets": [ + { + "resolveInfo": "Integer", + "reference": "LionCore-builtins-Integer" + } + ] + } + ], + "annotations": [], + "parent": "id-Circle" + }, + { + "id": "id-center", + "classifier": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Containment" + }, + "properties": [ + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "IKeyed-key" + }, + "value": "key-center" + }, + { + "property": { + "language": "LionCore-builtins", + "version": "2023.1", + "key": "LionCore-builtins-INamed-name" + }, + "value": "center" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Feature-optional" + }, + "value": "false" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Link-multiple" + }, + "value": "false" + } + ], + "containments": [], + "references": [ + { + "reference": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Link-type" + }, + "targets": [ + { + "resolveInfo": "Coord", + "reference": "id-Coord" + } + ] + } + ], + "annotations": [], + "parent": "id-Circle" + }, + { + "id": "id-Coord", + "classifier": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Concept" + }, + "properties": [ + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "IKeyed-key" + }, + "value": "key-Coord" + }, + { + "property": { + "language": "LionCore-builtins", + "version": "2023.1", + "key": "LionCore-builtins-INamed-name" + }, + "value": "Coord" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Concept-abstract" + }, + "value": "false" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Concept-partition" + }, + "value": "false" + } + ], + "containments": [ + { + "containment": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Classifier-features" + }, + "children": [ + "id-x", + "id-y", + "id-z" + ] + } + ], + "references": [ + { + "reference": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Concept-extends" + }, + "targets": [] + }, + { + "reference": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Concept-implements" + }, + "targets": [] + } + ], + "annotations": [], + "parent": "id-Shapes" + }, + { + "id": "id-x", + "classifier": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Property" + }, + "properties": [ + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "IKeyed-key" + }, + "value": "key-x" + }, + { + "property": { + "language": "LionCore-builtins", + "version": "2023.1", + "key": "LionCore-builtins-INamed-name" + }, + "value": "x" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Feature-optional" + }, + "value": "false" + } + ], + "containments": [], + "references": [ + { + "reference": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Property-type" + }, + "targets": [ + { + "resolveInfo": "Integer", + "reference": "LionCore-builtins-Integer" + } + ] + } + ], + "annotations": [], + "parent": "id-Coord" + }, + { + "id": "id-y", + "classifier": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Property" + }, + "properties": [ + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "IKeyed-key" + }, + "value": "key-y" + }, + { + "property": { + "language": "LionCore-builtins", + "version": "2023.1", + "key": "LionCore-builtins-INamed-name" + }, + "value": "y" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Feature-optional" + }, + "value": "false" + } + ], + "containments": [], + "references": [ + { + "reference": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Property-type" + }, + "targets": [ + { + "resolveInfo": "Integer", + "reference": "LionCore-builtins-Integer" + } + ] + } + ], + "annotations": [], + "parent": "id-Coord" + }, + { + "id": "id-z", + "classifier": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Property" + }, + "properties": [ + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "IKeyed-key" + }, + "value": "key-z" + }, + { + "property": { + "language": "LionCore-builtins", + "version": "2023.1", + "key": "LionCore-builtins-INamed-name" + }, + "value": "z" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Feature-optional" + }, + "value": "false" + } + ], + "containments": [], + "references": [ + { + "reference": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Property-type" + }, + "targets": [ + { + "resolveInfo": "Integer", + "reference": "LionCore-builtins-Integer" + } + ] + } + ], + "annotations": [], + "parent": "id-Coord" + }, + { + "id": "id-Geometry", + "classifier": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Concept" + }, + "properties": [ + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "IKeyed-key" + }, + "value": "key-Geometry" + }, + { + "property": { + "language": "LionCore-builtins", + "version": "2023.1", + "key": "LionCore-builtins-INamed-name" + }, + "value": "Geometry" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Concept-abstract" + }, + "value": "false" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Concept-partition" + }, + "value": "false" + } + ], + "containments": [ + { + "containment": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Classifier-features" + }, + "children": [ + "id-shapes", + "id-documentation" + ] + } + ], + "references": [ + { + "reference": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Concept-extends" + }, + "targets": [] + }, + { + "reference": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Concept-implements" + }, + "targets": [] + } + ], + "annotations": [], + "parent": "id-Shapes" + }, + { + "id": "id-shapes", + "classifier": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Containment" + }, + "properties": [ + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "IKeyed-key" + }, + "value": "key-shapes" + }, + { + "property": { + "language": "LionCore-builtins", + "version": "2023.1", + "key": "LionCore-builtins-INamed-name" + }, + "value": "shapes" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Feature-optional" + }, + "value": "true" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Link-multiple" + }, + "value": "true" + } + ], + "containments": [], + "references": [ + { + "reference": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Link-type" + }, + "targets": [ + { + "resolveInfo": "IShape", + "reference": "id-IShape" + } + ] + } + ], + "annotations": [], + "parent": "id-Geometry" + }, + { + "id": "id-documentation", + "classifier": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Containment" + }, + "properties": [ + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "IKeyed-key" + }, + "value": "key-documentation" + }, + { + "property": { + "language": "LionCore-builtins", + "version": "2023.1", + "key": "LionCore-builtins-INamed-name" + }, + "value": "documentation" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Feature-optional" + }, + "value": "true" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Link-multiple" + }, + "value": "false" + } + ], + "containments": [], + "references": [ + { + "reference": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Link-type" + }, + "targets": [ + { + "resolveInfo": "Documentation", + "reference": "id-Documentation" + } + ] + } + ], + "annotations": [], + "parent": "id-Geometry" + }, + { + "id": "id-IShape", + "classifier": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Interface" + }, + "properties": [ + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "IKeyed-key" + }, + "value": "key-IShape" + }, + { + "property": { + "language": "LionCore-builtins", + "version": "2023.1", + "key": "LionCore-builtins-INamed-name" + }, + "value": "IShape" + } + ], + "containments": [ + { + "containment": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Classifier-features" + }, + "children": [] + } + ], + "references": [ + { + "reference": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Interface-extends" + }, + "targets": [] + } + ], + "annotations": [], + "parent": "id-Shapes" + }, + { + "id": "id-Line", + "classifier": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Concept" + }, + "properties": [ + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "IKeyed-key" + }, + "value": "key-Line" + }, + { + "property": { + "language": "LionCore-builtins", + "version": "2023.1", + "key": "LionCore-builtins-INamed-name" + }, + "value": "Line" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Concept-abstract" + }, + "value": "false" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Concept-partition" + }, + "value": "false" + } + ], + "containments": [ + { + "containment": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Classifier-features" + }, + "children": [ + "id-start", + "id-end" + ] + } + ], + "references": [ + { + "reference": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Concept-extends" + }, + "targets": [ + { + "resolveInfo": "Shape", + "reference": "id-Shape" + } + ] + }, + { + "reference": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Concept-implements" + }, + "targets": [] + } + ], + "annotations": [], + "parent": "id-Shapes" + }, + { + "id": "id-start", + "classifier": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Containment" + }, + "properties": [ + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "IKeyed-key" + }, + "value": "key-start" + }, + { + "property": { + "language": "LionCore-builtins", + "version": "2023.1", + "key": "LionCore-builtins-INamed-name" + }, + "value": "start" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Feature-optional" + }, + "value": "false" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Link-multiple" + }, + "value": "false" + } + ], + "containments": [], + "references": [ + { + "reference": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Link-type" + }, + "targets": [ + { + "resolveInfo": "Coord", + "reference": "id-Coord" + } + ] + } + ], + "annotations": [], + "parent": "id-Line" + }, + { + "id": "id-end", + "classifier": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Containment" + }, + "properties": [ + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "IKeyed-key" + }, + "value": "key-end" + }, + { + "property": { + "language": "LionCore-builtins", + "version": "2023.1", + "key": "LionCore-builtins-INamed-name" + }, + "value": "end" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Feature-optional" + }, + "value": "false" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Link-multiple" + }, + "value": "false" + } + ], + "containments": [], + "references": [ + { + "reference": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Link-type" + }, + "targets": [ + { + "resolveInfo": "Coord", + "reference": "id-Coord" + } + ] + } + ], + "annotations": [], + "parent": "id-Line" + }, + { + "id": "id-OffsetDuplicate", + "classifier": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Concept" + }, + "properties": [ + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "IKeyed-key" + }, + "value": "key-OffsetDuplicate" + }, + { + "property": { + "language": "LionCore-builtins", + "version": "2023.1", + "key": "LionCore-builtins-INamed-name" + }, + "value": "OffsetDuplicate" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Concept-abstract" + }, + "value": "false" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Concept-partition" + }, + "value": "false" + } + ], + "containments": [ + { + "containment": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Classifier-features" + }, + "children": [ + "id-offset", + "id-source", + "id-alt-source", + "id-docs", + "id-secret-docs" + ] + } + ], + "references": [ + { + "reference": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Concept-extends" + }, + "targets": [ + { + "resolveInfo": "Shape", + "reference": "id-Shape" + } + ] + }, + { + "reference": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Concept-implements" + }, + "targets": [] + } + ], + "annotations": [], + "parent": "id-Shapes" + }, + { + "id": "id-offset", + "classifier": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Containment" + }, + "properties": [ + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "IKeyed-key" + }, + "value": "key-offset" + }, + { + "property": { + "language": "LionCore-builtins", + "version": "2023.1", + "key": "LionCore-builtins-INamed-name" + }, + "value": "offset" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Feature-optional" + }, + "value": "false" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Link-multiple" + }, + "value": "false" + } + ], + "containments": [], + "references": [ + { + "reference": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Link-type" + }, + "targets": [ + { + "resolveInfo": "Coord", + "reference": "id-Coord" + } + ] + } + ], + "annotations": [], + "parent": "id-OffsetDuplicate" + }, + { + "id": "id-source", + "classifier": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Reference" + }, + "properties": [ + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "IKeyed-key" + }, + "value": "key-source" + }, + { + "property": { + "language": "LionCore-builtins", + "version": "2023.1", + "key": "LionCore-builtins-INamed-name" + }, + "value": "source" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Feature-optional" + }, + "value": "false" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Link-multiple" + }, + "value": "false" + } + ], + "containments": [], + "references": [ + { + "reference": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Link-type" + }, + "targets": [ + { + "resolveInfo": "Shape", + "reference": "id-Shape" + } + ] + } + ], + "annotations": [], + "parent": "id-OffsetDuplicate" + }, + { + "id": "id-alt-source", + "classifier": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Reference" + }, + "properties": [ + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "IKeyed-key" + }, + "value": "key-alt-source" + }, + { + "property": { + "language": "LionCore-builtins", + "version": "2023.1", + "key": "LionCore-builtins-INamed-name" + }, + "value": "altSource" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Feature-optional" + }, + "value": "true" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Link-multiple" + }, + "value": "false" + } + ], + "containments": [], + "references": [ + { + "reference": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Link-type" + }, + "targets": [ + { + "resolveInfo": "Shape", + "reference": "id-Shape" + } + ] + } + ], + "annotations": [], + "parent": "id-OffsetDuplicate" + }, + { + "id": "id-docs", + "classifier": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Containment" + }, + "properties": [ + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "IKeyed-key" + }, + "value": "key-docs" + }, + { + "property": { + "language": "LionCore-builtins", + "version": "2023.1", + "key": "LionCore-builtins-INamed-name" + }, + "value": "docs" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Feature-optional" + }, + "value": "true" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Link-multiple" + }, + "value": "false" + } + ], + "containments": [], + "references": [ + { + "reference": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Link-type" + }, + "targets": [ + { + "resolveInfo": "Documentation", + "reference": "id-Documentation" + } + ] + } + ], + "annotations": [], + "parent": "id-OffsetDuplicate" + }, + { + "id": "id-secret-docs", + "classifier": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Containment" + }, + "properties": [ + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "IKeyed-key" + }, + "value": "key-secret-docs" + }, + { + "property": { + "language": "LionCore-builtins", + "version": "2023.1", + "key": "LionCore-builtins-INamed-name" + }, + "value": "secretDocs" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Feature-optional" + }, + "value": "true" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Link-multiple" + }, + "value": "false" + } + ], + "containments": [], + "references": [ + { + "reference": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Link-type" + }, + "targets": [ + { + "resolveInfo": "Documentation", + "reference": "id-Documentation" + } + ] + } + ], + "annotations": [], + "parent": "id-OffsetDuplicate" + }, + { + "id": "id-Shape", + "classifier": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Concept" + }, + "properties": [ + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "IKeyed-key" + }, + "value": "key-Shape" + }, + { + "property": { + "language": "LionCore-builtins", + "version": "2023.1", + "key": "LionCore-builtins-INamed-name" + }, + "value": "Shape" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Concept-abstract" + }, + "value": "true" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Concept-partition" + }, + "value": "false" + } + ], + "containments": [ + { + "containment": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Classifier-features" + }, + "children": [ + "id-shape-docs" + ] + } + ], + "references": [ + { + "reference": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Concept-extends" + }, + "targets": [] + }, + { + "reference": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Concept-implements" + }, + "targets": [ + { + "resolveInfo": "INamed", + "reference": "LionCore-builtins-INamed" + }, + { + "resolveInfo": "IShape", + "reference": "id-IShape" + } + ] + } + ], + "annotations": [], + "parent": "id-Shapes" + }, + { + "id": "id-shape-docs", + "classifier": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Containment" + }, + "properties": [ + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "IKeyed-key" + }, + "value": "key-shape-docs" + }, + { + "property": { + "language": "LionCore-builtins", + "version": "2023.1", + "key": "LionCore-builtins-INamed-name" + }, + "value": "shapeDocs" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Feature-optional" + }, + "value": "true" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Link-multiple" + }, + "value": "false" + } + ], + "containments": [], + "references": [ + { + "reference": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Link-type" + }, + "targets": [ + { + "resolveInfo": "Documentation", + "reference": "id-Documentation" + } + ] + } + ], + "annotations": [], + "parent": "id-Shape" + }, + { + "id": "id-CompositeShape", + "classifier": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Concept" + }, + "properties": [ + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "IKeyed-key" + }, + "value": "key-CompositeShape" + }, + { + "property": { + "language": "LionCore-builtins", + "version": "2023.1", + "key": "LionCore-builtins-INamed-name" + }, + "value": "CompositeShape" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Concept-abstract" + }, + "value": "false" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Concept-partition" + }, + "value": "false" + } + ], + "containments": [ + { + "containment": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Classifier-features" + }, + "children": [ + "id-parts", + "id-disabled-parts", + "id-evil-part" + ] + } + ], + "references": [ + { + "reference": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Concept-extends" + }, + "targets": [ + { + "resolveInfo": "Shape", + "reference": "id-Shape" + } + ] + }, + { + "reference": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Concept-implements" + }, + "targets": [] + } + ], + "annotations": [], + "parent": "id-Shapes" + }, + { + "id": "id-parts", + "classifier": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Containment" + }, + "properties": [ + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "IKeyed-key" + }, + "value": "key-parts" + }, + { + "property": { + "language": "LionCore-builtins", + "version": "2023.1", + "key": "LionCore-builtins-INamed-name" + }, + "value": "parts" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Feature-optional" + }, + "value": "false" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Link-multiple" + }, + "value": "true" + } + ], + "containments": [], + "references": [ + { + "reference": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Link-type" + }, + "targets": [ + { + "resolveInfo": "IShape", + "reference": "id-IShape" + } + ] + } + ], + "annotations": [], + "parent": "id-CompositeShape" + }, + { + "id": "id-disabled-parts", + "classifier": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Containment" + }, + "properties": [ + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "IKeyed-key" + }, + "value": "key-disabled-parts" + }, + { + "property": { + "language": "LionCore-builtins", + "version": "2023.1", + "key": "LionCore-builtins-INamed-name" + }, + "value": "disabledParts" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Feature-optional" + }, + "value": "false" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Link-multiple" + }, + "value": "true" + } + ], + "containments": [], + "references": [ + { + "reference": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Link-type" + }, + "targets": [ + { + "resolveInfo": "IShape", + "reference": "id-IShape" + } + ] + } + ], + "annotations": [], + "parent": "id-CompositeShape" + }, + { + "id": "id-evil-part", + "classifier": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Containment" + }, + "properties": [ + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "IKeyed-key" + }, + "value": "key-evil-part" + }, + { + "property": { + "language": "LionCore-builtins", + "version": "2023.1", + "key": "LionCore-builtins-INamed-name" + }, + "value": "evilPart" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Feature-optional" + }, + "value": "false" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Link-multiple" + }, + "value": "false" + } + ], + "containments": [], + "references": [ + { + "reference": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Link-type" + }, + "targets": [ + { + "resolveInfo": "IShape", + "reference": "id-IShape" + } + ] + } + ], + "annotations": [], + "parent": "id-CompositeShape" + }, + { + "id": "id-ReferenceGeometry", + "classifier": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Concept" + }, + "properties": [ + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "IKeyed-key" + }, + "value": "key-ReferenceGeometry" + }, + { + "property": { + "language": "LionCore-builtins", + "version": "2023.1", + "key": "LionCore-builtins-INamed-name" + }, + "value": "ReferenceGeometry" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Concept-abstract" + }, + "value": "false" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Concept-partition" + }, + "value": "false" + } + ], + "containments": [ + { + "containment": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Classifier-features" + }, + "children": [ + "id-shape-references" + ] + } + ], + "references": [ + { + "reference": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Concept-extends" + }, + "targets": [] + }, + { + "reference": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Concept-implements" + }, + "targets": [] + } + ], + "annotations": [], + "parent": "id-Shapes" + }, + { + "id": "id-shape-references", + "classifier": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Reference" + }, + "properties": [ + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "IKeyed-key" + }, + "value": "key-shapes-references" + }, + { + "property": { + "language": "LionCore-builtins", + "version": "2023.1", + "key": "LionCore-builtins-INamed-name" + }, + "value": "shapes" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Feature-optional" + }, + "value": "true" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Link-multiple" + }, + "value": "true" + } + ], + "containments": [], + "references": [ + { + "reference": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Link-type" + }, + "targets": [ + { + "resolveInfo": "IShape", + "reference": "id-IShape" + } + ] + } + ], + "annotations": [], + "parent": "id-ReferenceGeometry" + }, + { + "id": "id-Documentation", + "classifier": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Annotation" + }, + "properties": [ + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "IKeyed-key" + }, + "value": "key-Documentation" + }, + { + "property": { + "language": "LionCore-builtins", + "version": "2023.1", + "key": "LionCore-builtins-INamed-name" + }, + "value": "Documentation" + } + ], + "containments": [ + { + "containment": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Classifier-features" + }, + "children": [ + "id-text", + "id-technical" + ] + } + ], + "references": [ + { + "reference": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Annotation-extends" + }, + "targets": [] + }, + { + "reference": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Annotation-implements" + }, + "targets": [] + }, + { + "reference": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Annotation-annotates" + }, + "targets": [ + { + "resolveInfo": "Shape", + "reference": "id-Shape" + } + ] + } + ], + "annotations": [], + "parent": "id-Shapes" + }, + { + "id": "id-text", + "classifier": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Property" + }, + "properties": [ + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "IKeyed-key" + }, + "value": "key-text" + }, + { + "property": { + "language": "LionCore-builtins", + "version": "2023.1", + "key": "LionCore-builtins-INamed-name" + }, + "value": "text" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Feature-optional" + }, + "value": "true" + } + ], + "containments": [], + "references": [ + { + "reference": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Property-type" + }, + "targets": [ + { + "resolveInfo": "String", + "reference": "LionCore-builtins-String" + } + ] + } + ], + "annotations": [], + "parent": "id-Documentation" + }, + { + "id": "id-technical", + "classifier": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Property" + }, + "properties": [ + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "IKeyed-key" + }, + "value": "key-technical" + }, + { + "property": { + "language": "LionCore-builtins", + "version": "2023.1", + "key": "LionCore-builtins-INamed-name" + }, + "value": "technical" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Feature-optional" + }, + "value": "true" + } + ], + "containments": [], + "references": [ + { + "reference": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Property-type" + }, + "targets": [ + { + "resolveInfo": "Boolean", + "reference": "LionCore-builtins-Boolean" + } + ] + } + ], + "annotations": [], + "parent": "id-Documentation" + }, + { + "id": "id-BillOfMaterials", + "classifier": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Annotation" + }, + "properties": [ + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "IKeyed-key" + }, + "value": "key-BillOfMaterials" + }, + { + "property": { + "language": "LionCore-builtins", + "version": "2023.1", + "key": "LionCore-builtins-INamed-name" + }, + "value": "BillOfMaterials" + } + ], + "containments": [ + { + "containment": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Classifier-features" + }, + "children": [ + "id-materials", + "id-groups", + "id-alt-groups", + "id-default-group" + ] + } + ], + "references": [ + { + "reference": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Annotation-extends" + }, + "targets": [] + }, + { + "reference": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Annotation-implements" + }, + "targets": [] + }, + { + "reference": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Annotation-annotates" + }, + "targets": [ + { + "resolveInfo": "Node", + "reference": "LionCore-builtins-Node" + } + ] + } + ], + "annotations": [], + "parent": "id-Shapes" + }, + { + "id": "id-materials", + "classifier": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Reference" + }, + "properties": [ + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "IKeyed-key" + }, + "value": "key-materials" + }, + { + "property": { + "language": "LionCore-builtins", + "version": "2023.1", + "key": "LionCore-builtins-INamed-name" + }, + "value": "materials" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Feature-optional" + }, + "value": "true" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Link-multiple" + }, + "value": "true" + } + ], + "containments": [], + "references": [ + { + "reference": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Link-type" + }, + "targets": [ + { + "resolveInfo": "IShape", + "reference": "id-IShape" + } + ] + } + ], + "annotations": [], + "parent": "id-BillOfMaterials" + }, + { + "id": "id-groups", + "classifier": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Containment" + }, + "properties": [ + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "IKeyed-key" + }, + "value": "key-groups" + }, + { + "property": { + "language": "LionCore-builtins", + "version": "2023.1", + "key": "LionCore-builtins-INamed-name" + }, + "value": "groups" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Feature-optional" + }, + "value": "true" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Link-multiple" + }, + "value": "true" + } + ], + "containments": [], + "references": [ + { + "reference": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Link-type" + }, + "targets": [ + { + "resolveInfo": "MaterialGroup", + "reference": "id-MaterialGroup" + } + ] + } + ], + "annotations": [], + "parent": "id-BillOfMaterials" + }, + { + "id": "id-alt-groups", + "classifier": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Containment" + }, + "properties": [ + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "IKeyed-key" + }, + "value": "key-alt-groups" + }, + { + "property": { + "language": "LionCore-builtins", + "version": "2023.1", + "key": "LionCore-builtins-INamed-name" + }, + "value": "altGroups" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Feature-optional" + }, + "value": "true" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Link-multiple" + }, + "value": "true" + } + ], + "containments": [], + "references": [ + { + "reference": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Link-type" + }, + "targets": [ + { + "resolveInfo": "MaterialGroup", + "reference": "id-MaterialGroup" + } + ] + } + ], + "annotations": [], + "parent": "id-BillOfMaterials" + }, + { + "id": "id-default-group", + "classifier": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Containment" + }, + "properties": [ + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "IKeyed-key" + }, + "value": "key-default-group" + }, + { + "property": { + "language": "LionCore-builtins", + "version": "2023.1", + "key": "LionCore-builtins-INamed-name" + }, + "value": "defaultGroup" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Feature-optional" + }, + "value": "true" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Link-multiple" + }, + "value": "false" + } + ], + "containments": [], + "references": [ + { + "reference": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Link-type" + }, + "targets": [ + { + "resolveInfo": "MaterialGroup", + "reference": "id-MaterialGroup" + } + ] + } + ], + "annotations": [], + "parent": "id-BillOfMaterials" + }, + { + "id": "id-MaterialGroup", + "classifier": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Concept" + }, + "properties": [ + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "IKeyed-key" + }, + "value": "key-MaterialGroup" + }, + { + "property": { + "language": "LionCore-builtins", + "version": "2023.1", + "key": "LionCore-builtins-INamed-name" + }, + "value": "MaterialGroup" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Concept-abstract" + }, + "value": "false" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Concept-partition" + }, + "value": "false" + } + ], + "containments": [ + { + "containment": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Classifier-features" + }, + "children": [ + "id-matter-state", + "id-group-materials", + "id-default-shape" + ] + } + ], + "references": [ + { + "reference": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Concept-extends" + }, + "targets": [] + }, + { + "reference": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Concept-implements" + }, + "targets": [] + } + ], + "annotations": [], + "parent": "id-Shapes" + }, + { + "id": "id-matter-state", + "classifier": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Property" + }, + "properties": [ + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "IKeyed-key" + }, + "value": "key-matter-state" + }, + { + "property": { + "language": "LionCore-builtins", + "version": "2023.1", + "key": "LionCore-builtins-INamed-name" + }, + "value": "matterState" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Feature-optional" + }, + "value": "true" + } + ], + "containments": [], + "references": [ + { + "reference": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Property-type" + }, + "targets": [ + { + "resolveInfo": "MatterState", + "reference": "id-MatterState" + } + ] + } + ], + "annotations": [], + "parent": "id-MaterialGroup" + }, + { + "id": "id-group-materials", + "classifier": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Reference" + }, + "properties": [ + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "IKeyed-key" + }, + "value": "key-group-materials" + }, + { + "property": { + "language": "LionCore-builtins", + "version": "2023.1", + "key": "LionCore-builtins-INamed-name" + }, + "value": "materials" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Feature-optional" + }, + "value": "false" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Link-multiple" + }, + "value": "true" + } + ], + "containments": [], + "references": [ + { + "reference": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Link-type" + }, + "targets": [ + { + "resolveInfo": "IShape", + "reference": "id-IShape" + } + ] + } + ], + "annotations": [], + "parent": "id-MaterialGroup" + }, + { + "id": "id-default-shape", + "classifier": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Containment" + }, + "properties": [ + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "IKeyed-key" + }, + "value": "key-default-shape" + }, + { + "property": { + "language": "LionCore-builtins", + "version": "2023.1", + "key": "LionCore-builtins-INamed-name" + }, + "value": "defaultShape" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Feature-optional" + }, + "value": "true" + }, + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Link-multiple" + }, + "value": "false" + } + ], + "containments": [], + "references": [ + { + "reference": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Link-type" + }, + "targets": [ + { + "resolveInfo": "IShape", + "reference": "id-IShape" + } + ] + } + ], + "annotations": [], + "parent": "id-MaterialGroup" + }, + { + "id": "id-MatterState", + "classifier": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Enumeration" + }, + "properties": [ + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "IKeyed-key" + }, + "value": "key-MatterState" + }, + { + "property": { + "language": "LionCore-builtins", + "version": "2023.1", + "key": "LionCore-builtins-INamed-name" + }, + "value": "MatterState" + } + ], + "containments": [ + { + "containment": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "Enumeration-literals" + }, + "children": [ + "id-solid", + "id-liquid", + "id-gas" + ] + } + ], + "references": [], + "annotations": [], + "parent": "id-Shapes" + }, + { + "id": "id-solid", + "classifier": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "EnumerationLiteral" + }, + "properties": [ + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "IKeyed-key" + }, + "value": "key-solid" + }, + { + "property": { + "language": "LionCore-builtins", + "version": "2023.1", + "key": "LionCore-builtins-INamed-name" + }, + "value": "solid" + } + ], + "containments": [], + "references": [], + "annotations": [], + "parent": "id-MatterState" + }, + { + "id": "id-liquid", + "classifier": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "EnumerationLiteral" + }, + "properties": [ + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "IKeyed-key" + }, + "value": "key-liquid" + }, + { + "property": { + "language": "LionCore-builtins", + "version": "2023.1", + "key": "LionCore-builtins-INamed-name" + }, + "value": "liquid" + } + ], + "containments": [], + "references": [], + "annotations": [], + "parent": "id-MatterState" + }, + { + "id": "id-gas", + "classifier": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "EnumerationLiteral" + }, + "properties": [ + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "IKeyed-key" + }, + "value": "key-gas" + }, + { + "property": { + "language": "LionCore-builtins", + "version": "2023.1", + "key": "LionCore-builtins-INamed-name" + }, + "value": "gas" + } + ], + "containments": [], + "references": [], + "annotations": [], + "parent": "id-MatterState" + }, + { + "id": "id-Time", + "classifier": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "PrimitiveType" + }, + "properties": [ + { + "property": { + "language": "LionCore-M3", + "version": "2023.1", + "key": "IKeyed-key" + }, + "value": "key-Time" + }, + { + "property": { + "language": "LionCore-builtins", + "version": "2023.1", + "key": "LionCore-builtins-INamed-name" + }, + "value": "Time" + } + ], + "containments": [], + "references": [], + "annotations": [], + "parent": "id-Shapes" + } + ] +} \ No newline at end of file From 1698f286d1f9b807698c38aebf097ef123fbbd71 Mon Sep 17 00:00:00 2001 From: Niko Stotz Date: Sat, 29 Jun 2024 12:54:15 +0200 Subject: [PATCH 2/4] added dynamic ContainmentTests_Multiple_Optional (translated from C#) --- .../ContainmentTests_Multiple_Optional.java | 465 ++++++++++++++++++ .../m2/dynamic/test/DynamicNodeTestsBase.java | 4 +- 2 files changed, 467 insertions(+), 2 deletions(-) create mode 100644 core/src/test/java/lionweb/core/m2/dynamic/test/ContainmentTests_Multiple_Optional.java diff --git a/core/src/test/java/lionweb/core/m2/dynamic/test/ContainmentTests_Multiple_Optional.java b/core/src/test/java/lionweb/core/m2/dynamic/test/ContainmentTests_Multiple_Optional.java new file mode 100644 index 00000000..1e812a07 --- /dev/null +++ b/core/src/test/java/lionweb/core/m2/dynamic/test/ContainmentTests_Multiple_Optional.java @@ -0,0 +1,465 @@ +// Copyright 2024 TRUMPF Laser SE and other contributors +// +// 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. +// +// SPDX-FileCopyrightText: 2024 TRUMPF Laser SE and other contributors +// SPDX-License-Identifier: Apache-2.0 + +package lionweb.core.m2.dynamic.test; + +import io.lionweb.lioncore.java.model.Node; +import io.lionweb.lioncore.java.model.impl.AbstractClassifierInstance; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; + +public class ContainmentTests_Multiple_Optional extends DynamicNodeTestsBase +{ +// #region Single + + @Test + public void Single_Reflective() + { + AbstractClassifierInstance parent = newGeometry("g"); + Node line = newLine("myId"); +// Assert.assertThrows(IllegalArgumentException.class, () -> parent.addChild(Geometry_shapes(), line)); +// Assert.assertSame(null, line.getParent()); +// Assert.assertFalse((parent.getChildren(Geometry_shapes())).contains(line)); + parent.addChild(Geometry_shapes(), line); + Assert.assertSame(parent, line.getParent()); + Assert.assertTrue((parent.getChildren(Geometry_shapes())).contains(line)); + } + +// #endregion + +// #region Null + + @Test + public void Null_Reflective() + { + AbstractClassifierInstance parent = newGeometry("g"); + Assert.assertThrows(IllegalArgumentException.class, () -> parent.addChild(Geometry_shapes(), null)); + } + +// #endregion + +// #region EmptyCollection + +// @Test +// public void EmptyArray_Reflective() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// Node[] values = new Node[0]; +// parent.addChild(Geometry_shapes(), values); +// Assert.assertTrue((parent.getChildren(Geometry_shapes())).size() == 0); +// } + +// @Test +// public void EmptyUntypedList_Reflective() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// ArrayList values = new ArrayList(); +// parent.addChild(Geometry_shapes(), values); +// Assert.assertTrue((parent.getChildren(Geometry_shapes())).size() == 0); +// } + +// @Test +// public void EmptyListMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// AbstractClassifierInstance values = new List(); +// parent.addChild(Geometry_shapes(), values); +// Assert.assertTrue((parent.getChildren(Geometry_shapes())).size() == 0); +// } + +// @Test +// public void EmptyListSubtype_Reflective() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// AbstractClassifierInstance values = new List(); +// parent.addChild(Geometry_shapes(), values); +// Assert.assertTrue((parent.getChildren(Geometry_shapes())).size() == 0); +// } + +// @Test +// public void EmptySet_Reflective() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// AbstractClassifierInstance values = new HashSet(); +// parent.addChild(Geometry_shapes(), values); +// Assert.assertTrue((parent.getChildren(Geometry_shapes())).size() == 0); +// } + +// @Test +// public void EmptyListNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// AbstractClassifierInstance values = new List(); +// parent.addChild(Geometry_shapes(), values); +// Assert.assertTrue((parent.getChildren(Geometry_shapes())).size() == 0); +// } + +// @Test +// public void EmptyList_Reset_Reflective() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// parent.addChild(Geometry_shapes(), new List { newCircle("myId") }); +// AbstractClassifierInstance values = new List(); +// parent.addChild(Geometry_shapes(), values); +// Assert.assertTrue((parent.getChildren(Geometry_shapes())).size() == 0); +// } + +// #endregion + +// #region NullCollection + +// @Test +// public void NullArray_Reflective() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// AbstractClassifierInstance values = new DynamicNode[] { null }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addChild(Geometry_shapes(), values)); +// Assert.assertTrue((parent.getChildren(Geometry_shapes())).size() == 0); +// } + +// @Test +// public void NullUntypedList_Reflective() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// AbstractClassifierInstance values = new ArrayList() { null }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addChild(Geometry_shapes(), values)); +// Assert.assertTrue((parent.getChildren(Geometry_shapes())).size() == 0); +// } + +// @Test +// public void NullListMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// AbstractClassifierInstance values = new List() { null }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addChild(Geometry_shapes(), values)); +// Assert.assertTrue((parent.getChildren(Geometry_shapes())).size() == 0); +// } + +// @Test +// public void NullListSubtype_Reflective() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// AbstractClassifierInstance values = new List() { null }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addChild(Geometry_shapes(), values)); +// Assert.assertTrue((parent.getChildren(Geometry_shapes())).size() == 0); +// } + +// @Test +// public void NullListNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// AbstractClassifierInstance values = new List() { null }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addChild(Geometry_shapes(), values)); +// Assert.assertTrue((parent.getChildren(Geometry_shapes())).size() == 0); +// } + +// @Test +// public void NullSet_Reflective() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// AbstractClassifierInstance values = new HashSet() { null }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addChild(Geometry_shapes(), values)); +// Assert.assertTrue((parent.getChildren(Geometry_shapes())).size() == 0); +// } + +// #endregion + +// #region SingleCollection + +// @Test +// public void SingleArray_Reflective() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// AbstractClassifierInstance value = newLine("s"); +// AbstractClassifierInstance values = new DynamicNode[] { value }; +// parent.addChild(Geometry_shapes(), values); +// Assert.assertSame(parent, value.getParent()); +// Assert.assertTrue((parent.getChildren(Geometry_shapes())).contains(value)); +// } + +// @Test +// public void SingleArray_Existing_Reflective() +// { +// AbstractClassifierInstance circle = newCircle("cc"); +// AbstractClassifierInstance parent = newGeometry("g"); +// parent.addChild(Geometry_shapes(), new DynamicNode[] { circle }); +// AbstractClassifierInstance value = newLine("s"); +// AbstractClassifierInstance values = new DynamicNode[] { value }; +// parent.addChild(Geometry_shapes(), values); +// Assert.assertNull(circle.getParent()); +// Assert.assertSame(parent, value.getParent()); +// CollectionAssert.AreEqual(new List { value }, +// (parent.getChildren(Geometry_shapes())).ToList()); +// } + +// @Test +// public void SingleUntypedArray_Reflective() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// AbstractClassifierInstance value = newLine("s"); +// AbstractClassifierInstance values = new object[] { value }; +// parent.addChild(Geometry_shapes(), values); +// Assert.assertSame(parent, value.getParent()); +// Assert.assertTrue((parent.getChildren(Geometry_shapes())).contains(value)); +// } + +// @Test +// public void SingleUntypedList_Reflective() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// AbstractClassifierInstance value = newLine("s"); +// AbstractClassifierInstance values = new ArrayList() { value }; +// parent.addChild(Geometry_shapes(), values); +// Assert.assertSame(parent, value.getParent()); +// Assert.assertTrue((parent.getChildren(Geometry_shapes())).contains(value)); +// } + +// @Test +// public void SingleListMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// AbstractClassifierInstance value = newLine("s"); +// AbstractClassifierInstance values = new List() { value }; +// parent.addChild(Geometry_shapes(), values); +// Assert.assertSame(parent, value.getParent()); +// Assert.assertTrue((parent.getChildren(Geometry_shapes())).contains(value)); +// } + +// @Test +// public void SingleListSubtype_Reflective() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// AbstractClassifierInstance value = newLine("s"); +// AbstractClassifierInstance values = new List() { value }; +// parent.addChild(Geometry_shapes(), values); +// Assert.assertSame(parent, value.getParent()); +// Assert.assertTrue((parent.getChildren(Geometry_shapes())).contains(value)); +// } + +// @Test +// public void SingleSet_Reflective() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// AbstractClassifierInstance value = newLine("s"); +// AbstractClassifierInstance values = new HashSet() { value }; +// parent.addChild(Geometry_shapes(), values); +// Assert.assertSame(parent, value.getParent()); +// Assert.assertTrue((parent.getChildren(Geometry_shapes())).contains(value)); +// } + +// @Test +// public void SingleListNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// AbstractClassifierInstance value = newCoord("c"); +// AbstractClassifierInstance values = new List() { value }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addChild(Geometry_shapes(), values)); +// Assert.assertTrue((parent.getChildren(Geometry_shapes())).size() == 0); +// } + +// @Test +// public void SingleUntypedListNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// AbstractClassifierInstance value = newCoord("c"); +// AbstractClassifierInstance values = new ArrayList() { value }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addChild(Geometry_shapes(), values)); +// Assert.assertTrue((parent.getChildren(Geometry_shapes())).size() == 0); +// } + +// @Test +// public void SingleUntypedArrayNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// AbstractClassifierInstance value = newCoord("c"); +// AbstractClassifierInstance values = new object[] { value }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addChild(Geometry_shapes(), values)); +// Assert.assertTrue((parent.getChildren(Geometry_shapes())).size() == 0); +// } + +// #endregion + +// #region MultipleCollection + +// @Test +// public void MultipleArray_Reflective() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// AbstractClassifierInstance valueA = newLine("sA"); +// AbstractClassifierInstance valueB = newLine("sB"); +// AbstractClassifierInstance values = new DynamicNode[] { valueA, valueB }; +// parent.addChild(Geometry_shapes(), values); +// Assert.assertSame(parent, valueA.getParent()); +// Assert.assertTrue((parent.getChildren(Geometry_shapes())).contains(valueA)); +// Assert.assertSame(parent, valueB.getParent()); +// Assert.assertTrue((parent.getChildren(Geometry_shapes())).contains(valueB)); +// } + +// @Test +// public void MultipleUntypedArray_Reflective() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// AbstractClassifierInstance valueA = newLine("sA"); +// AbstractClassifierInstance valueB = newLine("sB"); +// AbstractClassifierInstance values = new object[] { valueA, valueB }; +// parent.addChild(Geometry_shapes(), values); +// Assert.assertSame(parent, valueA.getParent()); +// Assert.assertTrue((parent.getChildren(Geometry_shapes())).contains(valueA)); +// Assert.assertSame(parent, valueB.getParent()); +// Assert.assertTrue((parent.getChildren(Geometry_shapes())).contains(valueB)); +// } + +// @Test +// public void MultipleUntypedList_Reflective() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// AbstractClassifierInstance valueA = newLine("sA"); +// AbstractClassifierInstance valueB = newLine("sB"); +// AbstractClassifierInstance values = new ArrayList() { valueA, valueB }; +// parent.addChild(Geometry_shapes(), values); +// Assert.assertSame(parent, valueA.getParent()); +// Assert.assertTrue((parent.getChildren(Geometry_shapes())).contains(valueA)); +// Assert.assertSame(parent, valueB.getParent()); +// Assert.assertTrue((parent.getChildren(Geometry_shapes())).contains(valueB)); +// } + +// @Test +// public void MultipleListMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// AbstractClassifierInstance valueA = newLine("sA"); +// AbstractClassifierInstance valueB = newLine("sB"); +// AbstractClassifierInstance values = new List() { valueA, valueB }; +// parent.addChild(Geometry_shapes(), values); +// Assert.assertSame(parent, valueA.getParent()); +// Assert.assertTrue((parent.getChildren(Geometry_shapes())).contains(valueA)); +// Assert.assertSame(parent, valueB.getParent()); +// Assert.assertTrue((parent.getChildren(Geometry_shapes())).contains(valueB)); +// } + +// @Test +// public void MultipleListSubtype_Reflective() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// AbstractClassifierInstance valueA = newLine("sA"); +// AbstractClassifierInstance valueB = newLine("sB"); +// AbstractClassifierInstance values = new List() { valueA, valueB }; +// parent.addChild(Geometry_shapes(), values); +// Assert.assertSame(parent, valueA.getParent()); +// Assert.assertTrue((parent.getChildren(Geometry_shapes())).contains(valueA)); +// Assert.assertSame(parent, valueB.getParent()); +// Assert.assertTrue((parent.getChildren(Geometry_shapes())).contains(valueB)); +// } + +// @Test +// public void MultipleSet_Reflective() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// AbstractClassifierInstance valueA = newLine("sA"); +// AbstractClassifierInstance valueB = newLine("sB"); +// AbstractClassifierInstance values = new HashSet() { valueA, valueB }; +// parent.addChild(Geometry_shapes(), values); +// Assert.assertSame(parent, valueA.getParent()); +// Assert.assertTrue((parent.getChildren(Geometry_shapes())).contains(valueA)); +// Assert.assertSame(parent, valueB.getParent()); +// Assert.assertTrue((parent.getChildren(Geometry_shapes())).contains(valueB)); +// } + +// @Test +// public void MultipleSingleEnumerable_Reflective() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// AbstractClassifierInstance valueA = newLine("sA"); +// AbstractClassifierInstance valueB = newLine("sB"); +// AbstractClassifierInstance values = new SingleEnumerable { valueA, valueB }; +// parent.addChild(Geometry_shapes(), values); +// Assert.assertSame(parent, valueA.getParent()); +// Assert.assertTrue((parent.getChildren(Geometry_shapes())).contains(valueA)); +// Assert.assertSame(parent, valueB.getParent()); +// Assert.assertTrue((parent.getChildren(Geometry_shapes())).contains(valueB)); +// } + +// @Test +// public void MultipleListNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// AbstractClassifierInstance valueA = newCoord("cA"); +// AbstractClassifierInstance valueB = newCoord("cB"); +// AbstractClassifierInstance values = new List() { valueA, valueB }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addChild(Geometry_shapes(), values)); +// Assert.assertTrue((parent.getChildren(Geometry_shapes())).size() == 0); +// } + +// @Test +// public void MultipleUntypedListNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// AbstractClassifierInstance valueA = newCoord("cA"); +// AbstractClassifierInstance valueB = newCoord("cB"); +// AbstractClassifierInstance values = new ArrayList() { valueA, valueB }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addChild(Geometry_shapes(), values)); +// Assert.assertTrue((parent.getChildren(Geometry_shapes())).size() == 0); +// } + +// @Test +// public void MultipleUntypedArrayNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// AbstractClassifierInstance valueA = newCoord("cA"); +// AbstractClassifierInstance valueB = newCoord("cB"); +// AbstractClassifierInstance values = new object[] { valueA, valueB }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addChild(Geometry_shapes(), values)); +// Assert.assertTrue((parent.getChildren(Geometry_shapes())).size() == 0); +// } + + @Test + public void ResultUnmodifiable_Set() + { + AbstractClassifierInstance parent = newGeometry("g"); + Node valueA = newLine("sA"); + Node valueB = newLine("sB"); + parent.addChild(Geometry_shapes(), valueA); + parent.addChild(Geometry_shapes(), valueB); + List result = parent.getChildren(Geometry_shapes()); + Assert.assertThrows(UnsupportedOperationException.class, () -> result.add(valueA)); + } + + @Test + public void ResultUnmodifiable_Unset() + { + Node valueA = newLine("sA"); + AbstractClassifierInstance parent = newGeometry("g"); + List result = parent.getChildren(Geometry_shapes()); + Assert.assertThrows(UnsupportedOperationException.class, () -> result.add(valueA)); + } + +// #endregion +} \ No newline at end of file diff --git a/core/src/test/java/lionweb/core/m2/dynamic/test/DynamicNodeTestsBase.java b/core/src/test/java/lionweb/core/m2/dynamic/test/DynamicNodeTestsBase.java index f4f7f2e0..8eef96bd 100644 --- a/core/src/test/java/lionweb/core/m2/dynamic/test/DynamicNodeTestsBase.java +++ b/core/src/test/java/lionweb/core/m2/dynamic/test/DynamicNodeTestsBase.java @@ -149,8 +149,8 @@ protected Feature ReferenceGeometry_shapes() { return getFeatureByKey(getClassifierByKey("key-ReferenceGeometry"), "key-shapes-references"); } - protected Feature Geometry_shapes() { - return getFeatureByKey(getClassifierByKey("key-Geometry"), "key-shapes"); + protected Containment Geometry_shapes() { + return (Containment) getFeatureByKey(getClassifierByKey("key-Geometry"), "key-shapes"); } protected Feature CompositeShape_parts() { From 5dab2c5fcd2ee6d5b0b102fd0c40437208f94aa1 Mon Sep 17 00:00:00 2001 From: Niko Stotz Date: Sat, 29 Jun 2024 14:20:05 +0200 Subject: [PATCH 3/4] added remaining dynamic tests (translated from C#) --- .../test/ContainmentTests_Annotation.java | 175 ++-- .../ContainmentTests_Multiple_Optional.java | 26 +- .../ContainmentTests_Multiple_Required.java | 487 +++++++++ .../ContainmentTests_Single_Optional.java | 374 +++++++ .../ContainmentTests_Single_Required.java | 375 +++++++ .../m2/dynamic/test/DynamicNodeTestsBase.java | 127 +-- .../m2/dynamic/test/ParentHandlingTests.java | 932 ++++++++++++++++++ .../test/PropertyTests_Boolean_Optional.java | 95 ++ .../test/PropertyTests_Enum_Optional.java | 127 +++ .../test/PropertyTests_Integer_Required.java | 94 ++ .../test/PropertyTests_String_Optional.java | 93 ++ .../ReferenceTests_Multiple_Optional.java | 445 +++++++++ .../ReferenceTests_Multiple_Required.java | 486 +++++++++ .../test/ReferenceTests_Single_Optional.java | 373 +++++++ .../test/ReferenceTests_Single_Required.java | 374 +++++++ .../core/m2/dynamic/test/ReflectionTests.java | 110 +++ .../m2/dynamic/test/SetFeaturesTests.java | 413 ++++++++ 17 files changed, 4948 insertions(+), 158 deletions(-) create mode 100644 core/src/test/java/lionweb/core/m2/dynamic/test/ContainmentTests_Multiple_Required.java create mode 100644 core/src/test/java/lionweb/core/m2/dynamic/test/ContainmentTests_Single_Optional.java create mode 100644 core/src/test/java/lionweb/core/m2/dynamic/test/ContainmentTests_Single_Required.java create mode 100644 core/src/test/java/lionweb/core/m2/dynamic/test/ParentHandlingTests.java create mode 100644 core/src/test/java/lionweb/core/m2/dynamic/test/PropertyTests_Boolean_Optional.java create mode 100644 core/src/test/java/lionweb/core/m2/dynamic/test/PropertyTests_Enum_Optional.java create mode 100644 core/src/test/java/lionweb/core/m2/dynamic/test/PropertyTests_Integer_Required.java create mode 100644 core/src/test/java/lionweb/core/m2/dynamic/test/PropertyTests_String_Optional.java create mode 100644 core/src/test/java/lionweb/core/m2/dynamic/test/ReferenceTests_Multiple_Optional.java create mode 100644 core/src/test/java/lionweb/core/m2/dynamic/test/ReferenceTests_Multiple_Required.java create mode 100644 core/src/test/java/lionweb/core/m2/dynamic/test/ReferenceTests_Single_Optional.java create mode 100644 core/src/test/java/lionweb/core/m2/dynamic/test/ReferenceTests_Single_Required.java create mode 100644 core/src/test/java/lionweb/core/m2/dynamic/test/ReflectionTests.java create mode 100644 core/src/test/java/lionweb/core/m2/dynamic/test/SetFeaturesTests.java diff --git a/core/src/test/java/lionweb/core/m2/dynamic/test/ContainmentTests_Annotation.java b/core/src/test/java/lionweb/core/m2/dynamic/test/ContainmentTests_Annotation.java index 3bddf202..1d69e001 100644 --- a/core/src/test/java/lionweb/core/m2/dynamic/test/ContainmentTests_Annotation.java +++ b/core/src/test/java/lionweb/core/m2/dynamic/test/ContainmentTests_Annotation.java @@ -26,9 +26,10 @@ import org.junit.Test; import java.util.Collections; +import java.util.List; public class ContainmentTests_Annotation extends DynamicNodeTestsBase { -// #region Single +//// #region Single @Test public void Single_Add() { @@ -44,12 +45,12 @@ public void Single_Add() { // { // AbstractClassifierInstance parent = newLine("g"); // AbstractClassifierInstance bom = newBillOfMaterials("myId"); -// Assert.assertThrows(InvalidValueException>(() -> parent.Set(null, bom)); +// Assert.assertThrows(IllegalArgumentException.class, () -> parent.Set(null, bom)); // Assert.assertEquals(null, bom.getParent()); // Assert.assertFalse(parent.getAnnotations().contains(bom)); // } -// #region Insert +//// #region Insert // @Test // public void Single_Insert_Empty() @@ -92,7 +93,7 @@ public void Single_Add() { // Assert.assertEquals(parent, doc.getParent()); // Assert.assertEquals(parent, bom.getParent()); // Assert.assertTrue(parent.getAnnotations().contains(bom)); -// CollectionAssert.AreEqual(Lists.newArrayList( bom, doc }, parent.getAnnotations()); +// CollectionAssert.assertEquals(Lists.newArrayList( bom, doc }, parent.getAnnotations()); // } // @Test @@ -106,7 +107,7 @@ public void Single_Add() { // Assert.assertEquals(parent, doc.getParent()); // Assert.assertEquals(parent, bom.getParent()); // Assert.assertTrue(parent.getAnnotations().contains(bom)); -// CollectionAssert.AreEqual(Lists.newArrayList( doc, bom }, parent.getAnnotations()); +// CollectionAssert.assertEquals(Lists.newArrayList( doc, bom }, parent.getAnnotations()); // } // @Test @@ -122,7 +123,7 @@ public void Single_Add() { // Assert.assertEquals(parent, docB.getParent()); // Assert.assertEquals(parent, bom.getParent()); // Assert.assertTrue(parent.getAnnotations().contains(bom)); -// CollectionAssert.AreEqual(Lists.newArrayList( bom, docA, docB }, parent.getAnnotations()); +// CollectionAssert.assertEquals(Lists.newArrayList( bom, docA, docB }, parent.getAnnotations()); // } // @Test @@ -138,7 +139,7 @@ public void Single_Add() { // Assert.assertEquals(parent, docB.getParent()); // Assert.assertEquals(parent, bom.getParent()); // Assert.assertTrue(parent.getAnnotations().contains(bom)); -// CollectionAssert.AreEqual(Lists.newArrayList( docA, bom, docB }, parent.getAnnotations()); +// CollectionAssert.assertEquals(Lists.newArrayList( docA, bom, docB }, parent.getAnnotations()); // } // @Test @@ -154,12 +155,12 @@ public void Single_Add() { // Assert.assertEquals(parent, docB.getParent()); // Assert.assertEquals(parent, bom.getParent()); // Assert.assertTrue(parent.getAnnotations().contains(bom)); -// CollectionAssert.AreEqual(Lists.newArrayList( docA, docB, bom }, parent.getAnnotations()); +// CollectionAssert.assertEquals(Lists.newArrayList( docA, docB, bom }, parent.getAnnotations()); // } -// #endregion +//// #endregion -// #region Remove +//// #region Remove @Test public void Single_Remove_Empty() { @@ -234,11 +235,11 @@ public void Single_Remove_Between() { CollectionAssert.AreEqual(Lists.newArrayList(docA, docB), parent.getAnnotations()); } -// #endregion +//// #endregion -// #endregion +//// #endregion -// #region Null +//// #region Null @Test public void Null() { @@ -250,14 +251,14 @@ public void Null() { // public void Null_Reflective() // { // AbstractClassifierInstance parent = newLine("g"); -// Assert.assertThrows(InvalidValueException>(() -> parent.Set(null, null)); +// Assert.assertThrows(IllegalArgumentException.class, () -> parent.Set(null, null)); // } // @Test // public void Null_Insert_Empty() // { // AbstractClassifierInstance parent = newLine("g"); -// Assert.assertThrows(InvalidValueException>(() -> parent.InsertAnnotations(0, null)); +// Assert.assertThrows(IllegalArgumentException.class, () -> parent.InsertAnnotations(0, null)); // } // @Test @@ -273,9 +274,9 @@ public void Null_Remove_Empty() { Assert.assertThrows(NullPointerException.class, () -> parent.removeAnnotation(null)); } -// #endregion +//// #endregion -// #region EmptyCollection +//// #region EmptyCollection // @Test // public void EmptyArray() @@ -340,16 +341,16 @@ public void Null_Remove_Empty() { // Assert.assertTrue(parent.getAnnotations().size() == 0); // } -// #endregion +//// #endregion -// #region NullCollection +//// #region NullCollection // @Test // public void NullArray() // { // AbstractClassifierInstance parent = newLine("g"); // AbstractClassifierInstance[] values = new AbstractClassifierInstance[] { null }; -// Assert.assertThrows(InvalidValueException>(() -> parent.addAnnotation(values)); +// Assert.assertThrows(IllegalArgumentException.class, () -> parent.addAnnotation(values)); // Assert.assertTrue(parent.getAnnotations().size() == 0); // } @@ -358,7 +359,7 @@ public void Null_Remove_Empty() { // { // AbstractClassifierInstance parent = newLine("g"); // AbstractClassifierInstance[] values = new AbstractClassifierInstance[] { null }; -// Assert.assertThrows(InvalidValueException>( +// Assert.assertThrows(IllegalArgumentException.class, // () -> parent.Set(null, values)); // Assert.assertTrue(parent.getAnnotations().size() == 0); // } @@ -368,7 +369,7 @@ public void Null_Remove_Empty() { // { // AbstractClassifierInstance parent = newLine("g"); // AbstractClassifierInstance[] values = new AbstractClassifierInstance[] { null }; -// Assert.assertThrows(InvalidValueException>(() -> parent.InsertAnnotations(0, values)); +// Assert.assertThrows(IllegalArgumentException.class, () -> parent.InsertAnnotations(0, values)); // Assert.assertTrue(parent.getAnnotations().size() == 0); // } @@ -377,7 +378,7 @@ public void Null_Remove_Empty() { // { // AbstractClassifierInstance parent = newLine("g"); // AbstractClassifierInstance[] values = new AbstractClassifierInstance[] { null }; -// Assert.assertThrows(InvalidValueException>(() -> parent.RemoveAnnotations(values)); +// Assert.assertThrows(IllegalArgumentException.class, () -> parent.RemoveAnnotations(values)); // Assert.assertTrue(parent.getAnnotations().size() == 0); // } @@ -386,7 +387,7 @@ public void Null_Remove_Empty() { // { // AbstractClassifierInstance parent = newLine("g"); // AbstractClassifierInstance values = new ArrayList() { null }; -// Assert.assertThrows(InvalidValueException>( +// Assert.assertThrows(IllegalArgumentException.class, // () -> parent.Set(null, values)); // Assert.assertTrue(parent.getAnnotations().size() == 0); // } @@ -396,7 +397,7 @@ public void Null_Remove_Empty() { // { // AbstractClassifierInstance parent = newLine("g"); // AbstractClassifierInstance values = new List() { null }; -// Assert.assertThrows(InvalidValueException>( +// Assert.assertThrows(IllegalArgumentException.class, // () -> parent.Set(null, values)); // Assert.assertTrue(parent.getAnnotations().size() == 0); // } @@ -406,14 +407,14 @@ public void Null_Remove_Empty() { // { // AbstractClassifierInstance parent = newLine("g"); // AbstractClassifierInstance values = new HashSet() { null }; -// Assert.assertThrows(InvalidValueException>( +// Assert.assertThrows(IllegalArgumentException.class, // () -> parent.Set(null, values)); // Assert.assertTrue(parent.getAnnotations().size() == 0); // } -// #endregion +//// #endregion -// #region SingleCollection +//// #region SingleCollection // @Test // public void SingleArray() @@ -448,7 +449,7 @@ public void Null_Remove_Empty() { // parent.Set(null, values); // Assert.assertNull(doc.getParent()); // Assert.assertEquals(parent, value.getParent()); -// CollectionAssert.AreEqual(Lists.newArrayList( value }, parent.getAnnotations()); +// CollectionAssert.assertEquals(Lists.newArrayList( value }, parent.getAnnotations()); // } // @Test @@ -462,7 +463,7 @@ public void Null_Remove_Empty() { // Assert.assertTrue(parent.getAnnotations().contains(value)); // } -// #region Remove +//// #region Remove // @Test // public void SingleArray_Remove_Empty() @@ -484,7 +485,7 @@ public void Null_Remove_Empty() { // AnnotationInstance[] values = new AnnotationInstance[]{ bom }; // parent.RemoveAnnotations(values); // Assert.assertNull(bom.getParent()); -// CollectionAssert.AreEqual(Lists.newArrayList( }, parent.getAnnotations()); +// CollectionAssert.assertEquals(Lists.newArrayList( }, parent.getAnnotations()); // } // @Test @@ -498,7 +499,7 @@ public void Null_Remove_Empty() { // parent.RemoveAnnotations(values); // Assert.assertEquals(parent, doc.getParent()); // Assert.assertNull(bom.getParent()); -// CollectionAssert.AreEqual(Lists.newArrayList( doc }, parent.getAnnotations()); +// CollectionAssert.assertEquals(Lists.newArrayList( doc }, parent.getAnnotations()); // } // @Test @@ -512,7 +513,7 @@ public void Null_Remove_Empty() { // parent.RemoveAnnotations(values); // Assert.assertEquals(parent, doc.getParent()); // Assert.assertNull(bom.getParent()); -// CollectionAssert.AreEqual(Lists.newArrayList( doc }, parent.getAnnotations()); +// CollectionAssert.assertEquals(Lists.newArrayList( doc }, parent.getAnnotations()); // } // @Test @@ -528,10 +529,10 @@ public void Null_Remove_Empty() { // Assert.assertEquals(parent, docA.getParent()); // Assert.assertEquals(parent, docB.getParent()); // Assert.assertNull(bom.getParent()); -// CollectionAssert.AreEqual(Lists.newArrayList( docA, docB }, parent.getAnnotations()); +// CollectionAssert.assertEquals(Lists.newArrayList( docA, docB }, parent.getAnnotations()); // } -// #endregion +//// #endregion // @Test // public void SingleUntypedArray_Reflective() @@ -583,7 +584,7 @@ public void Null_Remove_Empty() { // AbstractClassifierInstance parent = newLine("g"); // AbstractClassifierInstance value = newCoord("c"); // AbstractClassifierInstance values = new ArrayList() { value }; -// Assert.assertThrows(InvalidValueException>( +// Assert.assertThrows(IllegalArgumentException.class, // () -> parent.Set(null, values)); // Assert.assertTrue(parent.getAnnotations().size() == 0); // } @@ -594,7 +595,7 @@ public void Null_Remove_Empty() { // AbstractClassifierInstance parent = newLine("g"); // AbstractClassifierInstance value = newCoord("c"); // AbstractClassifierInstance values = new ArrayList() { value }; -// Assert.assertThrows(InvalidValueException>( +// Assert.assertThrows(IllegalArgumentException.class, // () -> parent.Set(null, values)); // Assert.assertTrue(parent.getAnnotations().size() == 0); // } @@ -605,14 +606,14 @@ public void Null_Remove_Empty() { // AbstractClassifierInstance parent = newLine("g"); // AbstractClassifierInstance value = newCoord("c"); // Object[] values = new Object[] { value }; -// Assert.assertThrows(InvalidValueException>( +// Assert.assertThrows(IllegalArgumentException.class, // () -> parent.Set(null, values)); // Assert.assertTrue(parent.getAnnotations().size() == 0); // } -// #endregion +//// #endregion -// #region MultipleCollection +//// #region MultipleCollection // @Test // public void MultipleArray() @@ -642,7 +643,7 @@ public void Null_Remove_Empty() { // Assert.assertTrue(parent.getAnnotations().contains(valueB)); // } -// #region Insert +//// #region Insert // @Test // public void Multiple_Insert_ListMatchingType() @@ -654,7 +655,7 @@ public void Null_Remove_Empty() { // parent.InsertAnnotations(0, values); // Assert.assertEquals(parent, valueA.getParent()); // Assert.assertEquals(parent, valueB.getParent()); -// CollectionAssert.AreEqual(Lists.newArrayList( valueA, valueB }, parent.getAnnotations()); +// CollectionAssert.assertEquals(Lists.newArrayList( valueA, valueB }, parent.getAnnotations()); // } // @Test @@ -667,7 +668,7 @@ public void Null_Remove_Empty() { // parent.InsertAnnotations(0, values); // Assert.assertEquals(parent, valueA.getParent()); // Assert.assertEquals(parent, valueB.getParent()); -// CollectionAssert.AreEqual(Lists.newArrayList( valueA, valueB }, parent.getAnnotations()); +// CollectionAssert.assertEquals(Lists.newArrayList( valueA, valueB }, parent.getAnnotations()); // } // @Test @@ -680,7 +681,7 @@ public void Null_Remove_Empty() { // parent.InsertAnnotations(0, values); // Assert.assertEquals(parent, valueA.getParent()); // Assert.assertEquals(parent, valueB.getParent()); -// CollectionAssert.AreEqual(Lists.newArrayList( valueA, valueB }, parent.getAnnotations()); +// CollectionAssert.assertEquals(Lists.newArrayList( valueA, valueB }, parent.getAnnotations()); // } // @Test @@ -693,7 +694,7 @@ public void Null_Remove_Empty() { // parent.InsertAnnotations(0, values); // Assert.assertEquals(parent, valueA.getParent()); // Assert.assertEquals(parent, valueB.getParent()); -// CollectionAssert.AreEqual(Lists.newArrayList( valueA, valueB }, parent.getAnnotations()); +// CollectionAssert.assertEquals(Lists.newArrayList( valueA, valueB }, parent.getAnnotations()); // } // @Test @@ -709,7 +710,7 @@ public void Null_Remove_Empty() { // Assert.assertEquals(parent, doc.getParent()); // Assert.assertEquals(parent, valueA.getParent()); // Assert.assertEquals(parent, valueB.getParent()); -// CollectionAssert.AreEqual(Lists.newArrayList( valueA, valueB, doc }, parent.getAnnotations()); +// CollectionAssert.assertEquals(Lists.newArrayList( valueA, valueB, doc }, parent.getAnnotations()); // } // @Test @@ -725,7 +726,7 @@ public void Null_Remove_Empty() { // Assert.assertEquals(parent, doc.getParent()); // Assert.assertEquals(parent, valueA.getParent()); // Assert.assertEquals(parent, valueB.getParent()); -// CollectionAssert.AreEqual(Lists.newArrayList( doc, valueA, valueB }, parent.getAnnotations()); +// CollectionAssert.assertEquals(Lists.newArrayList( doc, valueA, valueB }, parent.getAnnotations()); // } // @Test @@ -743,7 +744,7 @@ public void Null_Remove_Empty() { // Assert.assertEquals(parent, docB.getParent()); // Assert.assertEquals(parent, valueA.getParent()); // Assert.assertEquals(parent, valueB.getParent()); -// CollectionAssert.AreEqual(Lists.newArrayList( valueA, valueB, docA, docB }, parent.getAnnotations()); +// CollectionAssert.assertEquals(Lists.newArrayList( valueA, valueB, docA, docB }, parent.getAnnotations()); // } // @Test @@ -761,7 +762,7 @@ public void Null_Remove_Empty() { // Assert.assertEquals(parent, docB.getParent()); // Assert.assertEquals(parent, valueA.getParent()); // Assert.assertEquals(parent, valueB.getParent()); -// CollectionAssert.AreEqual(Lists.newArrayList( docA, valueA, valueB, docB }, parent.getAnnotations()); +// CollectionAssert.assertEquals(Lists.newArrayList( docA, valueA, valueB, docB }, parent.getAnnotations()); // } // @Test @@ -779,12 +780,12 @@ public void Null_Remove_Empty() { // Assert.assertEquals(parent, docB.getParent()); // Assert.assertEquals(parent, valueA.getParent()); // Assert.assertEquals(parent, valueB.getParent()); -// CollectionAssert.AreEqual(Lists.newArrayList( docA, docB, valueA, valueB }, parent.getAnnotations()); +// CollectionAssert.assertEquals(Lists.newArrayList( docA, docB, valueA, valueB }, parent.getAnnotations()); // } -// #endregion +//// #endregion -// #region Remove +//// #region Remove // @Test // public void Multiple_Remove_ListMatchingType() @@ -857,7 +858,7 @@ public void Null_Remove_Empty() { // Assert.assertEquals(parent, docB.getParent()); // Assert.assertNull(valueA.getParent()); // Assert.assertNull(valueB.getParent()); -// CollectionAssert.AreEqual(Lists.newArrayList( docA, docB }, parent.getAnnotations()); +// CollectionAssert.assertEquals(Lists.newArrayList( docA, docB }, parent.getAnnotations()); // } // @Test @@ -873,7 +874,7 @@ public void Null_Remove_Empty() { // Assert.assertEquals(parent, docB.getParent()); // Assert.assertNull(valueA.getParent()); // Assert.assertNull(docA.getParent()); -// CollectionAssert.AreEqual(Lists.newArrayList( docB }, parent.getAnnotations()); +// CollectionAssert.assertEquals(Lists.newArrayList( docB }, parent.getAnnotations()); // } // @Test @@ -887,7 +888,7 @@ public void Null_Remove_Empty() { // parent.RemoveAnnotations(values); // Assert.assertNull(valueA.getParent()); // Assert.assertNull(valueB.getParent()); -// CollectionAssert.AreEqual(Lists.newArrayList( }, parent.getAnnotations()); +// CollectionAssert.assertEquals(Lists.newArrayList( }, parent.getAnnotations()); // } // @Test @@ -903,7 +904,7 @@ public void Null_Remove_Empty() { // Assert.assertEquals(parent, doc.getParent()); // Assert.assertNull(valueA.getParent()); // Assert.assertNull(valueB.getParent()); -// CollectionAssert.AreEqual(Lists.newArrayList( doc }, parent.getAnnotations()); +// CollectionAssert.assertEquals(Lists.newArrayList( doc }, parent.getAnnotations()); // } // @Test @@ -919,7 +920,7 @@ public void Null_Remove_Empty() { // Assert.assertEquals(parent, doc.getParent()); // Assert.assertNull(valueA.getParent()); // Assert.assertNull(valueB.getParent()); -// CollectionAssert.AreEqual(Lists.newArrayList( doc }, parent.getAnnotations()); +// CollectionAssert.assertEquals(Lists.newArrayList( doc }, parent.getAnnotations()); // } // @Test @@ -937,7 +938,7 @@ public void Null_Remove_Empty() { // Assert.assertEquals(parent, docB.getParent()); // Assert.assertNull(valueA.getParent()); // Assert.assertNull(valueB.getParent()); -// CollectionAssert.AreEqual(Lists.newArrayList( docA, docB }, parent.getAnnotations()); +// CollectionAssert.assertEquals(Lists.newArrayList( docA, docB }, parent.getAnnotations()); // } // @Test @@ -955,10 +956,10 @@ public void Null_Remove_Empty() { // Assert.assertEquals(parent, docB.getParent()); // Assert.assertNull(valueA.getParent()); // Assert.assertNull(valueB.getParent()); -// CollectionAssert.AreEqual(Lists.newArrayList( docA, docB }, parent.getAnnotations()); +// CollectionAssert.assertEquals(Lists.newArrayList( docA, docB }, parent.getAnnotations()); // } -// #endregion +//// #endregion // @Test // public void MultipleUntypedArray_Reflective() @@ -1079,7 +1080,7 @@ public void Null_Remove_Empty() { // AbstractClassifierInstance valueA = newCoord("cA"); // AbstractClassifierInstance valueB = newCoord("cB"); // AbstractClassifierInstance values = new ArrayList() { valueA, valueB }; -// Assert.assertThrows(InvalidValueException>( +// Assert.assertThrows(IllegalArgumentException.class, // () -> parent.Set(null, values)); // Assert.assertTrue(parent.getAnnotations().size() == 0); // } @@ -1091,7 +1092,7 @@ public void Null_Remove_Empty() { // AbstractClassifierInstance valueA = newCoord("cA"); // AbstractClassifierInstance valueB = newCoord("cB"); // AbstractClassifierInstance values = new ArrayList() { valueA, valueB }; -// Assert.assertThrows(InvalidValueException>( +// Assert.assertThrows(IllegalArgumentException.class, // () -> parent.Set(null, values)); // Assert.assertTrue(parent.getAnnotations().size() == 0); // } @@ -1103,7 +1104,7 @@ public void Null_Remove_Empty() { // AbstractClassifierInstance valueA = newCoord("cA"); // AbstractClassifierInstance valueB = newCoord("cB"); // Object[] values = new Object[] { valueA, valueB }; -// Assert.assertThrows(InvalidValueException>( +// Assert.assertThrows(IllegalArgumentException.class, // () -> parent.Set(null, values)); // Assert.assertTrue(parent.getAnnotations().size() == 0); // } @@ -1114,7 +1115,7 @@ public void Null_Remove_Empty() { // AbstractClassifierInstance parent = newGeometry("g"); // AnnotationInstance value = newDocumentation("sA"); // AbstractClassifierInstance values = new ArrayList() { value }; -// Assert.assertThrows(InvalidValueException>(() -> parent.addAnnotation(values)); +// Assert.assertThrows(IllegalArgumentException.class, () -> parent.addAnnotation(values)); // Assert.assertNull(value.getParent()); // Assert.assertFalse(parent.getAnnotations().contains(value)); // } @@ -1125,7 +1126,7 @@ public void Null_Remove_Empty() { // AbstractClassifierInstance parent = newGeometry("g"); // AnnotationInstance value = newDocumentation("sA"); // AbstractClassifierInstance values = new ArrayList() { value }; -// Assert.assertThrows(InvalidValueException>(() -> parent.Set(null, values)); +// Assert.assertThrows(IllegalArgumentException.class, () -> parent.Set(null, values)); // Assert.assertNull(value.getParent()); // Assert.assertFalse(parent.getAnnotations().contains(value)); // } @@ -1136,7 +1137,7 @@ public void Null_Remove_Empty() { // AbstractClassifierInstance parent = newGeometry("g"); // AnnotationInstance value = newDocumentation("sA"); // AbstractClassifierInstance values = new ArrayList() { value }; -// Assert.assertThrows(InvalidValueException>(() -> parent.InsertAnnotations(0, values)); +// Assert.assertThrows(IllegalArgumentException.class, () -> parent.InsertAnnotations(0, values)); // Assert.assertNull(value.getParent()); // Assert.assertFalse(parent.getAnnotations().contains(value)); // } @@ -1161,28 +1162,30 @@ public void Null_Remove_Empty() { // AnnotationInstance[] values = new AnnotationInstance[]{ valueA, valueB }; // parent.Set(null, values); // AbstractClassifierInstance result = parent.Get(null); -// CollectionAssert.AreEqual(new List() {valueA, valueB}, (result as IList).ToList()); +// CollectionAssert.assertEquals(new List() {valueA, valueB}, (result as IList).ToList()); // } -// @Test -// public void ResultUnmodifiable_Set() -// { -// AbstractClassifierInstance parent = newLine("g"); -// AnnotationInstance valueA = newBillOfMaterials("sA"); -// AnnotationInstance valueB = newBillOfMaterials("sB"); -// AnnotationInstance[] values = new AnnotationInstance[]{ valueA, valueB }; -// parent.Set(null, values); -// AbstractClassifierInstance result = parent.Get(null); -// Assert.IsInstanceOfType>(result); -// } + @Test + public void ResultUnmodifiable_Set() + { + AbstractClassifierInstance parent = newLine("g"); + AnnotationInstance valueA = newBillOfMaterials("sA"); + AnnotationInstance valueB = newBillOfMaterials("sB"); + AnnotationInstance[] values = new AnnotationInstance[]{ valueA, valueB }; + parent.addAnnotation(valueA); + parent.addAnnotation(valueB); + List result = parent.getAnnotations(); + Assert.assertThrows(UnsupportedOperationException.class, () -> result.add(valueA)); + } -// @Test -// public void ResultUnmodifiable_Unset() -// { -// AbstractClassifierInstance parent = newLine("g"); -// AbstractClassifierInstance result = parent.Get(null); -// Assert.IsInstanceOfType>(result); -// } + @Test + public void ResultUnmodifiable_Unset() + { + AnnotationInstance valueA = newBillOfMaterials("sA"); + AbstractClassifierInstance parent = newLine("g"); + List result = parent.getAnnotations(); + Assert.assertThrows(UnsupportedOperationException.class, () -> result.add(valueA)); + } -// #endregion +//// #endregion } \ No newline at end of file diff --git a/core/src/test/java/lionweb/core/m2/dynamic/test/ContainmentTests_Multiple_Optional.java b/core/src/test/java/lionweb/core/m2/dynamic/test/ContainmentTests_Multiple_Optional.java index 1e812a07..faa289a5 100644 --- a/core/src/test/java/lionweb/core/m2/dynamic/test/ContainmentTests_Multiple_Optional.java +++ b/core/src/test/java/lionweb/core/m2/dynamic/test/ContainmentTests_Multiple_Optional.java @@ -26,7 +26,7 @@ public class ContainmentTests_Multiple_Optional extends DynamicNodeTestsBase { -// #region Single +//// #region Single @Test public void Single_Reflective() @@ -41,9 +41,9 @@ public void Single_Reflective() Assert.assertTrue((parent.getChildren(Geometry_shapes())).contains(line)); } -// #endregion +//// #endregion -// #region Null +//// #region Null @Test public void Null_Reflective() @@ -52,9 +52,9 @@ public void Null_Reflective() Assert.assertThrows(IllegalArgumentException.class, () -> parent.addChild(Geometry_shapes(), null)); } -// #endregion +//// #endregion -// #region EmptyCollection +//// #region EmptyCollection // @Test // public void EmptyArray_Reflective() @@ -120,9 +120,9 @@ public void Null_Reflective() // Assert.assertTrue((parent.getChildren(Geometry_shapes())).size() == 0); // } -// #endregion +//// #endregion -// #region NullCollection +//// #region NullCollection // @Test // public void NullArray_Reflective() @@ -184,9 +184,9 @@ public void Null_Reflective() // Assert.assertTrue((parent.getChildren(Geometry_shapes())).size() == 0); // } -// #endregion +//// #endregion -// #region SingleCollection +//// #region SingleCollection // @Test // public void SingleArray_Reflective() @@ -210,7 +210,7 @@ public void Null_Reflective() // parent.addChild(Geometry_shapes(), values); // Assert.assertNull(circle.getParent()); // Assert.assertSame(parent, value.getParent()); -// CollectionAssert.AreEqual(new List { value }, +// CollectionAssert.assertEquals(new List { value }, // (parent.getChildren(Geometry_shapes())).ToList()); // } @@ -302,9 +302,9 @@ public void Null_Reflective() // Assert.assertTrue((parent.getChildren(Geometry_shapes())).size() == 0); // } -// #endregion +//// #endregion -// #region MultipleCollection +//// #region MultipleCollection // @Test // public void MultipleArray_Reflective() @@ -461,5 +461,5 @@ public void ResultUnmodifiable_Unset() Assert.assertThrows(UnsupportedOperationException.class, () -> result.add(valueA)); } -// #endregion +//// #endregion } \ No newline at end of file diff --git a/core/src/test/java/lionweb/core/m2/dynamic/test/ContainmentTests_Multiple_Required.java b/core/src/test/java/lionweb/core/m2/dynamic/test/ContainmentTests_Multiple_Required.java new file mode 100644 index 00000000..de98a1d1 --- /dev/null +++ b/core/src/test/java/lionweb/core/m2/dynamic/test/ContainmentTests_Multiple_Required.java @@ -0,0 +1,487 @@ +// Copyright 2024 TRUMPF Laser SE and other contributors +// +// 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. +// +// SPDX-FileCopyrightText: 2024 TRUMPF Laser SE and other contributors +// SPDX-License-Identifier: Apache-2.0 + +package lionweb.core.m2.dynamic.test; + +import io.lionweb.lioncore.java.model.Node; +import io.lionweb.lioncore.java.model.impl.AbstractClassifierInstance; +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; + +public class ContainmentTests_Multiple_Required extends DynamicNodeTestsBase +{ +// #region Single + + @Test + public void Single_Reflective() + { + AbstractClassifierInstance parent = newCompositeShape("cs"); + Node line = newLine("myId"); + Assert.assertThrows(IllegalArgumentException.class, () -> parent.addChild(CompositeShape_parts(), line)); + Assert.assertSame(null, line.getParent()); + Assert.assertThrows(IllegalArgumentException.class, () -> parent.getChildren(CompositeShape_parts()).contains(line)); + } + +// #endregion + +// #region Null + + @Test + public void Null_Reflective() + { + AbstractClassifierInstance parent = newCompositeShape("cs"); + Assert.assertThrows(IllegalArgumentException.class, () -> parent.addChild(CompositeShape_parts(), null)); + } + +// #endregion + +// #region EmptyCollection + +// @Test +// public void EmptyArray_Reflective() +// { +// AbstractClassifierInstance parent = newCompositeShape("cs"); +// AbstractClassifierInstance values = new DynamicNode[0]; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addChild(CompositeShape_parts(), values)); +// Assert.assertThrows(IllegalArgumentException.class, +// () -> (parent.Get(CompositeShape_parts()).size() == 0); +// } +// +// @Test +// public void EmptyUntypedList_Reflective() +// { +// AbstractClassifierInstance parent = newCompositeShape("cs"); +// AbstractClassifierInstance values = new ArrayList(); +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addChild(CompositeShape_parts(), values)); +// Assert.assertThrows(IllegalArgumentException.class, +// () -> (parent.Get(CompositeShape_parts()).size() == 0); +// } +// +// @Test +// public void EmptyListMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newCompositeShape("cs"); +// AbstractClassifierInstance values = new List(); +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addChild(CompositeShape_parts(), values)); +// Assert.assertThrows(IllegalArgumentException.class, +// () -> (parent.Get(CompositeShape_parts()).size() == 0); +// } +// +// @Test +// public void EmptyListSubtype_Reflective() +// { +// AbstractClassifierInstance parent = newCompositeShape("cs"); +// AbstractClassifierInstance values = new List(); +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addChild(CompositeShape_parts(), values)); +// Assert.assertThrows(IllegalArgumentException.class, +// () -> (parent.Get(CompositeShape_parts()).size() == 0); +// } +// +// @Test +// public void EmptySet_Reflective() +// { +// AbstractClassifierInstance parent = newCompositeShape("cs"); +// AbstractClassifierInstance values = new HashSet(); +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addChild(CompositeShape_parts(), values)); +// Assert.assertThrows(IllegalArgumentException.class, +// () -> (parent.Get(CompositeShape_parts()).size() == 0); +// } +// +// @Test +// public void EmptyListNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newCompositeShape("cs"); +// AbstractClassifierInstance values = new List(); +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addChild(CompositeShape_parts(), values)); +// Assert.assertThrows(IllegalArgumentException.class, +// () -> (parent.Get(CompositeShape_parts()).size() == 0); +// } +// +// @Test +// public void EmptyList_Reset_Reflective() +// { +// AbstractClassifierInstance parent = newCompositeShape("cs"); +// AbstractClassifierInstance value = newCircle("myId"); +// parent.addChild(CompositeShape_parts(), new List { value }); +// AbstractClassifierInstance values = new List(); +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addChild(CompositeShape_parts(), values)); +// CollectionAssert.assertEquals(new List { value }, +// (parent.Get(CompositeShape_parts()).ToList()); +// } + +// #endregion + +// #region NullCollection + +// @Test +// public void NullArray_Reflective() +// { +// AbstractClassifierInstance parent = newCompositeShape("cs"); +// AbstractClassifierInstance values = new DynamicNode[] { null }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addChild(CompositeShape_parts(), values)); +// Assert.assertThrows(IllegalArgumentException.class, () => +// (parent.Get(CompositeShape_parts()).size() == 0); +// } +// +// @Test +// public void NullUntypedList_Reflective() +// { +// AbstractClassifierInstance parent = newCompositeShape("cs"); +// AbstractClassifierInstance values = new ArrayList() { null }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addChild(CompositeShape_parts(), values)); +// Assert.assertThrows(IllegalArgumentException.class, () => +// (parent.Get(CompositeShape_parts()).size() == 0); +// } +// +// @Test +// public void NullListMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newCompositeShape("cs"); +// AbstractClassifierInstance values = new List() { null }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addChild(CompositeShape_parts(), values)); +// Assert.assertThrows(IllegalArgumentException.class, () => +// (parent.Get(CompositeShape_parts()).size() == 0); +// } +// +// @Test +// public void NullListSubtype_Reflective() +// { +// AbstractClassifierInstance parent = newCompositeShape("cs"); +// AbstractClassifierInstance values = new List() { null }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addChild(CompositeShape_parts(), values)); +// Assert.assertThrows(IllegalArgumentException.class, () => +// (parent.Get(CompositeShape_parts()).size() == 0); +// } +// +// @Test +// public void NullListNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newCompositeShape("cs"); +// AbstractClassifierInstance values = new List() { null }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addChild(CompositeShape_parts(), values)); +// Assert.assertThrows(IllegalArgumentException.class, () => +// (parent.Get(CompositeShape_parts()).size() == 0); +// } +// +// @Test +// public void NullSet_Reflective() +// { +// AbstractClassifierInstance parent = newCompositeShape("cs"); +// AbstractClassifierInstance values = new HashSet() { null }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addChild(CompositeShape_parts(), values)); +// Assert.assertThrows(IllegalArgumentException.class, () => +// (parent.Get(CompositeShape_parts()).size() == 0); +// } + +// #endregion + +// #region SingleCollection + +// @Test +// public void SingleArray_Reflective() +// { +// AbstractClassifierInstance parent = newCompositeShape("cs"); +// AbstractClassifierInstance value = newLine("s"); +// AbstractClassifierInstance values = new DynamicNode[] { value }; +// parent.addChild(CompositeShape_parts(), values); +// Assert.assertSame(parent, value.getParent()); +// Assert.assertTrue((parent.Get(CompositeShape_parts()).contains(value)); +// } +// +// @Test +// public void SingleArray_Existing_Reflective() +// { +// AbstractClassifierInstance circle = newCircle("cc"); +// AbstractClassifierInstance parent = newCompositeShape("g"); +// parent.addChild(CompositeShape_parts(), new DynamicNode[] { circle }); +// AbstractClassifierInstance value = newLine("s"); +// AbstractClassifierInstance values = new DynamicNode[] { value }; +// parent.addChild(CompositeShape_parts(), values); +// Assert.assertNull(circle.getParent()); +// Assert.assertSame(parent, value.getParent()); +// CollectionAssert.assertEquals(new List { value }, +// (parent.Get(CompositeShape_parts()).ToList()); +// } +// +// @Test +// public void SingleUntypedArray_Reflective() +// { +// AbstractClassifierInstance parent = newCompositeShape("cs"); +// AbstractClassifierInstance value = newLine("s"); +// AbstractClassifierInstance values = new object[] { value }; +// parent.addChild(CompositeShape_parts(), values); +// Assert.assertSame(parent, value.getParent()); +// Assert.assertTrue((parent.Get(CompositeShape_parts()).contains(value)); +// } +// +// @Test +// public void SingleUntypedList_Reflective() +// { +// AbstractClassifierInstance parent = newCompositeShape("cs"); +// AbstractClassifierInstance value = newLine("s"); +// AbstractClassifierInstance values = new ArrayList() { value }; +// parent.addChild(CompositeShape_parts(), values); +// Assert.assertSame(parent, value.getParent()); +// Assert.assertTrue((parent.Get(CompositeShape_parts()).contains(value)); +// } +// +// @Test +// public void SingleListMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newCompositeShape("cs"); +// AbstractClassifierInstance value = newLine("s"); +// AbstractClassifierInstance values = new List() { value }; +// parent.addChild(CompositeShape_parts(), values); +// Assert.assertSame(parent, value.getParent()); +// Assert.assertTrue((parent.Get(CompositeShape_parts()).contains(value)); +// } +// +// @Test +// public void SingleListSubtype_Reflective() +// { +// AbstractClassifierInstance parent = newCompositeShape("cs"); +// AbstractClassifierInstance value = newLine("s"); +// AbstractClassifierInstance values = new List() { value }; +// parent.addChild(CompositeShape_parts(), values); +// Assert.assertSame(parent, value.getParent()); +// Assert.assertTrue((parent.Get(CompositeShape_parts()).contains(value)); +// } +// +// @Test +// public void SingleSet_Reflective() +// { +// AbstractClassifierInstance parent = newCompositeShape("cs"); +// AbstractClassifierInstance value = newLine("s"); +// AbstractClassifierInstance values = new HashSet() { value }; +// parent.addChild(CompositeShape_parts(), values); +// Assert.assertSame(parent, value.getParent()); +// Assert.assertTrue((parent.Get(CompositeShape_parts()).contains(value)); +// } +// +// @Test +// public void SingleListNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newCompositeShape("cs"); +// AbstractClassifierInstance value = "c"; +// AbstractClassifierInstance values = new List() { value }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addChild(CompositeShape_parts(), values)); +// Assert.assertThrows(IllegalArgumentException.class, () => +// (parent.Get(CompositeShape_parts()).size() == 0); +// } +// +// @Test +// public void SingleUntypedListNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newCompositeShape("cs"); +// AbstractClassifierInstance value = newCoord("c"); +// AbstractClassifierInstance values = new ArrayList() { value }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addChild(CompositeShape_parts(), values)); +// Assert.assertThrows(IllegalArgumentException.class, () => +// (parent.Get(CompositeShape_parts()).size() == 0); +// } +// +// @Test +// public void SingleUntypedArrayNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newCompositeShape("cs"); +// AbstractClassifierInstance value = newCoord("c"); +// AbstractClassifierInstance values = new object[] { value }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addChild(CompositeShape_parts(), values)); +// Assert.assertThrows(IllegalArgumentException.class, () => +// (parent.Get(CompositeShape_parts()).size() == 0); +// } + +// #endregion + +// #region MultipleCollection + +// @Test +// public void MultipleArray_Reflective() +// { +// AbstractClassifierInstance parent = newCompositeShape("cs"); +// AbstractClassifierInstance valueA = newLine("sA"); +// AbstractClassifierInstance valueB = newLine("sB"); +// AbstractClassifierInstance values = new DynamicNode[] { valueA, valueB }; +// parent.addChild(CompositeShape_parts(), values); +// Assert.assertSame(parent, valueA.getParent()); +// Assert.assertTrue((parent.Get(CompositeShape_parts()).contains(valueA)); +// Assert.assertSame(parent, valueB.getParent()); +// Assert.assertTrue((parent.Get(CompositeShape_parts()).contains(valueB)); +// } +// +// @Test +// public void MultipleUntypedArray_Reflective() +// { +// AbstractClassifierInstance parent = newCompositeShape("cs"); +// AbstractClassifierInstance valueA = newLine("sA"); +// AbstractClassifierInstance valueB = newLine("sB"); +// AbstractClassifierInstance values = new object[] { valueA, valueB }; +// parent.addChild(CompositeShape_parts(), values); +// Assert.assertSame(parent, valueA.getParent()); +// Assert.assertTrue((parent.Get(CompositeShape_parts()).contains(valueA)); +// Assert.assertSame(parent, valueB.getParent()); +// Assert.assertTrue((parent.Get(CompositeShape_parts()).contains(valueB)); +// } +// +// @Test +// public void MultipleUntypedList_Reflective() +// { +// AbstractClassifierInstance parent = newCompositeShape("cs"); +// AbstractClassifierInstance valueA = newLine("sA"); +// AbstractClassifierInstance valueB = newLine("sB"); +// AbstractClassifierInstance values = new ArrayList() { valueA, valueB }; +// parent.addChild(CompositeShape_parts(), values); +// Assert.assertSame(parent, valueA.getParent()); +// Assert.assertTrue((parent.Get(CompositeShape_parts()).contains(valueA)); +// Assert.assertSame(parent, valueB.getParent()); +// Assert.assertTrue((parent.Get(CompositeShape_parts()).contains(valueB)); +// } +// +// @Test +// public void MultipleListMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newCompositeShape("cs"); +// AbstractClassifierInstance valueA = newLine("sA"); +// AbstractClassifierInstance valueB = newLine("sB"); +// AbstractClassifierInstance values = new List() { valueA, valueB }; +// parent.addChild(CompositeShape_parts(), values); +// Assert.assertSame(parent, valueA.getParent()); +// Assert.assertTrue((parent.Get(CompositeShape_parts()).contains(valueA)); +// Assert.assertSame(parent, valueB.getParent()); +// Assert.assertTrue((parent.Get(CompositeShape_parts()).contains(valueB)); +// } +// +// @Test +// public void MultipleListSubtype_Reflective() +// { +// AbstractClassifierInstance parent = newCompositeShape("cs"); +// AbstractClassifierInstance valueA = newLine("sA"); +// AbstractClassifierInstance valueB = newLine("sB"); +// AbstractClassifierInstance values = new List() { valueA, valueB }; +// parent.addChild(CompositeShape_parts(), values); +// Assert.assertSame(parent, valueA.getParent()); +// Assert.assertTrue((parent.Get(CompositeShape_parts()).contains(valueA)); +// Assert.assertSame(parent, valueB.getParent()); +// Assert.assertTrue((parent.Get(CompositeShape_parts()).contains(valueB)); +// } +// +// @Test +// public void MultipleSet_Reflective() +// { +// AbstractClassifierInstance parent = newCompositeShape("cs"); +// AbstractClassifierInstance valueA = newLine("sA"); +// AbstractClassifierInstance valueB = newLine("sB"); +// AbstractClassifierInstance values = new HashSet() { valueA, valueB }; +// parent.addChild(CompositeShape_parts(), values); +// Assert.assertSame(parent, valueA.getParent()); +// Assert.assertTrue((parent.Get(CompositeShape_parts()).contains(valueA)); +// Assert.assertSame(parent, valueB.getParent()); +// Assert.assertTrue((parent.Get(CompositeShape_parts()).contains(valueB)); +// } +// +// @Test +// public void MultipleSingleEnumerable_Reflective() +// { +// AbstractClassifierInstance parent = newCompositeShape("cs"); +// AbstractClassifierInstance valueA = newLine("sA"); +// AbstractClassifierInstance valueB = newLine("sB"); +// AbstractClassifierInstance values = new SingleEnumerable() { valueA, valueB }; +// parent.addChild(CompositeShape_parts(), values); +// Assert.assertSame(parent, valueA.getParent()); +// Assert.assertTrue((parent.Get(CompositeShape_parts()).contains(valueA)); +// Assert.assertSame(parent, valueB.getParent()); +// Assert.assertTrue((parent.Get(CompositeShape_parts()).contains(valueB)); +// } +// +// @Test +// public void MultipleListNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newCompositeShape("cs"); +// AbstractClassifierInstance valueA = "cA"; +// AbstractClassifierInstance valueB = "cB"; +// AbstractClassifierInstance values = new List() { valueA, valueB }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addChild(CompositeShape_parts(), values)); +// Assert.assertThrows(IllegalArgumentException.class, () => +// (parent.Get(CompositeShape_parts()).size() == 0); +// } +// +// @Test +// public void MultipleUntypedListNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newCompositeShape("cs"); +// AbstractClassifierInstance valueA = newCoord("cA"); +// AbstractClassifierInstance valueB = newCoord("cB"); +// AbstractClassifierInstance values = new ArrayList() { valueA, valueB }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addChild(CompositeShape_parts(), values)); +// Assert.assertThrows(IllegalArgumentException.class, () => +// (parent.Get(CompositeShape_parts()).size() == 0); +// } +// +// @Test +// public void MultipleUntypedArrayNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newCompositeShape("cs"); +// AbstractClassifierInstance valueA = newCoord("cA"); +// AbstractClassifierInstance valueB = newCoord("cB"); +// AbstractClassifierInstance values = new object[] { valueA, valueB }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addChild(CompositeShape_parts(), values)); +// Assert.assertThrows(IllegalArgumentException.class, () => +// (parent.Get(CompositeShape_parts()).size() == 0); +// } + + @Test + public void ResultUnmodifiable_Set() + { + AbstractClassifierInstance parent = newCompositeShape("g"); + Node valueA = newLine("sA"); + Node valueB = newLine("sB"); + parent.addChild(CompositeShape_parts(), valueA); + parent.addChild(CompositeShape_parts(), valueB); + List result = parent.getChildren(CompositeShape_parts()); + Assert.assertThrows(UnsupportedOperationException.class, () -> result.add(valueA)); + } + + @Test + public void ResultUnmodifiable_Unset() + { + AbstractClassifierInstance parent = newCompositeShape("g"); + Assert.assertThrows(IllegalArgumentException.class, () -> parent.getChildren(CompositeShape_parts())); + } + +// #endregion +} \ No newline at end of file diff --git a/core/src/test/java/lionweb/core/m2/dynamic/test/ContainmentTests_Single_Optional.java b/core/src/test/java/lionweb/core/m2/dynamic/test/ContainmentTests_Single_Optional.java new file mode 100644 index 00000000..ed3f2640 --- /dev/null +++ b/core/src/test/java/lionweb/core/m2/dynamic/test/ContainmentTests_Single_Optional.java @@ -0,0 +1,374 @@ +// Copyright 2024 TRUMPF Laser SE and other contributors +// +// 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. +// +// SPDX-FileCopyrightText: 2024 TRUMPF Laser SE and other contributors +// SPDX-License-Identifier: Apache-2.0 + +package lionweb.core.m2.dynamic.test; + +import io.lionweb.lioncore.java.model.Node; +import io.lionweb.lioncore.java.model.impl.AbstractClassifierInstance; +import org.junit.Assert; +import org.junit.Test; + +public class ContainmentTests_Single_Optional extends DynamicNodeTestsBase +{ +// #region Single + +// @Test +// public void Single_Reflective() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// Node doc = newDocumentation("myId"); +// parent.addChild(Geometry_documentation(), doc); +// Assert.assertSame(parent, doc.getParent()); +// Assert.assertSame(doc, parent.getChildren(Geometry_documentation())); +// } + +// @Test +// public void Existing_Reflective() +// { +// Node oldDoc = newDocumentation("old"); +// AbstractClassifierInstance parent = newGeometry("g"); +// parent.addChild(Geometry_documentation(), oldDoc); +// Node doc = newDocumentation("myId"); +// parent.addChild(Geometry_documentation(), doc); +// Assert.assertNull(oldDoc.getParent()); +// Assert.assertSame(parent, doc.getParent()); +// Assert.assertSame(doc, parent.getChildren(Geometry_documentation())); +// } + +// #endregion + +// #region Null + + @Test + public void Null_Reflective() + { + AbstractClassifierInstance parent = newGeometry("g"); + parent.addChild(Geometry_documentation(), null); + Assert.assertNull(parent.getChildren(Geometry_documentation())); + } + +// #endregion + +// #region EmptyCollection + +// @Test +// public void EmptyArray_Reflective() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// AbstractClassifierInstance values = new DynamicNode[0]; +// Assert.assertThrows(IllegalArgumentException.class, () => +// parent.addChild(Geometry_documentation(), values)); +// } +// +// @Test +// public void EmptyUntypedList_Reflective() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// AbstractClassifierInstance values = new ArrayList(); +// Assert.assertThrows(IllegalArgumentException.class, () => +// parent.addChild(Geometry_documentation(), values)); +// } +// +// @Test +// public void EmptyListMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// AbstractClassifierInstance values = new List(); +// Assert.assertThrows(IllegalArgumentException.class, () => +// parent.addChild(Geometry_documentation(), values)); +// } +// +// @Test +// public void EmptySet_Reflective() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// AbstractClassifierInstance values = new HashSet(); +// Assert.assertThrows(IllegalArgumentException.class, () => +// parent.addChild(Geometry_documentation(), values)); +// } +// +// @Test +// public void EmptyListNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// AbstractClassifierInstance values = new List(); +// Assert.assertThrows(IllegalArgumentException.class, () => +// parent.addChild(Geometry_documentation(), values)); +// } + +// #endregion + +// #region NullCollection + +// @Test +// public void NullArray_Reflective() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// AbstractClassifierInstance values = new DynamicNode[] { null }; +// Assert.assertThrows(IllegalArgumentException.class, () => +// parent.addChild(Geometry_documentation(), values)); +// } +// +// @Test +// public void NullUntypedList_Reflective() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// AbstractClassifierInstance values = new ArrayList() { null }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addChild(Geometry_documentation(), values)); +// } +// +// @Test +// public void NullListMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// AbstractClassifierInstance values = new List() { null }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addChild(Geometry_documentation(), values)); +// } +// +// @Test +// public void NullListNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// AbstractClassifierInstance values = new List() { null }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addChild(Geometry_documentation(), values)); +// } +// +// @Test +// public void NullSet_Reflective() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// AbstractClassifierInstance values = new HashSet() { null }; +// Assert.assertThrows(IllegalArgumentException.class, () => +// parent.addChild(Geometry_documentation(), values)); +// } + +// #endregion + +// #region SingleCollection + +// @Test +// public void SingleArray_Reflective() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// AbstractClassifierInstance value = newDocumentation("s"); +// AbstractClassifierInstance values = new DynamicNode[] { value }; +// +// Assert.assertThrows(IllegalArgumentException.class, () => +// parent.addChild(Geometry_documentation(), values)); +// Assert.assertNull(parent.getChildren(Geometry_documentation())); +// Assert.assertNull(value.getParent()); +// } +// +// @Test +// public void SingleUntypedArray_Reflective() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// AbstractClassifierInstance value = newDocumentation("s"); +// AbstractClassifierInstance values = new object[] { value }; +// Assert.assertThrows(IllegalArgumentException.class, () => +// parent.addChild(Geometry_documentation(), values)); +// Assert.assertNull(parent.getChildren(Geometry_documentation())); +// Assert.assertNull(value.getParent()); +// } +// +// @Test +// public void SingleUntypedList_Reflective() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// AbstractClassifierInstance value = newDocumentation("s"); +// AbstractClassifierInstance values = new ArrayList() { value }; +// Assert.assertThrows(IllegalArgumentException.class, () => +// parent.addChild(Geometry_documentation(), values)); +// Assert.assertNull(parent.getChildren(Geometry_documentation())); +// Assert.assertNull(value.getParent()); +// } +// +// @Test +// public void SingleListMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// AbstractClassifierInstance value = newDocumentation("s"); +// AbstractClassifierInstance values = new List() { value }; +// Assert.assertThrows(IllegalArgumentException.class, () => +// parent.addChild(Geometry_documentation(), values)); +// Assert.assertNull(parent.getChildren(Geometry_documentation())); +// Assert.assertNull(value.getParent()); +// } +// +// @Test +// public void SingleSet_Reflective() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// AbstractClassifierInstance value = newDocumentation("s"); +// AbstractClassifierInstance values = new HashSet() { value }; +// Assert.assertThrows(IllegalArgumentException.class, () => +// parent.addChild(Geometry_documentation(), values)); +// Assert.assertNull(parent.getChildren(Geometry_documentation())); +// Assert.assertNull(value.getParent()); +// } +// +// @Test +// public void SingleListNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// AbstractClassifierInstance value = newCoord("c"); +// AbstractClassifierInstance values = new List() { value }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addChild(Geometry_documentation(), values)); +// } +// +// @Test +// public void SingleUntypedListNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// AbstractClassifierInstance value = newCoord("c"); +// AbstractClassifierInstance values = new ArrayList() { value }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addChild(Geometry_documentation(), values)); +// } +// +// @Test +// public void SingleUntypedArrayNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// AbstractClassifierInstance value = newCoord("c"); +// AbstractClassifierInstance values = new object[] { value }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addChild(Geometry_documentation(), values)); +// } + +// #endregion + +// #region MultipleCollection + +// @Test +// public void MultipleArray_Reflective() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// AbstractClassifierInstance valueA = newDocumentation("sA"); +// AbstractClassifierInstance valueB = newDocumentation("sB"); +// AbstractClassifierInstance values = new DynamicNode[] { valueA, valueB }; +// Assert.assertThrows(IllegalArgumentException.class, () => +// parent.addChild(Geometry_documentation(), values)); +// Assert.assertNull(parent.getChildren(Geometry_documentation())); +// Assert.assertNull(valueA.getParent()); +// Assert.assertNull(valueB.getParent()); +// } +// +// @Test +// public void MultipleUntypedArray_Reflective() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// AbstractClassifierInstance valueA = newDocumentation("sA"); +// AbstractClassifierInstance valueB = newDocumentation("sB"); +// AbstractClassifierInstance values = new object[] { valueA, valueB }; +// Assert.assertThrows(IllegalArgumentException.class, () => +// parent.addChild(Geometry_documentation(), values)); +// Assert.assertNull(parent.getChildren(Geometry_documentation())); +// Assert.assertNull(valueA.getParent()); +// Assert.assertNull(valueB.getParent()); +// } +// +// @Test +// public void MultipleUntypedList_Reflective() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// AbstractClassifierInstance valueA = newDocumentation("sA"); +// AbstractClassifierInstance valueB = newDocumentation("sB"); +// AbstractClassifierInstance values = new ArrayList() { valueA, valueB }; +// Assert.assertThrows(IllegalArgumentException.class, () => +// parent.addChild(Geometry_documentation(), values)); +// Assert.assertNull(parent.getChildren(Geometry_documentation())); +// Assert.assertNull(valueA.getParent()); +// Assert.assertNull(valueB.getParent()); +// } +// +// @Test +// public void MultipleListMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// AbstractClassifierInstance valueA = newDocumentation("sA"); +// AbstractClassifierInstance valueB = newDocumentation("sB"); +// AbstractClassifierInstance values = new List() { valueA, valueB }; +// Assert.assertThrows(IllegalArgumentException.class, () => +// parent.addChild(Geometry_documentation(), values)); +// Assert.assertNull(parent.getChildren(Geometry_documentation())); +// Assert.assertNull(valueA.getParent()); +// Assert.assertNull(valueB.getParent()); +// } +// +// @Test +// public void MultipleSet_Reflective() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// AbstractClassifierInstance valueA = newDocumentation("sA"); +// AbstractClassifierInstance valueB = newDocumentation("sB"); +// AbstractClassifierInstance values = new HashSet() { valueA, valueB }; +// Assert.assertThrows(IllegalArgumentException.class, () => +// parent.addChild(Geometry_documentation(), values)); +// Assert.assertNull(parent.getChildren(Geometry_documentation())); +// Assert.assertNull(valueA.getParent()); +// Assert.assertNull(valueB.getParent()); +// } +// +// @Test +// public void MultipleListNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// AbstractClassifierInstance valueA = newCoord("cA"); +// AbstractClassifierInstance valueB = newCoord("cB"); +// AbstractClassifierInstance values = new List() { valueA, valueB }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addChild(Geometry_documentation(), values)); +// Assert.assertNull(parent.getChildren(Geometry_documentation())); +// Assert.assertNull(valueA.getParent()); +// Assert.assertNull(valueB.getParent()); +// } +// +// @Test +// public void MultipleUntypedListNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// AbstractClassifierInstance valueA = newCoord("cA"); +// AbstractClassifierInstance valueB = newCoord("cB"); +// AbstractClassifierInstance values = new ArrayList() { valueA, valueB }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addChild(Geometry_documentation(), values)); +// Assert.assertNull(parent.getChildren(Geometry_documentation())); +// Assert.assertNull(valueA.getParent()); +// Assert.assertNull(valueB.getParent()); +// } +// +// @Test +// public void MultipleUntypedArrayNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// AbstractClassifierInstance valueA = newCoord("cA"); +// AbstractClassifierInstance valueB = newCoord("cB"); +// AbstractClassifierInstance values = new object[] { valueA, valueB }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addChild(Geometry_documentation(), values)); +// Assert.assertNull(parent.getChildren(Geometry_documentation())); +// Assert.assertNull(valueA.getParent()); +// Assert.assertNull(valueB.getParent()); +// } + +// #endregion +} \ No newline at end of file diff --git a/core/src/test/java/lionweb/core/m2/dynamic/test/ContainmentTests_Single_Required.java b/core/src/test/java/lionweb/core/m2/dynamic/test/ContainmentTests_Single_Required.java new file mode 100644 index 00000000..a9feff68 --- /dev/null +++ b/core/src/test/java/lionweb/core/m2/dynamic/test/ContainmentTests_Single_Required.java @@ -0,0 +1,375 @@ +// Copyright 2024 TRUMPF Laser SE and other contributors +// +// 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. +// +// SPDX-FileCopyrightText: 2024 TRUMPF Laser SE and other contributors +// SPDX-License-Identifier: Apache-2.0 + +package lionweb.core.m2.dynamic.test; + +import io.lionweb.lioncore.java.model.Node; +import io.lionweb.lioncore.java.model.impl.AbstractClassifierInstance; +import org.junit.Assert; +import org.junit.Test; + +public class ContainmentTests_Single_Required extends DynamicNodeTestsBase +{ +// #region Single + + @Test + public void Single_Reflective() + { + AbstractClassifierInstance parent = newOffsetDuplicate("od"); + Node coord = newCoord("myId"); + parent.addChild(OffsetDuplicate_offset(), coord); + Assert.assertSame(parent, coord.getParent()); + Assert.assertSame(coord, parent.getChildren(OffsetDuplicate_offset())); + } + + @Test + public void Existing_Reflective() + { + Node oldCoord = newCoord("old"); + AbstractClassifierInstance parent = newOffsetDuplicate("g"); + parent.addChild(OffsetDuplicate_offset(), oldCoord); + Node coord = newCoord("myId"); + parent.addChild(OffsetDuplicate_offset(), coord); + Assert.assertNull(oldCoord.getParent()); + Assert.assertSame(parent, coord.getParent()); + Assert.assertSame(coord, parent.getChildren(OffsetDuplicate_offset())); + } + +// #endregion + +// #region Null + + @Test + public void Null_Reflective() + { + AbstractClassifierInstance parent = newOffsetDuplicate("od"); + Assert.assertThrows(IllegalArgumentException.class, + () -> parent.addChild(OffsetDuplicate_offset(), null)); + Assert.assertThrows(IllegalArgumentException.class, () -> parent.getChildren(OffsetDuplicate_offset())); + } + +// #endregion + +// #region EmptyCollection + +// @Test +// public void EmptyArray_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("od"); +// AbstractClassifierInstance values = new DynamicNode[0]; +// Assert.assertThrows(IllegalArgumentException.class, () => +// parent.addChild(OffsetDuplicate_offset(), values)); +// } +// +// @Test +// public void EmptyUntypedList_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("od"); +// AbstractClassifierInstance values = new ArrayList(); +// Assert.assertThrows(IllegalArgumentException.class, () => +// parent.addChild(OffsetDuplicate_offset(), values)); +// } +// +// @Test +// public void EmptyListMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("od"); +// AbstractClassifierInstance values = new List(); +// Assert.assertThrows(IllegalArgumentException.class, () => +// parent.addChild(OffsetDuplicate_offset(), values)); +// } +// +// @Test +// public void EmptySet_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("od"); +// AbstractClassifierInstance values = new HashSet(); +// Assert.assertThrows(IllegalArgumentException.class, () => +// parent.addChild(OffsetDuplicate_offset(), values)); +// } +// +// @Test +// public void EmptyListNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("od"); +// AbstractClassifierInstance values = new List(); +// Assert.assertThrows(IllegalArgumentException.class, () => +// parent.addChild(OffsetDuplicate_offset(), values)); +// } + +// #endregion + +// #region NullCollection + +// @Test +// public void NullArray_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("od"); +// AbstractClassifierInstance values = new DynamicNode[] { null }; +// Assert.assertThrows(IllegalArgumentException.class, () => +// parent.addChild(OffsetDuplicate_offset(), values)); +// } +// +// @Test +// public void NullUntypedList_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("od"); +// AbstractClassifierInstance values = new ArrayList() { null }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addChild(OffsetDuplicate_offset(), values)); +// } +// +// @Test +// public void NullListMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("od"); +// AbstractClassifierInstance values = new List() { null }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addChild(OffsetDuplicate_offset(), values)); +// } +// +// @Test +// public void NullListNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("od"); +// AbstractClassifierInstance values = new List() { null }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addChild(OffsetDuplicate_offset(), values)); +// } +// +// @Test +// public void NullSet_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("od"); +// AbstractClassifierInstance values = new HashSet() { null }; +// Assert.assertThrows(IllegalArgumentException.class, () => +// parent.addChild(OffsetDuplicate_offset(), values)); +// } + +// #endregion + +// #region SingleCollection + +// @Test +// public void SingleArray_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("od"); +// AbstractClassifierInstance value = newCoord("s"); +// AbstractClassifierInstance values = new DynamicNode[] { value }; +// +// Assert.assertThrows(IllegalArgumentException.class, () => +// parent.addChild(OffsetDuplicate_offset(), values)); +// Assert.assertThrows(IllegalArgumentException.class, () -> parent.getChildren(OffsetDuplicate_offset())); +// Assert.assertNull(value.getParent()); +// } +// +// @Test +// public void SingleUntypedArray_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("od"); +// AbstractClassifierInstance value = newCoord("s"); +// AbstractClassifierInstance values = new object[] { value }; +// Assert.assertThrows(IllegalArgumentException.class, () => +// parent.addChild(OffsetDuplicate_offset(), values)); +// Assert.assertThrows(IllegalArgumentException.class, () -> parent.getChildren(OffsetDuplicate_offset())); +// Assert.assertNull(value.getParent()); +// } +// +// @Test +// public void SingleUntypedList_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("od"); +// AbstractClassifierInstance value = newCoord("s"); +// AbstractClassifierInstance values = new ArrayList() { value }; +// Assert.assertThrows(IllegalArgumentException.class, () => +// parent.addChild(OffsetDuplicate_offset(), values)); +// Assert.assertThrows(IllegalArgumentException.class, () -> parent.getChildren(OffsetDuplicate_offset())); +// Assert.assertNull(value.getParent()); +// } +// +// @Test +// public void SingleListMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("od"); +// AbstractClassifierInstance value = newCoord("s"); +// AbstractClassifierInstance values = new List() { value }; +// Assert.assertThrows(IllegalArgumentException.class, () => +// parent.addChild(OffsetDuplicate_offset(), values)); +// Assert.assertThrows(IllegalArgumentException.class, () -> parent.getChildren(OffsetDuplicate_offset())); +// Assert.assertNull(value.getParent()); +// } +// +// @Test +// public void SingleSet_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("od"); +// AbstractClassifierInstance value = newCoord("s"); +// AbstractClassifierInstance values = new HashSet() { value }; +// Assert.assertThrows(IllegalArgumentException.class, () => +// parent.addChild(OffsetDuplicate_offset(), values)); +// Assert.assertThrows(IllegalArgumentException.class, () -> parent.getChildren(OffsetDuplicate_offset())); +// Assert.assertNull(value.getParent()); +// } +// +// @Test +// public void SingleListNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("od"); +// AbstractClassifierInstance value = newLine("c"); +// AbstractClassifierInstance values = new List() { value }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addChild(OffsetDuplicate_offset(), values)); +// } +// +// @Test +// public void SingleUntypedListNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("od"); +// AbstractClassifierInstance value = newCoord("c"); +// AbstractClassifierInstance values = new ArrayList() { value }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addChild(OffsetDuplicate_offset(), values)); +// } +// +// @Test +// public void SingleUntypedArrayNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("od"); +// AbstractClassifierInstance value = newCoord("c"); +// AbstractClassifierInstance values = new object[] { value }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addChild(OffsetDuplicate_offset(), values)); +// } + +// #endregion + +// #region MultipleCollection + +// @Test +// public void MultipleArray_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("od"); +// AbstractClassifierInstance valueA = newCoord("sA"); +// AbstractClassifierInstance valueB = newCoord("sB"); +// AbstractClassifierInstance values = new DynamicNode[] { valueA, valueB }; +// Assert.assertThrows(IllegalArgumentException.class, () => +// parent.addChild(OffsetDuplicate_offset(), values)); +// Assert.assertThrows(IllegalArgumentException.class, () -> parent.getChildren(OffsetDuplicate_offset())); +// Assert.assertNull(valueA.getParent()); +// Assert.assertNull(valueB.getParent()); +// } +// +// @Test +// public void MultipleUntypedArray_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("od"); +// AbstractClassifierInstance valueA = newCoord("sA"); +// AbstractClassifierInstance valueB = newCoord("sB"); +// AbstractClassifierInstance values = new object[] { valueA, valueB }; +// Assert.assertThrows(IllegalArgumentException.class, () => +// parent.addChild(OffsetDuplicate_offset(), values)); +// Assert.assertThrows(IllegalArgumentException.class, () -> parent.getChildren(OffsetDuplicate_offset())); +// Assert.assertNull(valueA.getParent()); +// Assert.assertNull(valueB.getParent()); +// } +// +// @Test +// public void MultipleUntypedList_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("od"); +// AbstractClassifierInstance valueA = newCoord("sA"); +// AbstractClassifierInstance valueB = newCoord("sB"); +// AbstractClassifierInstance values = new ArrayList() { valueA, valueB }; +// Assert.assertThrows(IllegalArgumentException.class, () => +// parent.addChild(OffsetDuplicate_offset(), values)); +// Assert.assertThrows(IllegalArgumentException.class, () -> parent.getChildren(OffsetDuplicate_offset())); +// Assert.assertNull(valueA.getParent()); +// Assert.assertNull(valueB.getParent()); +// } +// +// @Test +// public void MultipleListMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("od"); +// AbstractClassifierInstance valueA = newCoord("sA"); +// AbstractClassifierInstance valueB = newCoord("sB"); +// AbstractClassifierInstance values = new List() { valueA, valueB }; +// Assert.assertThrows(IllegalArgumentException.class, () => +// parent.addChild(OffsetDuplicate_offset(), values)); +// Assert.assertThrows(IllegalArgumentException.class, () -> parent.getChildren(OffsetDuplicate_offset())); +// Assert.assertNull(valueA.getParent()); +// Assert.assertNull(valueB.getParent()); +// } +// +// @Test +// public void MultipleSet_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("od"); +// AbstractClassifierInstance valueA = newCoord("sA"); +// AbstractClassifierInstance valueB = newCoord("sB"); +// AbstractClassifierInstance values = new HashSet() { valueA, valueB }; +// Assert.assertThrows(IllegalArgumentException.class, () => +// parent.addChild(OffsetDuplicate_offset(), values)); +// Assert.assertThrows(IllegalArgumentException.class, () -> parent.getChildren(OffsetDuplicate_offset())); +// Assert.assertNull(valueA.getParent()); +// Assert.assertNull(valueB.getParent()); +// } +// +// @Test +// public void MultipleListNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("od"); +// AbstractClassifierInstance valueA = newLine("cA"); +// AbstractClassifierInstance valueB = newLine("cB"); +// AbstractClassifierInstance values = new List() { valueA, valueB }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addChild(OffsetDuplicate_offset(), values)); +// Assert.assertThrows(IllegalArgumentException.class, () -> parent.getChildren(OffsetDuplicate_offset())); +// Assert.assertNull(valueA.getParent()); +// Assert.assertNull(valueB.getParent()); +// } +// +// @Test +// public void MultipleUntypedListNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("od"); +// AbstractClassifierInstance valueA = newLine("cA"); +// AbstractClassifierInstance valueB = newLine("cB"); +// AbstractClassifierInstance values = new ArrayList() { valueA, valueB }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addChild(OffsetDuplicate_offset(), values)); +// Assert.assertThrows(IllegalArgumentException.class, () -> parent.getChildren(OffsetDuplicate_offset())); +// Assert.assertNull(valueA.getParent()); +// Assert.assertNull(valueB.getParent()); +// } +// +// @Test +// public void MultipleUntypedArrayNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("od"); +// AbstractClassifierInstance valueA = newLine("cA"); +// AbstractClassifierInstance valueB = newLine("cB"); +// AbstractClassifierInstance values = new object[] { valueA, valueB }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addChild(OffsetDuplicate_offset(), values)); +// Assert.assertThrows(IllegalArgumentException.class, () -> parent.getChildren(OffsetDuplicate_offset())); +// Assert.assertNull(valueA.getParent()); +// Assert.assertNull(valueB.getParent()); +// } + +// #endregion +} \ No newline at end of file diff --git a/core/src/test/java/lionweb/core/m2/dynamic/test/DynamicNodeTestsBase.java b/core/src/test/java/lionweb/core/m2/dynamic/test/DynamicNodeTestsBase.java index 8eef96bd..aa4ea469 100644 --- a/core/src/test/java/lionweb/core/m2/dynamic/test/DynamicNodeTestsBase.java +++ b/core/src/test/java/lionweb/core/m2/dynamic/test/DynamicNodeTestsBase.java @@ -19,12 +19,14 @@ import examples.shapes.dynamic.ShapesDynamic; import io.lionweb.lioncore.java.language.*; +import io.lionweb.lioncore.java.model.Node; import io.lionweb.lioncore.java.model.impl.DynamicAnnotationInstance; import io.lionweb.lioncore.java.model.impl.DynamicClassifierInstance; import io.lionweb.lioncore.java.model.impl.DynamicNode; import io.lionweb.lioncore.java.serialization.Instantiator; import org.junit.Before; +import java.sql.Ref; import java.util.List; public abstract class DynamicNodeTestsBase { @@ -145,142 +147,149 @@ protected DynamicNode newMaterialGroup(String id) { return node; } - protected Feature ReferenceGeometry_shapes() { - return getFeatureByKey(getClassifierByKey("key-ReferenceGeometry"), "key-shapes-references"); + protected Reference ReferenceGeometry_shapes() { + return (Reference) getFeatureByKey(getClassifierByKey("key-ReferenceGeometry"), "key-shapes-references"); } protected Containment Geometry_shapes() { return (Containment) getFeatureByKey(getClassifierByKey("key-Geometry"), "key-shapes"); } - protected Feature CompositeShape_parts() { - return getFeatureByKey(getClassifierByKey("key-CompositeShape"), "key-parts"); + protected Containment CompositeShape_parts() { + return (Containment) getFeatureByKey(getClassifierByKey("key-CompositeShape"), "key-parts"); } - protected Feature CompositeShape_disabledParts() { - return getFeatureByKey(getClassifierByKey("key-CompositeShape"), "key-disabled-parts"); + protected Containment CompositeShape_disabledParts() { + return (Containment) getFeatureByKey(getClassifierByKey("key-CompositeShape"), "key-disabled-parts"); } - protected Feature CompositeShape_evilPart() { - return getFeatureByKey(getClassifierByKey("key-CompositeShape"), "key-evil-part"); + protected Containment CompositeShape_evilPart() { + return (Containment) getFeatureByKey(getClassifierByKey("key-CompositeShape"), "key-evil-part"); } - protected Feature Geometry_documentation() { - return getFeatureByKey(getClassifierByKey("key-Geometry"), "key-documentation"); + protected Containment Geometry_documentation() { + return (Containment) getFeatureByKey(getClassifierByKey("key-Geometry"), "key-documentation"); } - protected Feature OffsetDuplicate_offset() { - return getFeatureByKey(getClassifierByKey("key-OffsetDuplicate"), "key-offset"); + protected Containment OffsetDuplicate_offset() { + return (Containment) getFeatureByKey(getClassifierByKey("key-OffsetDuplicate"), "key-offset"); } - protected Feature Documentation_technical() + protected Property Documentation_technical() { - return getFeatureByKey(getClassifierByKey("key-Documentation"), "key-technical"); + return (Property) getFeatureByKey(getClassifierByKey("key-Documentation"), "key-technical"); } - protected Feature MaterialGroup_matterState() + protected Property MaterialGroup_matterState() { - return getFeatureByKey(getClassifierByKey("key-MaterialGroup"), "key-matter-state"); + return (Property) getFeatureByKey(getClassifierByKey("key-MaterialGroup"), "key-matter-state"); } - protected Feature MaterialGroup_defaultShape() + protected Containment MaterialGroup_defaultShape() { - return getFeatureByKey(getClassifierByKey("key-MaterialGroup"), "key-default-shape"); + return (Containment) getFeatureByKey(getClassifierByKey("key-MaterialGroup"), "key-default-shape"); } - protected Feature Circle_r() + protected Property Circle_r() { - return getFeatureByKey(getClassifierByKey("key-Circle"), "key-r"); + return (Property) getFeatureByKey(getClassifierByKey("key-Circle"), "key-r"); } - protected Feature Circle_center() + protected Containment Circle_center() { - return getFeatureByKey(getClassifierByKey("key-Circle"), "key-center"); + return (Containment) getFeatureByKey(getClassifierByKey("key-Circle"), "key-center"); } - protected Feature Line_start() + protected Containment Line_start() { - return getFeatureByKey(getClassifierByKey("key-Line"), "key-start"); + return (Containment) getFeatureByKey(getClassifierByKey("key-Line"), "key-start"); } - protected Feature Line_end() + protected Containment Line_end() { - return getFeatureByKey(getClassifierByKey("key-Line"), "key-end"); + return (Containment) getFeatureByKey(getClassifierByKey("key-Line"), "key-end"); } - protected Feature Documentation_text() + protected Property Documentation_text() { - return getFeatureByKey(getClassifierByKey("key-Documentation"), "key-text"); + return (Property) getFeatureByKey(getClassifierByKey("key-Documentation"), "key-text"); } - protected Feature MaterialGroup_materials() + protected Reference MaterialGroup_materials() { - return getFeatureByKey(getClassifierByKey("key-MaterialGroup"), "key-group-materials"); + return (Reference) getFeatureByKey(getClassifierByKey("key-MaterialGroup"), "key-group-materials"); } - protected Feature OffsetDuplicate_altSource() + protected Reference OffsetDuplicate_altSource() { - return getFeatureByKey(getClassifierByKey("key-OffsetDuplicate"), "key-alt-source"); + return (Reference) getFeatureByKey(getClassifierByKey("key-OffsetDuplicate"), "key-alt-source"); } - protected Feature OffsetDuplicate_source() + protected Reference OffsetDuplicate_source() { - return getFeatureByKey(getClassifierByKey("key-OffsetDuplicate"), "key-source"); + return (Reference) getFeatureByKey(getClassifierByKey("key-OffsetDuplicate"), "key-source"); } - protected Feature OffsetDuplicate_docs() + protected Containment OffsetDuplicate_docs() { - return getFeatureByKey(getClassifierByKey("key-OffsetDuplicate"), "key-docs"); + return (Containment) getFeatureByKey(getClassifierByKey("key-OffsetDuplicate"), "key-docs"); } - protected Feature OffsetDuplicate_secretDocs() + protected Containment OffsetDuplicate_secretDocs() { - return getFeatureByKey(getClassifierByKey("key-OffsetDuplicate"), "key-secret-docs"); + return (Containment) getFeatureByKey(getClassifierByKey("key-OffsetDuplicate"), "key-secret-docs"); } - protected Feature BillOfMaterials_groups() + protected Containment BillOfMaterials_groups() { - return getFeatureByKey(getClassifierByKey("key-BillOfMaterials"), "key-groups"); + return (Containment) getFeatureByKey(getClassifierByKey("key-BillOfMaterials"), "key-groups"); } - protected Feature BillOfMaterials_altGroups() + protected Containment BillOfMaterials_altGroups() { - return getFeatureByKey(getClassifierByKey("key-BillOfMaterials"), "key-alt-groups"); + return (Containment) getFeatureByKey(getClassifierByKey("key-BillOfMaterials"), "key-alt-groups"); } - protected Feature BillOfMaterials_defaultGroup() + protected Containment BillOfMaterials_defaultGroup() { - return getFeatureByKey(getClassifierByKey("key-BillOfMaterials"), "key-default-group"); + return (Containment) getFeatureByKey(getClassifierByKey("key-BillOfMaterials"), "key-default-group"); } - protected Feature Shape_shapeDocs() + protected Containment Shape_shapeDocs() { - return getFeatureByKey(getClassifierByKey("key-Shape"), "key-shape-docs"); + return (Containment) getFeatureByKey(getClassifierByKey("key-Shape"), "key-shape-docs"); } -// protected Enum MatterState_Gas() -// { + protected Enum MatterState_Gas() + { + return null; // return getGetFactory().GetEnumerationLiteral( // MatterState // .Literals // .First(l => l.Key == "key-gas") // ); -// } -// -// protected Enum MatterState_Liquid() -// { + } + + protected Enum MatterState_Liquid() + { + return null; // return getGetFactory().GetEnumerationLiteral( // MatterState // .Literals // .First(l => l.Key == "key-liquid") // ); -// } -// -// private Enumeration MatterState() { -// _lang -// .Enumerations() -// .First(e = > e.Key == "key-MatterState"); -// } + } + + private Enumeration MatterState() { + return _lang + .getElements() + .stream() + .filter(e -> e instanceof Enumeration) + .map(e -> (Enumeration) e) + .filter(e -> e.getKey().equals("key-MatterState")) + .findFirst() + .orElse(null); + } } diff --git a/core/src/test/java/lionweb/core/m2/dynamic/test/ParentHandlingTests.java b/core/src/test/java/lionweb/core/m2/dynamic/test/ParentHandlingTests.java new file mode 100644 index 00000000..9a94c353 --- /dev/null +++ b/core/src/test/java/lionweb/core/m2/dynamic/test/ParentHandlingTests.java @@ -0,0 +1,932 @@ +// Copyright 2024 TRUMPF Laser SE and other contributors +// +// 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. +// +// SPDX-FileCopyrightText: 2024 TRUMPF Laser SE and other contributors +// SPDX-License-Identifier: Apache-2.0 + +package lionweb.core.m2.dynamic.test; + +import com.google.common.collect.Lists; +import io.lionweb.lioncore.java.model.Node; +import io.lionweb.lioncore.java.model.impl.AbstractClassifierInstance; +import lionweb.utils.tests.CollectionAssert; +import org.junit.Assert; +import org.junit.Test; + +public class ParentHandlingTests extends DynamicNodeTestsBase +{ +// #region single + +// #region optional + +// #region SameInOtherInstance + +// @Test +// public void SingleOptional_SameInOtherInstance_Reflective() +// { +// Node child = newDocumentation("myId"); +// AbstractClassifierInstance source = newGeometry("src"); +// source.addChild(Geometry_documentation(), child); +// AbstractClassifierInstance target = newGeometry("tgt"); +// +// target.addChild(Geometry_documentation(), child); +// +// Assert.assertSame(target, child.getParent()); +// Assert.assertSame(child, target.getChildren(Geometry_documentation())); +// Assert.assertNull(source.getChildren(Geometry_documentation())); +// } + +// @Test +// public void SingleOptional_SameInOtherInstance_detach_Reflective() +// { +// Node child = newDocumentation("myId"); +// AbstractClassifierInstance source = newGeometry("src"); +// source.addChild(Geometry_documentation(), child); +// Node orphan = newDocumentation("o"); +// AbstractClassifierInstance target = newGeometry("tgt"); +// target.addChild(Geometry_documentation(), orphan); +// +// target.addChild(Geometry_documentation(), child); +// +// Assert.assertSame(target, child.getParent()); +// Assert.assertSame(child, target.getChildren(Geometry_documentation())); +// Assert.assertNull(source.getChildren(Geometry_documentation())); +// Assert.assertNull(orphan.getParent()); +// } + +// #endregion + +// #region other + +// @Test +// public void SingleOptional_Other_Reflective() +// { +// Node child = newDocumentation("myId"); +// AbstractClassifierInstance source = newGeometry("src"); +// source.addChild(Geometry_documentation(), child); +// AbstractClassifierInstance target = newOffsetDuplicate("tgt"); +// +// target.addChild(OffsetDuplicate_docs(), child); +// +// Assert.assertSame(target, child.getParent()); +// Assert.assertSame(child, target.getChildren(OffsetDuplicate_docs())); +// Assert.assertNull(source.getChildren(Geometry_documentation())); +// } + +// @Test +// public void SingleOptional_Other_detach_Reflective() +// { +// Node child = newDocumentation("myId"); +// AbstractClassifierInstance source = newGeometry("src"); +// source.addChild(Geometry_documentation(), child); +// Node orphan = newDocumentation("o"); +// AbstractClassifierInstance target = newOffsetDuplicate("tgt"); +// target.addChild(OffsetDuplicate_docs(), orphan); +// +// target.addChild(OffsetDuplicate_docs(), child); +// +// Assert.assertSame(target, child.getParent()); +// Assert.assertSame(child, target.getChildren(OffsetDuplicate_docs())); +// Assert.assertNull(source.getChildren(Geometry_documentation())); +// Assert.assertNull(orphan.getParent()); +// } + +// #endregion + +// #region otherInSameInstance + +// @Test +// public void SingleOptional_OtherInSameInstance_Reflective() +// { +// Node child = newDocumentation("myId"); +// AbstractClassifierInstance parent = newOffsetDuplicate("src"); +// parent.addChild(OffsetDuplicate_docs(), child); +// +// parent.addChild(OffsetDuplicate_secretDocs(), child); +// +// Assert.assertSame(parent, child.getParent()); +// Assert.assertSame(child, parent.getChildren(OffsetDuplicate_secretDocs())); +// Assert.assertNull(parent.getChildren(OffsetDuplicate_docs())); +// } + +// @Test +// public void SingleOptional_OtherInSameInstance_detach_Reflective() +// { +// Node child = newDocumentation("myId"); +// Node orphan = newDocumentation("o"); +// AbstractClassifierInstance parent = newOffsetDuplicate("src"); +// parent.addChild(OffsetDuplicate_docs(), child); +// parent.addChild(OffsetDuplicate_secretDocs(), orphan); +// +// parent.addChild(OffsetDuplicate_secretDocs(), child); +// +// Assert.assertSame(parent, child.getParent()); +// Assert.assertSame(child, parent.getChildren(OffsetDuplicate_secretDocs())); +// Assert.assertNull(parent.getChildren(OffsetDuplicate_docs())); +// Assert.assertNull(orphan.getParent()); +// } + +// #endregion + +// #region sameInSameInstance + +// @Test +// public void SingleOptional_SameInSameInstance_Reflective() +// { +// Node child = newDocumentation("myId"); +// AbstractClassifierInstance parent = newOffsetDuplicate("src"); +// parent.addChild(OffsetDuplicate_docs(), child); +// +// parent.addChild(OffsetDuplicate_docs(), child); +// +// Assert.assertSame(parent, child.getParent()); +// Assert.assertSame(child, parent.getChildren(OffsetDuplicate_docs())); +// } + +// #endregion + +// #region annotation + +// @Test +// public void SingleOptional_ToAnnotation() +// { +// Node child = newDocumentation("myId"); +// AbstractClassifierInstance source = newGeometry("src"); +// source.addChild(Geometry_documentation(), child); +// AbstractClassifierInstance target = newLine("tgt"); +// +// target.addAnnotation(child); +// +// Assert.assertSame(target, child.getParent()); +// Assert.assertTrue(target.getAnnotations().contains(child)); +// Assert.assertFalse(source.getAnnotations().contains(child)); +// } + +// @Test +// public void SingleOptional_ToAnnotation_Reflective() +// { +// Node child = newDocumentation("myId"); +// AbstractClassifierInstance source = newGeometry("src"); +// source.addChild(Geometry_documentation(), child); +// AbstractClassifierInstance target = newLine("tgt"); +// +// target.addChild(null, child); +// +// Assert.assertSame(target, child.getParent()); +// Assert.assertTrue(target.getAnnotations().contains(child)); +// Assert.assertFalse(source.getAnnotations().contains(child)); +// } + +// @Test +// public void Annotation_ToSingleOptional_Reflective() +// { +// Node child = newDocumentation("myId"); +// AbstractClassifierInstance source = newLine("src"); +// source.addAnnotation(child); +// AbstractClassifierInstance target = newGeometry("tgt"); +// +// target.addChild(Geometry_documentation(), child); +// +// Assert.assertSame(target, child.getParent()); +// Assert.assertFalse(source.getAnnotations().contains(child)); +// Assert.assertSame(child, target.getChildren(Geometry_documentation())); +// } + +// @Test +// public void Annotation_ToSingleOptional_detach_Reflective() +// { +// Node child = newDocumentation("myId"); +// Node orphan = newDocumentation("o"); +// AbstractClassifierInstance source = newLine("src"); +// source.addAnnotation(child); +// AbstractClassifierInstance target = newGeometry("tgt"); +// target.addChild(Geometry_documentation(), orphan); +// +// target.addChild(Geometry_documentation(), child); +// +// Assert.assertSame(target, child.getParent()); +// Assert.assertFalse(source.getAnnotations().contains(child)); +// Assert.assertSame(child, target.getChildren(Geometry_documentation())); +// Assert.assertNull(orphan.getParent()); +// } + +// #region sameInstance + +// @Test +// public void SingleOptional_ToAnnotation_SameInstance() +// { +// Node child = newDocumentation("myId"); +// AbstractClassifierInstance parent = newOffsetDuplicate("src"); +// parent.addChild(OffsetDuplicate_docs(), child); +// +// parent.addAnnotation(child); +// +// Assert.assertSame(parent, child.getParent()); +// Assert.assertTrue(parent.getAnnotations().contains(child)); +// Assert.assertNull(parent.getChildren(OffsetDuplicate_docs())); +// } + +// @Test +// public void SingleOptional_ToAnnotation_SameInstance_Reflective() +// { +// Node child = newDocumentation("myId"); +// AbstractClassifierInstance parent = newOffsetDuplicate("src"); +// parent.addChild(OffsetDuplicate_docs(), child); +// +// parent.addChild(null, child); +// +// Assert.assertSame(parent, child.getParent()); +// Assert.assertTrue(parent.getAnnotations().contains(child)); +// Assert.assertNull(parent.getChildren(OffsetDuplicate_docs())); +// } + +// @Test +// public void Annotation_ToSingleOptional_SameInstance_Reflective() +// { +// Node child = newDocumentation("myId"); +// AbstractClassifierInstance parent = newOffsetDuplicate("src"); +// parent.addAnnotation(child); +// +// parent.addChild(OffsetDuplicate_docs(), child); +// +// Assert.assertSame(parent, child.getParent()); +// Assert.assertFalse(parent.getAnnotations().contains(child)); +// Assert.assertSame(child, parent.getChildren(OffsetDuplicate_docs())); +// } + +// @Test +// public void Annotation_ToSingleOptional_SameInstance_detach_Reflective() +// { +// Node child = newDocumentation("myId"); +// Node orphan = newDocumentation("o"); +// AbstractClassifierInstance parent = newOffsetDuplicate("src"); +// parent.addChild(OffsetDuplicate_docs(), orphan); +// parent.addAnnotation(child); +// +// parent.addChild(OffsetDuplicate_docs(), child); +// +// Assert.assertSame(parent, child.getParent()); +// Assert.assertFalse(parent.getAnnotations().contains(child)); +// Assert.assertSame(child, parent.getChildren(OffsetDuplicate_docs())); +// Assert.assertNull(orphan.getParent()); +// } + +// #endregion + +// #endregion + +// #endregion + +// #region required + +// #region SameInOtherInstance + + @Test + public void SingleRequired_SameInOtherInstance_Reflective() + { + Node child = newCoord("myId"); + AbstractClassifierInstance source = newOffsetDuplicate("src"); + source.addChild(OffsetDuplicate_offset(), child); + AbstractClassifierInstance target = newOffsetDuplicate("tgt"); + + target.addChild(OffsetDuplicate_offset(), child); + + Assert.assertSame(target, child.getParent()); + Assert.assertSame(child, target.getChildren(OffsetDuplicate_offset())); + Assert.assertThrows(IllegalArgumentException.class, () -> source.getChildren(OffsetDuplicate_offset())); + } + + @Test + public void SingleRequired_SameInOtherInstance_detach_Reflective() + { + Node child = newCoord("myId"); + Node orphan = newCoord("o"); + AbstractClassifierInstance source = newOffsetDuplicate("src"); + source.addChild(OffsetDuplicate_offset(), child); + AbstractClassifierInstance target = newOffsetDuplicate("tgt"); + target.addChild(OffsetDuplicate_offset(), orphan); + + target.addChild(OffsetDuplicate_offset(), child); + + Assert.assertSame(target, child.getParent()); + Assert.assertSame(child, target.getChildren(OffsetDuplicate_offset())); + Assert.assertThrows(IllegalArgumentException.class, () -> source.getChildren(OffsetDuplicate_offset())); + Assert.assertNull(orphan.getParent()); + } + +// #endregion + +// #region other + + @Test + public void SingleRequired_Other_Reflective() + { + Node child = newCoord("myId"); + AbstractClassifierInstance source = newOffsetDuplicate("src"); + source.addChild(OffsetDuplicate_offset(), child); + AbstractClassifierInstance target = newCircle("tgt"); + + target.addChild(Circle_center(), child); + + Assert.assertSame(target, child.getParent()); + Assert.assertSame(child, target.getChildren(Circle_center())); + Assert.assertThrows(IllegalArgumentException.class, () -> source.getChildren(OffsetDuplicate_offset())); + } + + @Test + public void SingleRequired_Other_detach_Reflective() + { + Node child = newCoord("myId"); + Node orphan = newCoord("o"); + AbstractClassifierInstance source = newOffsetDuplicate("src"); + source.addChild(OffsetDuplicate_offset(), child); + AbstractClassifierInstance target = newCircle("tgt"); + target.addChild(Circle_center(), orphan); + + target.addChild(Circle_center(), child); + + Assert.assertSame(target, child.getParent()); + Assert.assertSame(child, target.getChildren(Circle_center())); + Assert.assertThrows(IllegalArgumentException.class, () -> source.getChildren(OffsetDuplicate_offset())); + Assert.assertNull(orphan.getParent()); + } + +// #endregion + +// #region SameInSameInstance + + @Test + public void SingleRequired_SameInSameInstance_Reflective() + { + Node child = newCoord("myId"); + AbstractClassifierInstance parent = newLine("src"); + parent.addChild(Line_start(), child); + + parent.addChild(Line_start(), child); + + Assert.assertSame(parent, child.getParent()); + Assert.assertSame(child, parent.getChildren(Line_start())); + } + +// #endregion + +// #region OtherInSameInstance + + @Test + public void SingleRequired_OtherInSameInstance_Reflective() + { + Node child = newCoord("myId"); + AbstractClassifierInstance parent = newLine("src"); + parent.addChild(Line_start(), child); + + parent.addChild(Line_end(), child); + + Assert.assertSame(parent, child.getParent()); + Assert.assertSame(child, parent.getChildren(Line_end())); + Assert.assertThrows(IllegalArgumentException.class, () -> parent.getChildren(Line_start())); + } + + @Test + public void SingleRequired_OtherInSameInstance_detach_Reflective() + { + Node child = newCoord("myId"); + Node orphan = newCoord("o"); + AbstractClassifierInstance parent = newLine("src"); + parent.addChild(Line_start(), child); + parent.addChild(Line_end(), orphan); + + parent.addChild(Line_end(), child); + + Assert.assertSame(parent, child.getParent()); + Assert.assertSame(child, parent.getChildren(Line_end())); + Assert.assertThrows(IllegalArgumentException.class, () -> parent.getChildren(Line_start())); + Assert.assertNull(orphan.getParent()); + } + +// #endregion + +// #endregion + +// #endregion + +// #region multiple + +// #region optional + +// #region singleEntry + +// #region SameInOtherInstance + + @Test + public void MultipleOptional_Single_SameInOtherInstance_Reflective() + { + Node child = newLine("myId"); + AbstractClassifierInstance source = newGeometry("src"); +// source.addChild(Geometry_shapes(), Lists.newArrayList( child }); + source.addChild(Geometry_shapes(), child); + AbstractClassifierInstance target = newGeometry("tgt"); + +// target.addChild(Geometry_shapes(), Lists.newArrayList( child }); + target.addChild(Geometry_shapes(), child); + + Assert.assertSame(target, child.getParent()); + CollectionAssert.AreEqual(Lists.newArrayList( child), target.getChildren(Geometry_shapes())); + Assert.assertEquals(0, (source.getChildren(Geometry_shapes())).size()); + } + +// #endregion + +// #region Other + +// @Test +// public void MultipleOptional_Single_Other_Reflective() +// { +// Node child = newLine("myId"); +// AbstractClassifierInstance source = newGeometry("src"); +// source.addChild(Geometry_shapes(), Lists.newArrayList( child }); +// AbstractClassifierInstance target = newCompositeShape("tgt"); +// +// target.addChild(CompositeShape_parts(), Lists.newArrayList( child }); +// +// Assert.assertSame(target, child.getParent()); +// CollectionAssert.AreEqual(Lists.newArrayList( child }, target.getChildren(CompositeShape_parts())); +// Assert.assertEquals(0, (source.getChildren(Geometry_shapes())).size()); +// } + +// #endregion + +// #region OtherInSameInstance + + @Test + public void MultipleOptional_Single_OtherInSameInstance_Reflective() + { + Node child = newMaterialGroup("myId"); + AbstractClassifierInstance parent = newBillOfMaterials("src"); + parent.addChild(BillOfMaterials_groups(), child); + + parent.addChild(BillOfMaterials_altGroups(), child); + + Assert.assertSame(parent, child.getParent()); + CollectionAssert.AreEqual(Lists.newArrayList( child ), parent.getChildren(BillOfMaterials_altGroups())); + Assert.assertEquals(0, (parent.getChildren(BillOfMaterials_groups())).size()); + } + +// #endregion + +// #region SameInSameInstance + + @Test + public void MultipleOptional_Single_SameInSameInstance_Reflective() + { + Node child = newMaterialGroup("myId"); + AbstractClassifierInstance parent = newBillOfMaterials("src"); + parent.addChild(BillOfMaterials_groups(), child); + + parent.addChild(BillOfMaterials_groups(), child); + + Assert.assertSame(parent, child.getParent()); + CollectionAssert.AreEqual(Lists.newArrayList( child ), parent.getChildren(BillOfMaterials_groups())); + } + +// #endregion + +// #endregion + +// #region someEntries + +// #region SameInOtherInstance + + @Test + public void MultipleOptional_Partial_SameInOtherInstance_Reflective() + { + Node childA = newLine("a"); + Node childB = newLine("b"); + AbstractClassifierInstance source = newGeometry("src"); +// source.addChild(Geometry_shapes(), Lists.newArrayList( childA,childB }); + source.addChild(Geometry_shapes(), childA); + source.addChild(Geometry_shapes(), childB); + AbstractClassifierInstance target = newGeometry("tgt"); + + target.addChild(Geometry_shapes(), childA); + + Assert.assertSame(target, childA.getParent()); + CollectionAssert.AreEqual(Lists.newArrayList( childA ), target.getChildren(Geometry_shapes())); + CollectionAssert.AreEqual(Lists.newArrayList( childB ), source.getChildren(Geometry_shapes())); + } + +// #endregion + +// #region Other + + @Test + public void MultipleOptional_Partial_Other_Reflective() + { + Node childA = newLine("a"); + Node childB = newLine("b"); + AbstractClassifierInstance source = newGeometry("src"); +// source.addChild(Geometry_shapes(), Lists.newArrayList( childA,childB }); + source.addChild(Geometry_shapes(),childA); + source.addChild(Geometry_shapes(),childB); + AbstractClassifierInstance target = newCompositeShape("tgt"); + + target.addChild(CompositeShape_parts(), childA); + + Assert.assertSame(target, childA.getParent()); + CollectionAssert.AreEqual(Lists.newArrayList( childA ), target.getChildren(CompositeShape_parts())); + CollectionAssert.AreEqual(Lists.newArrayList( childB ), source.getChildren(Geometry_shapes())); + } + +// #endregion + +// #region OtherInSameInstance + + @Test + public void MultipleOptional_Partial_OtherInSameInstance_Reflective() + { + Node childA = newMaterialGroup("a"); + Node childB = newMaterialGroup("b"); + AbstractClassifierInstance parent = newBillOfMaterials("src"); +// parent.addChild(BillOfMaterials_groups(), Lists.newArrayList( childA, childB }); + parent.addChild(BillOfMaterials_groups(), childA); + parent.addChild(BillOfMaterials_groups(), childB); + + parent.addChild(BillOfMaterials_altGroups(), childA); + + Assert.assertSame(parent, childA.getParent()); + CollectionAssert.AreEqual(Lists.newArrayList( childA ), parent.getChildren(BillOfMaterials_altGroups())); + CollectionAssert.AreEqual(Lists.newArrayList( childB ), parent.getChildren(BillOfMaterials_groups())); + } + +// #endregion + +// #region SameInSameInstance + + @Test + public void MultipleOptional_Partial_SameInSameInstance_Reflective() + { + Node childA = newMaterialGroup("myId"); + Node childB = newMaterialGroup("b"); + AbstractClassifierInstance parent = newBillOfMaterials("src"); +// parent.addChild(BillOfMaterials_groups(), Lists.newArrayList( childA, childA }); + parent.addChild(BillOfMaterials_groups(), childA); + parent.addChild(BillOfMaterials_groups(), childA); + + parent.addChild(BillOfMaterials_groups(), childA); + + Assert.assertSame(parent, childA.getParent()); + CollectionAssert.AreEqual(Lists.newArrayList( childA ), parent.getChildren(BillOfMaterials_groups())); + } + +// #endregion + +// #endregion + +// #region FromSingle + +// #region Other + + @Test + public void MultipleOptional_FromSingle_Other_Reflective() + { + Node child = newLine("myId"); + AbstractClassifierInstance source = newMaterialGroup("src"); + source.addChild(MaterialGroup_defaultShape(), child); + AbstractClassifierInstance target = newGeometry("tgt"); + + target.addChild(Geometry_shapes(), child); + + Assert.assertSame(target, child.getParent()); + CollectionAssert.AreEqual(Lists.newArrayList( child ), target.getChildren(Geometry_shapes())); + Assert.assertNull(source.getChildren(MaterialGroup_defaultShape())); + } + +// #endregion + +// #region OtherInSameInstance + + @Test + public void MultipleOptional_FromSingle_OtherInSameInstance_Reflective() + { + Node child = newMaterialGroup("myId"); + AbstractClassifierInstance parent = newBillOfMaterials("src"); + parent.addChild(BillOfMaterials_defaultGroup(), child); + + parent.addChild(BillOfMaterials_altGroups(), child); + + Assert.assertSame(parent, child.getParent()); + CollectionAssert.AreEqual(Lists.newArrayList( child ), parent.getChildren(BillOfMaterials_altGroups())); + Assert.assertNull(parent.getChildren(BillOfMaterials_defaultGroup())); + } + +// #endregion + +// #endregion + +// #region ToSingle + +// #region Other + + @Test + public void MultipleOptional_ToSingle_Other_Reflective() + { + Node child = newLine("myId"); + AbstractClassifierInstance source = newGeometry("src"); + source.addChild(Geometry_shapes(), child); + AbstractClassifierInstance target = newMaterialGroup("tgt"); + + target.addChild(MaterialGroup_defaultShape(), child); + + Assert.assertSame(target, child.getParent()); + Assert.assertSame(child, target.getChildren(MaterialGroup_defaultShape())); + Assert.assertEquals(0, (source.getChildren(Geometry_shapes())).size()); + } + +// #endregion + +// #region OtherInSameInstance + + @Test + public void MultipleOptional_ToSingle_OtherInSameInstance_Reflective() + { + Node child = newMaterialGroup("myId"); + AbstractClassifierInstance parent = newBillOfMaterials("src"); + parent.addChild(BillOfMaterials_altGroups(), child); + + parent.addChild(BillOfMaterials_defaultGroup(), child); + + Assert.assertSame(parent, child.getParent()); + Assert.assertSame(child, parent.getChildren(BillOfMaterials_defaultGroup())); + Assert.assertEquals(0, (parent.getChildren(BillOfMaterials_altGroups())).size()); + } + +// #endregion + +// #endregion + +// #endregion + +// #region required + +// #region singleEntry + +// #region SameInOtherInstance + + @Test + public void MultipleRequired_Single_SameInOtherInstance_Reflective() + { + Node child = newLine("myId"); + AbstractClassifierInstance source = newCompositeShape("src"); + source.addChild(CompositeShape_parts(), child); + AbstractClassifierInstance target = newCompositeShape("tgt"); + + target.addChild(CompositeShape_parts(), child); + + Assert.assertSame(target, child.getParent()); + CollectionAssert.AreEqual(Lists.newArrayList( child ), target.getChildren(CompositeShape_parts())); + Assert.assertThrows(IllegalArgumentException.class, () -> (source.getChildren(CompositeShape_parts())).size()); + } + +// #endregion + +// #region Other + + @Test + public void MultipleRequired_Single_Other_Reflective() + { + Node child = newLine("myId"); + AbstractClassifierInstance source = newCompositeShape("src"); + source.addChild(CompositeShape_parts(), child); + AbstractClassifierInstance target = newGeometry("tgt"); + + target.addChild(Geometry_shapes(), child); + + Assert.assertSame(target, child.getParent()); + CollectionAssert.AreEqual(Lists.newArrayList( child ), target.getChildren(Geometry_shapes())); + Assert.assertThrows(IllegalArgumentException.class, () -> (source.getChildren(CompositeShape_parts())).size()); + } + +// #endregion + +// #region OtherInSameInstance + + @Test + public void MultipleRequired_Single_OtherInSameInstance_Reflective() + { + Node child = newLine("myId"); + AbstractClassifierInstance parent = newCompositeShape("src"); + parent.addChild(CompositeShape_parts(), child); + + parent.addChild(CompositeShape_disabledParts(), child); + + Assert.assertSame(parent, child.getParent()); + CollectionAssert.AreEqual(Lists.newArrayList( child ), parent.getChildren(CompositeShape_disabledParts())); + Assert.assertThrows(IllegalArgumentException.class, () -> (parent.getChildren(CompositeShape_parts())).size()); + } + +// #endregion + +// #region SameInSameInstance + + @Test + public void MultipleRequired_Single_SameInSameInstance_Reflective() + { + Node child = newLine("myId"); + AbstractClassifierInstance parent = newCompositeShape("src"); + parent.addChild(CompositeShape_parts(), child); + + parent.addChild(CompositeShape_parts(), child); + + Assert.assertSame(parent, child.getParent()); + CollectionAssert.AreEqual(Lists.newArrayList( child ), parent.getChildren(CompositeShape_parts())); + } + +// #endregion + +// #endregion + +// #region someEntries + +// #region SameInOtherInstance + + @Test + public void MultipleRequired_Partial_SameInOtherInstance_Reflective() + { + Node childA = newLine("a"); + Node childB = newLine("b"); + AbstractClassifierInstance source = newCompositeShape("src"); +// source.addChild(CompositeShape_parts(), Lists.newArrayList( childA, childB }); + source.addChild(CompositeShape_parts(), childA); + source.addChild(CompositeShape_parts(), childB); + AbstractClassifierInstance target = newCompositeShape("tgt"); + + target.addChild(CompositeShape_parts(), childA); + + Assert.assertSame(target, childA.getParent()); + CollectionAssert.AreEqual(Lists.newArrayList( childA ), target.getChildren(CompositeShape_parts())); + CollectionAssert.AreEqual(Lists.newArrayList( childB ), source.getChildren(CompositeShape_parts())); + } + +// #endregion + +// #region Other + + @Test + public void MultipleRequired_Partial_Other_Reflective() + { + Node childA = newLine("a"); + Node childB = newLine("b"); + AbstractClassifierInstance source = newCompositeShape("src"); +// source.addChild(CompositeShape_parts(), Lists.newArrayList( childA,childB }); + source.addChild(CompositeShape_parts(), childA); + source.addChild(CompositeShape_parts(), childB); + AbstractClassifierInstance target = newGeometry("tgt"); + + target.addChild(Geometry_shapes(), childA); + + Assert.assertSame(target, childA.getParent()); + CollectionAssert.AreEqual(Lists.newArrayList( childA ), target.getChildren(Geometry_shapes())); + CollectionAssert.AreEqual(Lists.newArrayList( childB ), source.getChildren(CompositeShape_parts())); + } + +// #endregion + +// #region OtherInSameInstance + + @Test + public void MultipleRequired_Partial_OtherInSameInstance_Reflective() + { + Node childA = newLine("a"); + Node childB = newLine("b"); + AbstractClassifierInstance parent = newCompositeShape("src"); +// parent.addChild(CompositeShape_parts(), Lists.newArrayList( childA,childB }); + parent.addChild(CompositeShape_parts(), childA); + parent.addChild(CompositeShape_parts(), childB); + + parent.addChild(CompositeShape_disabledParts(), childA); + + Assert.assertSame(parent, childA.getParent()); + CollectionAssert.AreEqual(Lists.newArrayList( childA ), parent.getChildren(CompositeShape_disabledParts())); + CollectionAssert.AreEqual(Lists.newArrayList( childB ), parent.getChildren(CompositeShape_parts())); + } + +// #endregion + +// #region SameInSameInstance + + @Test + public void MultipleRequired_Partial_SameInSameInstance_Reflective() + { + Node childA = newLine("myId"); + Node childB = newLine("b"); + AbstractClassifierInstance parent = newCompositeShape("src"); +// parent.addChild(CompositeShape_parts(), Lists.newArrayList( childA, childB }); + parent.addChild(CompositeShape_parts(), childA); + parent.addChild(CompositeShape_parts(), childB); + + parent.addChild(CompositeShape_parts(), childA); + + Assert.assertSame(parent, childA.getParent()); + CollectionAssert.AreEqual(Lists.newArrayList( childA ), parent.getChildren(CompositeShape_parts())); + } + +// #endregion + +// #endregion + +// #region FromSingle + +// #region Other + + @Test + public void MultipleRequired_FromSingle_Other_Reflective() + { + Node child = newLine("myId"); + AbstractClassifierInstance source = newCompositeShape("src"); + source.addChild(CompositeShape_evilPart(), child); + AbstractClassifierInstance target = newGeometry("tgt"); + + target.addChild(Geometry_shapes(), child); + + Assert.assertSame(target, child.getParent()); + CollectionAssert.AreEqual(Lists.newArrayList( child ), target.getChildren(Geometry_shapes())); + Assert.assertThrows(IllegalArgumentException.class, () -> source.getChildren(CompositeShape_evilPart())); + } + +// #endregion + +// #region OtherInSameInstance + + @Test + public void MultipleRequired_FromSingle_OtherInSameInstance_Reflective() + { + Node child = newLine("myId"); + AbstractClassifierInstance parent = newCompositeShape("src"); + parent.addChild(CompositeShape_evilPart(), child); + + parent.addChild(CompositeShape_parts(), child); + + Assert.assertSame(parent, child.getParent()); + CollectionAssert.AreEqual(Lists.newArrayList( child ), parent.getChildren(CompositeShape_parts())); + Assert.assertThrows(IllegalArgumentException.class, () -> parent.getChildren(CompositeShape_evilPart())); + } + +// #endregion + +// #endregion + +// #region ToSingle + +// #region Other + + @Test + public void MultipleRequired_ToSingle_Other_Reflective() + { + Node child = newLine("myId"); + AbstractClassifierInstance source = newGeometry("src"); + source.addChild(Geometry_shapes(), child); + AbstractClassifierInstance target = newCompositeShape("tgt"); + + target.addChild(CompositeShape_evilPart(), child); + + Assert.assertSame(target, child.getParent()); + Assert.assertSame(child, target.getChildren(CompositeShape_evilPart())); + Assert.assertEquals(0, (source.getChildren(Geometry_shapes())).size()); + } + +// #endregion + +// #region OtherInSameInstance + + @Test + public void MultipleRequired_ToSingle_OtherInSameInstance_Reflective() + { + Node child = newLine("myId"); + AbstractClassifierInstance parent = newCompositeShape("src"); + parent.addChild(CompositeShape_parts(), child); + + parent.addChild(CompositeShape_evilPart(), child); + + Assert.assertSame(parent, child.getParent()); + Assert.assertSame(child, parent.getChildren(CompositeShape_evilPart())); + Assert.assertThrows(IllegalArgumentException.class, () -> parent.getChildren(CompositeShape_parts())); + } + +// #endregion + +// #endregion + +// #endregion + +// #endregion +} \ No newline at end of file diff --git a/core/src/test/java/lionweb/core/m2/dynamic/test/PropertyTests_Boolean_Optional.java b/core/src/test/java/lionweb/core/m2/dynamic/test/PropertyTests_Boolean_Optional.java new file mode 100644 index 00000000..7f51e7b2 --- /dev/null +++ b/core/src/test/java/lionweb/core/m2/dynamic/test/PropertyTests_Boolean_Optional.java @@ -0,0 +1,95 @@ +// Copyright 2024 TRUMPF Laser SE and other contributors +// +// 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. +// +// SPDX-FileCopyrightText: 2024 TRUMPF Laser SE and other contributors +// SPDX-License-Identifier: Apache-2.0 + +package lionweb.core.m2.dynamic.test; + +import io.lionweb.lioncore.java.model.impl.AbstractClassifierInstance; +import org.junit.Assert; +import org.junit.Test; + +public class PropertyTests_Boolean_Optional extends DynamicNodeTestsBase +{ +// #region Single + + @Test + public void Reflective() + { + AbstractClassifierInstance parent = newDocumentation("od"); + boolean value = true; + parent.setPropertyValue(Documentation_technical(), value); + Assert.assertEquals(true, parent.getPropertyValue(Documentation_technical())); + } + + @Test + public void Get_Reflective() + { + AbstractClassifierInstance parent = newDocumentation("od"); + parent.setPropertyValue(Documentation_technical(), true); + Assert.assertEquals(true, parent.getPropertyValue(Documentation_technical())); + } + + @Test + public void False_Reflective() + { + AbstractClassifierInstance parent = newDocumentation("od"); + boolean value = false; + parent.setPropertyValue(Documentation_technical(), value); + Assert.assertEquals(false, parent.getPropertyValue(Documentation_technical())); + } + + @Test + public void String_Reflective() + { + AbstractClassifierInstance parent = newDocumentation("od"); + String value = "10"; + Assert.assertThrows(IllegalArgumentException.class, () -> + parent.setPropertyValue(Documentation_technical(), value)); + Assert.assertEquals(null, parent.getPropertyValue(Documentation_technical())); + } + + @Test + public void Integer_Reflective() + { + AbstractClassifierInstance parent = newDocumentation("od"); + int value = 10; + Assert.assertThrows(IllegalArgumentException.class, () -> + parent.setPropertyValue(Documentation_technical(), value)); + Assert.assertEquals(null, parent.getPropertyValue(Documentation_technical())); + } + +// #endregion + +// #region Null + + @Test + public void Null_Reflective() + { + AbstractClassifierInstance parent = newDocumentation("od"); + Object value = null; + parent.setPropertyValue(Documentation_technical(), null); + Assert.assertEquals(null, parent.getPropertyValue(Documentation_technical())); + } + + @Test + public void Null_Get_Reflective() + { + AbstractClassifierInstance parent = newDocumentation("od"); + Assert.assertEquals(null, parent.getPropertyValue(Documentation_technical())); + } + +// #endregion +} \ No newline at end of file diff --git a/core/src/test/java/lionweb/core/m2/dynamic/test/PropertyTests_Enum_Optional.java b/core/src/test/java/lionweb/core/m2/dynamic/test/PropertyTests_Enum_Optional.java new file mode 100644 index 00000000..e42873a0 --- /dev/null +++ b/core/src/test/java/lionweb/core/m2/dynamic/test/PropertyTests_Enum_Optional.java @@ -0,0 +1,127 @@ +// Copyright 2024 TRUMPF Laser SE and other contributors +// +// 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. +// +// SPDX-FileCopyrightText: 2024 TRUMPF Laser SE and other contributors +// SPDX-License-Identifier: Apache-2.0 + +package lionweb.core.m2.dynamic.test; + +import io.lionweb.lioncore.java.model.impl.AbstractClassifierInstance; +import org.junit.Assert; +import org.junit.Test; + +public class PropertyTests_Enum_Optional extends DynamicNodeTestsBase +{ +// #region Single + + @Test + public void Reflective() + { + AbstractClassifierInstance parent = newMaterialGroup("od"); + Enum value = MatterState_Liquid(); + parent.setPropertyValue(MaterialGroup_matterState(), value); + Assert.assertEquals(MatterState_Liquid(), parent.getPropertyValue(MaterialGroup_matterState())); + } + + @Test + public void Get_Reflective() + { + AbstractClassifierInstance parent = newMaterialGroup("od"); + parent.setPropertyValue(MaterialGroup_matterState(), MatterState_Liquid()); + Assert.assertEquals(MatterState_Liquid(), parent.getPropertyValue(MaterialGroup_matterState())); + } + + @Test + public void Gas_Reflective() + { + AbstractClassifierInstance parent = newMaterialGroup("od"); + Enum value = MatterState_Gas(); + parent.setPropertyValue(MaterialGroup_matterState(), value); + Assert.assertEquals(MatterState_Gas(), parent.getPropertyValue(MaterialGroup_matterState())); + } + + @Test + public void Boolean_Reflective() + { + AbstractClassifierInstance parent = newMaterialGroup("od"); + boolean value = true; + Assert.assertThrows(IllegalArgumentException.class, () -> parent.setPropertyValue(MaterialGroup_matterState(), value)); + Assert.assertEquals(null, parent.getPropertyValue(MaterialGroup_matterState())); + } + + private enum TestEnum + { + a, + solid, + gas + } + + @Test + public void OtherEnum_Reflective() + { + AbstractClassifierInstance parent = newMaterialGroup("od"); + TestEnum value = TestEnum.a; + Assert.assertThrows(IllegalArgumentException.class, () -> parent.setPropertyValue(MaterialGroup_matterState(), value)); + Assert.assertEquals(null, parent.getPropertyValue(MaterialGroup_matterState())); + } + + @Test + public void SimilarEnum_Reflective() + { + AbstractClassifierInstance parent = newMaterialGroup("od"); + TestEnum value = TestEnum.solid; + Assert.assertThrows(IllegalArgumentException.class, () -> parent.setPropertyValue(MaterialGroup_matterState(), value)); + Assert.assertEquals(null, parent.getPropertyValue(MaterialGroup_matterState())); + } + + @Test + public void VerySimilarEnum_Reflective() + { + AbstractClassifierInstance parent = newMaterialGroup("od"); + TestEnum value = TestEnum.gas; + Assert.assertThrows(IllegalArgumentException.class, () -> parent.setPropertyValue(MaterialGroup_matterState(), value)); + Assert.assertEquals(null, parent.getPropertyValue(MaterialGroup_matterState())); + } + + @Test + public void Integer_Reflective() + { + AbstractClassifierInstance parent = newMaterialGroup("od"); + int value = 10; + Assert.assertThrows(IllegalArgumentException.class, () -> parent.setPropertyValue(MaterialGroup_matterState(), value)); + Assert.assertEquals(null, parent.getPropertyValue(MaterialGroup_matterState())); + } + +// #endregion + +// #region Null + + @Test + public void Null_Reflective() + { + AbstractClassifierInstance parent = newMaterialGroup("od"); + Object value = null; + parent.setPropertyValue(MaterialGroup_matterState(), null); + Assert.assertEquals(null, parent.getPropertyValue(MaterialGroup_matterState())); + } + + @Test + public void Null_Get_Reflective() + { + AbstractClassifierInstance parent = newMaterialGroup("od"); + Assert.assertEquals(null, parent.getPropertyValue(MaterialGroup_matterState())); + } + +// #endregion +} \ No newline at end of file diff --git a/core/src/test/java/lionweb/core/m2/dynamic/test/PropertyTests_Integer_Required.java b/core/src/test/java/lionweb/core/m2/dynamic/test/PropertyTests_Integer_Required.java new file mode 100644 index 00000000..f01b4d2d --- /dev/null +++ b/core/src/test/java/lionweb/core/m2/dynamic/test/PropertyTests_Integer_Required.java @@ -0,0 +1,94 @@ +// Copyright 2024 TRUMPF Laser SE and other contributors +// +// 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. +// +// SPDX-FileCopyrightText: 2024 TRUMPF Laser SE and other contributors +// SPDX-License-Identifier: Apache-2.0 + +package lionweb.core.m2.dynamic.test; + +import io.lionweb.lioncore.java.model.impl.AbstractClassifierInstance; +import org.junit.Assert; +import org.junit.Test; + +public class PropertyTests_Integer_Required extends DynamicNodeTestsBase +{ +// #region Single + + @Test + public void Reflective() + { + AbstractClassifierInstance parent = newCircle("od"); + int value = 10; + parent.setPropertyValue(Circle_r(), value); + Assert.assertEquals(10, parent.getPropertyValue(Circle_r())); + } + + @Test + public void Get_Reflective() + { + AbstractClassifierInstance parent = newCircle("od"); + parent.setPropertyValue(Circle_r(), 10); + Assert.assertEquals(10, parent.getPropertyValue(Circle_r())); + } + + @Test + public void Long_Reflective() + { + AbstractClassifierInstance parent = newCircle("od"); + long value = 10L; + Assert.assertThrows(IllegalArgumentException.class, () -> parent.setPropertyValue(Circle_r(), value)); + Assert.assertThrows(IllegalArgumentException.class, () -> parent.getPropertyValue(Circle_r())); + } + + @Test + public void String_Reflective() + { + AbstractClassifierInstance parent = newCircle("od"); + String value = "10"; + Assert.assertThrows(IllegalArgumentException.class, () -> parent.setPropertyValue(Circle_r(), value)); + Assert.assertThrows(IllegalArgumentException.class, () -> parent.getPropertyValue(Circle_r())); + } + + @Test + public void Boolean_Reflective() + { + AbstractClassifierInstance parent = newCircle("od"); + boolean value = true; + Assert.assertThrows(IllegalArgumentException.class, () -> parent.setPropertyValue(Circle_r(), value)); + Assert.assertThrows(IllegalArgumentException.class, () -> parent.getPropertyValue(Circle_r())); + } + +// #endregion + +// #region Null + + @Test + public void Null_Reflective() + { + AbstractClassifierInstance parent = newCircle("od"); + Object value = null; + Assert.assertThrows(IllegalArgumentException.class, + () -> parent.setPropertyValue(Circle_r(), value)); + Assert.assertThrows(IllegalArgumentException.class, () -> parent.getPropertyValue(Circle_r())); + } + + @Test + public void Null_Get_Reflective() + { + AbstractClassifierInstance parent = newCircle("od"); + Assert.assertThrows(IllegalArgumentException.class, () -> parent.getPropertyValue(Circle_r())); + } + +// #endregion +} \ No newline at end of file diff --git a/core/src/test/java/lionweb/core/m2/dynamic/test/PropertyTests_String_Optional.java b/core/src/test/java/lionweb/core/m2/dynamic/test/PropertyTests_String_Optional.java new file mode 100644 index 00000000..3a50d1b6 --- /dev/null +++ b/core/src/test/java/lionweb/core/m2/dynamic/test/PropertyTests_String_Optional.java @@ -0,0 +1,93 @@ +// Copyright 2024 TRUMPF Laser SE and other contributors +// +// 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. +// +// SPDX-FileCopyrightText: 2024 TRUMPF Laser SE and other contributors +// SPDX-License-Identifier: Apache-2.0 + +package lionweb.core.m2.dynamic.test; + +import io.lionweb.lioncore.java.model.impl.AbstractClassifierInstance; +import org.junit.Assert; +import org.junit.Test; + +public class PropertyTests_String_Optional extends DynamicNodeTestsBase +{ +// #region Single + + @Test + public void Reflective() + { + AbstractClassifierInstance parent = newDocumentation("od"); + String value = "Hi"; + parent.setPropertyValue(Documentation_text(), value); + Assert.assertEquals("Hi", parent.getPropertyValue(Documentation_text())); + } + + @Test + public void Get_Reflective() + { + AbstractClassifierInstance parent = newDocumentation("od"); + parent.setPropertyValue(Documentation_text(), "Hi"); + Assert.assertEquals("Hi", parent.getPropertyValue(Documentation_text())); + } + + @Test + public void Bye_Reflective() + { + AbstractClassifierInstance parent = newDocumentation("od"); + String value = "Bye"; + parent.setPropertyValue(Documentation_text(), value); + Assert.assertEquals("Bye", parent.getPropertyValue(Documentation_text())); + } + + @Test + public void Boolean_Reflective() + { + AbstractClassifierInstance parent = newDocumentation("od"); + boolean value = true; + Assert.assertThrows(IllegalArgumentException.class, () -> parent.setPropertyValue(Documentation_text(), value)); + Assert.assertEquals(null, parent.getPropertyValue(Documentation_text())); + } + + @Test + public void Integer_Reflective() + { + AbstractClassifierInstance parent = newDocumentation("od"); + int value = 10; + Assert.assertThrows(IllegalArgumentException.class, () -> parent.setPropertyValue(Documentation_text(), value)); + Assert.assertEquals(null, parent.getPropertyValue(Documentation_text())); + } + +// #endregion + +// #region Null + + @Test + public void Null_Reflective() + { + AbstractClassifierInstance parent = newDocumentation("od"); + Object value = null; + parent.setPropertyValue(Documentation_text(), null); + Assert.assertEquals(null, parent.getPropertyValue(Documentation_text())); + } + + @Test + public void Null_Get_Reflective() + { + AbstractClassifierInstance parent = newDocumentation("od"); + Assert.assertEquals(null, parent.getPropertyValue(Documentation_text())); + } + +// #endregion +} \ No newline at end of file diff --git a/core/src/test/java/lionweb/core/m2/dynamic/test/ReferenceTests_Multiple_Optional.java b/core/src/test/java/lionweb/core/m2/dynamic/test/ReferenceTests_Multiple_Optional.java new file mode 100644 index 00000000..6fc29950 --- /dev/null +++ b/core/src/test/java/lionweb/core/m2/dynamic/test/ReferenceTests_Multiple_Optional.java @@ -0,0 +1,445 @@ +// Copyright 2024 TRUMPF Laser SE and other contributors +// +// 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. +// +// SPDX-FileCopyrightText: 2024 TRUMPF Laser SE and other contributors +// SPDX-License-Identifier: Apache-2.0 + +package lionweb.core.m2.dynamic.test; + +import io.lionweb.lioncore.java.model.impl.AbstractClassifierInstance; +import org.junit.Assert; +import org.junit.Test; + +public class ReferenceTests_Multiple_Optional extends DynamicNodeTestsBase +{ +//// #region Single +// +// @Test +// public void Single_Reflective() +// { +// AbstractClassifierInstance parent = newReferenceGeometry("g"); +// AbstractClassifierInstance line = newLine("myId"); +// Assert.assertThrows(IllegalArgumentException.class, () -> +// parent.addReferenceValue(ReferenceGeometry_shapes(), line)); +// Assert.assertNull(line.getParent()); +// Assert.assertFalse((parent.getReferenceValues(ReferenceGeometry_shapes()).contains(line)); +// } +// +//// #endregion +// +//// #region Null +// +// @Test +// public void Null_Reflective() +// { +// AbstractClassifierInstance parent = newReferenceGeometry("g"); +// Assert.assertThrows(IllegalArgumentException.class, () -> +// parent.addReferenceValue(ReferenceGeometry_shapes(), null)); +// } +// +//// #endregion +// +//// #region EmptyCollection +// +// @Test +// public void EmptyArray_Reflective() +// { +// AbstractClassifierInstance parent = newReferenceGeometry("g"); +// AbstractClassifierInstance values = new DynamicNode[0]; +// parent.addReferenceValue(ReferenceGeometry_shapes(), values); +// Assert.assertTrue((parent.getReferenceValues(ReferenceGeometry_shapes()).size() == 0); +// } +// +// @Test +// public void EmptyUntypedList_Reflective() +// { +// AbstractClassifierInstance parent = newReferenceGeometry("g"); +// AbstractClassifierInstance values = new ArrayList(); +// parent.addReferenceValue(ReferenceGeometry_shapes(), values); +// Assert.assertTrue((parent.getReferenceValues(ReferenceGeometry_shapes()).size() == 0); +// } +// +// @Test +// public void EmptyListMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newReferenceGeometry("g"); +// AbstractClassifierInstance values = new List(); +// parent.addReferenceValue(ReferenceGeometry_shapes(), values); +// Assert.assertTrue((parent.getReferenceValues(ReferenceGeometry_shapes()).size() == 0); +// } +// +// @Test +// public void EmptyListSubtype_Reflective() +// { +// AbstractClassifierInstance parent = newReferenceGeometry("g"); +// AbstractClassifierInstance values = new List(); +// parent.addReferenceValue(ReferenceGeometry_shapes(), values); +// Assert.assertTrue((parent.getReferenceValues(ReferenceGeometry_shapes()).size() == 0); +// } +// +// @Test +// public void EmptySet_Reflective() +// { +// AbstractClassifierInstance parent = newReferenceGeometry("g"); +// AbstractClassifierInstance values = new HashSet(); +// parent.addReferenceValue(ReferenceGeometry_shapes(), values); +// Assert.assertTrue((parent.getReferenceValues(ReferenceGeometry_shapes()).size() == 0); +// } +// +// @Test +// public void EmptyListNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newReferenceGeometry("g"); +// AbstractClassifierInstance values = new List(); +// parent.addReferenceValue(ReferenceGeometry_shapes(), values); +// Assert.assertTrue((parent.getReferenceValues(ReferenceGeometry_shapes()).size() == 0); +// } +// +// @Test +// public void EmptyList_Reset_Reflective() +// { +// AbstractClassifierInstance parent = newReferenceGeometry("g"); +// parent.addReferenceValue(ReferenceGeometry_shapes(), new List { newLine("myId") }); +// AbstractClassifierInstance values = new List(); +// parent.addReferenceValue(ReferenceGeometry_shapes(), values); +// Assert.assertTrue((parent.getReferenceValues(ReferenceGeometry_shapes()).size() == 0); +// } +// +//// #endregion +// +//// #region NullCollection +// +// @Test +// public void NullArray_Reflective() +// { +// AbstractClassifierInstance parent = newReferenceGeometry("g"); +// AbstractClassifierInstance values = new DynamicNode[] { null }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addReferenceValue(ReferenceGeometry_shapes(), values)); +// Assert.assertTrue((parent.getReferenceValues(ReferenceGeometry_shapes()).size() == 0); +// } +// +// @Test +// public void NullUntypedList_Reflective() +// { +// AbstractClassifierInstance parent = newReferenceGeometry("g"); +// AbstractClassifierInstance values = new ArrayList() { null }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addReferenceValue(ReferenceGeometry_shapes(), values)); +// Assert.assertTrue((parent.getReferenceValues(ReferenceGeometry_shapes()).size() == 0); +// } +// +// @Test +// public void NullListMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newReferenceGeometry("g"); +// AbstractClassifierInstance values = new List() { null }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addReferenceValue(ReferenceGeometry_shapes(), values)); +// Assert.assertTrue((parent.getReferenceValues(ReferenceGeometry_shapes()).size() == 0); +// } +// +// @Test +// public void NullListSubtype_Reflective() +// { +// AbstractClassifierInstance parent = newReferenceGeometry("g"); +// AbstractClassifierInstance values = new List() { null }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addReferenceValue(ReferenceGeometry_shapes(), values)); +// Assert.assertTrue((parent.getReferenceValues(ReferenceGeometry_shapes()).size() == 0); +// } +// +// @Test +// public void NullListNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newReferenceGeometry("g"); +// AbstractClassifierInstance values = new List() { null }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addReferenceValue(ReferenceGeometry_shapes(), values)); +// Assert.assertTrue((parent.getReferenceValues(ReferenceGeometry_shapes()).size() == 0); +// } +// +// @Test +// public void NullSet_Reflective() +// { +// AbstractClassifierInstance parent = newReferenceGeometry("g"); +// AbstractClassifierInstance values = new HashSet() { null }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addReferenceValue(ReferenceGeometry_shapes(), values)); +// Assert.assertTrue((parent.getReferenceValues(ReferenceGeometry_shapes()).size() == 0); +// } +// +//// #endregion +// +//// #region SingleCollection +// +// @Test +// public void SingleArray_Reflective() +// { +// AbstractClassifierInstance parent = newReferenceGeometry("g"); +// AbstractClassifierInstance value = newLine("s"); +// AbstractClassifierInstance values = new DynamicNode[] { value }; +// parent.addReferenceValue(ReferenceGeometry_shapes(), values); +// Assert.assertNull(value.getParent()); +// Assert.assertTrue((parent.getReferenceValues(ReferenceGeometry_shapes()).contains(value)); +// } +// +// @Test +// public void SingleUntypedArray_Reflective() +// { +// AbstractClassifierInstance parent = newReferenceGeometry("g"); +// AbstractClassifierInstance value = newLine("s"); +// AbstractClassifierInstance values = new object[] { value }; +// parent.addReferenceValue(ReferenceGeometry_shapes(), values); +// Assert.assertNull(value.getParent()); +// Assert.assertTrue((parent.getReferenceValues(ReferenceGeometry_shapes()).contains(value)); +// } +// +// @Test +// public void SingleUntypedList_Reflective() +// { +// AbstractClassifierInstance parent = newReferenceGeometry("g"); +// AbstractClassifierInstance value = newLine("s"); +// AbstractClassifierInstance values = new ArrayList() { value }; +// parent.addReferenceValue(ReferenceGeometry_shapes(), values); +// Assert.assertNull(value.getParent()); +// Assert.assertTrue((parent.getReferenceValues(ReferenceGeometry_shapes()).contains(value)); +// } +// +// @Test +// public void SingleListMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newReferenceGeometry("g"); +// AbstractClassifierInstance value = newLine("s"); +// AbstractClassifierInstance values = new List() { value }; +// parent.addReferenceValue(ReferenceGeometry_shapes(), values); +// Assert.assertNull(value.getParent()); +// Assert.assertTrue((parent.getReferenceValues(ReferenceGeometry_shapes()).contains(value)); +// } +// +// @Test +// public void SingleListSubtype_Reflective() +// { +// AbstractClassifierInstance parent = newReferenceGeometry("g"); +// AbstractClassifierInstance value = newLine("s"); +// AbstractClassifierInstance values = new List() { value }; +// parent.addReferenceValue(ReferenceGeometry_shapes(), values); +// Assert.assertNull(value.getParent()); +// Assert.assertTrue((parent.getReferenceValues(ReferenceGeometry_shapes()).contains(value)); +// } +// +// @Test +// public void SingleSet_Reflective() +// { +// AbstractClassifierInstance parent = newReferenceGeometry("g"); +// AbstractClassifierInstance value = newLine("s"); +// AbstractClassifierInstance values = new HashSet() { value }; +// parent.addReferenceValue(ReferenceGeometry_shapes(), values); +// Assert.assertNull(value.getParent()); +// Assert.assertTrue((parent.getReferenceValues(ReferenceGeometry_shapes()).contains(value)); +// } +// +// @Test +// public void SingleListNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newReferenceGeometry("g"); +// AbstractClassifierInstance value = newCoord("c"); +// AbstractClassifierInstance values = new List() { value }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addReferenceValue(ReferenceGeometry_shapes(), values)); +// Assert.assertTrue((parent.getReferenceValues(ReferenceGeometry_shapes()).size() == 0); +// } +// +// @Test +// public void SingleUntypedListNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newReferenceGeometry("g"); +// AbstractClassifierInstance value = newCoord("c"); +// AbstractClassifierInstance values = new ArrayList() { value }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addReferenceValue(ReferenceGeometry_shapes(), values)); +// Assert.assertTrue((parent.getReferenceValues(ReferenceGeometry_shapes()).size() == 0); +// } +// +// @Test +// public void SingleUntypedArrayNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newReferenceGeometry("g"); +// AbstractClassifierInstance value = newCoord("c"); +// AbstractClassifierInstance values = new object[] { value }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addReferenceValue(ReferenceGeometry_shapes(), values)); +// Assert.assertTrue((parent.getReferenceValues(ReferenceGeometry_shapes()).size() == 0); +// } +// +//// #endregion +// +//// #region MultipleCollection +// +// @Test +// public void MultipleArray_Reflective() +// { +// AbstractClassifierInstance parent = newReferenceGeometry("g"); +// AbstractClassifierInstance valueA = newLine("sA"); +// AbstractClassifierInstance valueB = newLine("sB"); +// AbstractClassifierInstance values = new DynamicNode[] { valueA, valueB }; +// parent.addReferenceValue(ReferenceGeometry_shapes(), values); +// Assert.assertNull(valueA.getParent()); +// Assert.assertTrue((parent.getReferenceValues(ReferenceGeometry_shapes()).contains(valueA)); +// Assert.assertNull(valueB.getParent()); +// Assert.assertTrue((parent.getReferenceValues(ReferenceGeometry_shapes()).contains(valueB)); +// } +// +// @Test +// public void MultipleUntypedArray_Reflective() +// { +// AbstractClassifierInstance parent = newReferenceGeometry("g"); +// AbstractClassifierInstance valueA = newLine("sA"); +// AbstractClassifierInstance valueB = newLine("sB"); +// AbstractClassifierInstance values = new object[] { valueA, valueB }; +// parent.addReferenceValue(ReferenceGeometry_shapes(), values); +// Assert.assertNull(valueA.getParent()); +// Assert.assertTrue((parent.getReferenceValues(ReferenceGeometry_shapes()).contains(valueA)); +// Assert.assertNull(valueB.getParent()); +// Assert.assertTrue((parent.getReferenceValues(ReferenceGeometry_shapes()).contains(valueB)); +// } +// +// @Test +// public void MultipleUntypedList_Reflective() +// { +// AbstractClassifierInstance parent = newReferenceGeometry("g"); +// AbstractClassifierInstance valueA = newLine("sA"); +// AbstractClassifierInstance valueB = newLine("sB"); +// AbstractClassifierInstance values = new ArrayList() { valueA, valueB }; +// parent.addReferenceValue(ReferenceGeometry_shapes(), values); +// Assert.assertNull(valueA.getParent()); +// Assert.assertTrue((parent.getReferenceValues(ReferenceGeometry_shapes()).contains(valueA)); +// Assert.assertNull(valueB.getParent()); +// Assert.assertTrue((parent.getReferenceValues(ReferenceGeometry_shapes()).contains(valueB)); +// } +// +// @Test +// public void MultipleListMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newReferenceGeometry("g"); +// AbstractClassifierInstance valueA = newLine("sA"); +// AbstractClassifierInstance valueB = newLine("sB"); +// AbstractClassifierInstance values = new List() { valueA, valueB }; +// parent.addReferenceValue(ReferenceGeometry_shapes(), values); +// Assert.assertNull(valueA.getParent()); +// Assert.assertTrue((parent.getReferenceValues(ReferenceGeometry_shapes()).contains(valueA)); +// Assert.assertNull(valueB.getParent()); +// Assert.assertTrue((parent.getReferenceValues(ReferenceGeometry_shapes()).contains(valueB)); +// } +// +// @Test +// public void MultipleListSubtype_Reflective() +// { +// AbstractClassifierInstance parent = newReferenceGeometry("g"); +// AbstractClassifierInstance valueA = newLine("sA"); +// AbstractClassifierInstance valueB = newLine("sB"); +// AbstractClassifierInstance values = new List() { valueA, valueB }; +// parent.addReferenceValue(ReferenceGeometry_shapes(), values); +// Assert.assertNull(valueA.getParent()); +// Assert.assertTrue((parent.getReferenceValues(ReferenceGeometry_shapes()).contains(valueA)); +// Assert.assertNull(valueB.getParent()); +// Assert.assertTrue((parent.getReferenceValues(ReferenceGeometry_shapes()).contains(valueB)); +// } +// +// @Test +// public void MultipleSet_Reflective() +// { +// AbstractClassifierInstance parent = newReferenceGeometry("g"); +// AbstractClassifierInstance valueA = newLine("sA"); +// AbstractClassifierInstance valueB = newLine("sB"); +// AbstractClassifierInstance values = new HashSet() { valueA, valueB }; +// parent.addReferenceValue(ReferenceGeometry_shapes(), values); +// Assert.assertNull(valueA.getParent()); +// Assert.assertTrue((parent.getReferenceValues(ReferenceGeometry_shapes()).contains(valueA)); +// Assert.assertNull(valueB.getParent()); +// Assert.assertTrue((parent.getReferenceValues(ReferenceGeometry_shapes()).contains(valueB)); +// } +// +// @Test +// public void MultipleSingleEnumerable_Reflective() +// { +// AbstractClassifierInstance parent = newReferenceGeometry("g"); +// AbstractClassifierInstance valueA = newLine("sA"); +// AbstractClassifierInstance valueB = newLine("sB"); +// AbstractClassifierInstance values = new SingleEnumerable() { valueA, valueB }; +// parent.addReferenceValue(ReferenceGeometry_shapes(), values); +// Assert.assertNull(valueA.getParent()); +// Assert.assertTrue((parent.getReferenceValues(ReferenceGeometry_shapes()).contains(valueA)); +// Assert.assertNull(valueB.getParent()); +// Assert.assertTrue((parent.getReferenceValues(ReferenceGeometry_shapes()).contains(valueB)); +// } +// +// @Test +// public void MultipleListNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newReferenceGeometry("g"); +// AbstractClassifierInstance valueA = newCoord("cA"); +// AbstractClassifierInstance valueB = newCoord("cB"); +// AbstractClassifierInstance values = new List() { valueA, valueB }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addReferenceValue(ReferenceGeometry_shapes(), values)); +// Assert.assertTrue((parent.getReferenceValues(ReferenceGeometry_shapes()).size() == 0); +// } +// +// @Test +// public void MultipleUntypedListNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newReferenceGeometry("g"); +// AbstractClassifierInstance valueA = newCoord("cA"); +// AbstractClassifierInstance valueB = newCoord("cB"); +// AbstractClassifierInstance values = new ArrayList() { valueA, valueB }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addReferenceValue(ReferenceGeometry_shapes(), values)); +// Assert.assertTrue((parent.getReferenceValues(ReferenceGeometry_shapes()).size() == 0); +// } +// +// @Test +// public void MultipleUntypedArrayNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newReferenceGeometry("g"); +// AbstractClassifierInstance valueA = newCoord("cA"); +// AbstractClassifierInstance valueB = newCoord("cB"); +// AbstractClassifierInstance values = new object[] { valueA, valueB }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addReferenceValue(ReferenceGeometry_shapes(), values)); +// Assert.assertTrue((parent.getReferenceValues(ReferenceGeometry_shapes()).size() == 0); +// } +// +// @Test +// public void ResultUnmodifiable_Set() +// { +// AbstractClassifierInstance parent = newReferenceGeometry("g"); +// AbstractClassifierInstance valueA = newLine("sA"); +// AbstractClassifierInstance valueB = newLine("sB"); +// AbstractClassifierInstance values = new DynamicNode[] { valueA, valueB }; +// parent.addReferenceValue(ReferenceGeometry_shapes(), values); +// AbstractClassifierInstance result = parent.getReferenceValues(ReferenceGeometry_shapes()); +// Assert.IsInstanceOfType>(result); +// } +// +// @Test +// public void ResultUnmodifiable_Unset() +// { +// AbstractClassifierInstance parent = newReferenceGeometry("g"); +// AbstractClassifierInstance result = parent.getReferenceValues(ReferenceGeometry_shapes()); +// Assert.IsInstanceOfType>(result); +// } +// +//// #endregion +} \ No newline at end of file diff --git a/core/src/test/java/lionweb/core/m2/dynamic/test/ReferenceTests_Multiple_Required.java b/core/src/test/java/lionweb/core/m2/dynamic/test/ReferenceTests_Multiple_Required.java new file mode 100644 index 00000000..a274afee --- /dev/null +++ b/core/src/test/java/lionweb/core/m2/dynamic/test/ReferenceTests_Multiple_Required.java @@ -0,0 +1,486 @@ +// Copyright 2024 TRUMPF Laser SE and other contributors +// +// 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. +// +// SPDX-FileCopyrightText: 2024 TRUMPF Laser SE and other contributors +// SPDX-License-Identifier: Apache-2.0 + +package lionweb.core.m2.dynamic.test; + +import io.lionweb.lioncore.java.model.impl.AbstractClassifierInstance; +import lionweb.utils.tests.CollectionAssert; +import org.junit.Assert; +import org.junit.Test; + +public class ReferenceTests_Multiple_Required extends DynamicNodeTestsBase +{ +//// #region Single +// +// @Test +// public void Single_Reflective() +// { +// AbstractClassifierInstance parent = newMaterialGroup("cs"); +// AbstractClassifierInstance line = newLine("myId"); +// Assert.assertThrows(IllegalArgumentException.class, () -> parent.addReferenceValue(MaterialGroup_materials(), line)); +// Assert.assertNull(line.getParent()); +// Assert.assertThrows(IllegalArgumentException.class, () -> +// parent.getReferenceValues(MaterialGroup_materials()).contains(line)); +// } +// +//// #endregion +// +//// #region Null +// +// @Test +// public void Null_Reflective() +// { +// AbstractClassifierInstance parent = newMaterialGroup("cs"); +// Assert.assertThrows(IllegalArgumentException.class, () -> parent.addReferenceValue(MaterialGroup_materials(), null)); +// } +// +//// #endregion +// +//// #region EmptyCollection +// +// @Test +// public void EmptyArray_Reflective() +// { +// AbstractClassifierInstance parent = newMaterialGroup("cs"); +// AbstractClassifierInstance values = new DynamicNode[0]; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addReferenceValue(MaterialGroup_materials(), values)); +// Assert.assertThrows(IllegalArgumentException.class, () -> +// parent.getReferenceValues(MaterialGroup_materials()).size() == 0); +// } +// +// @Test +// public void EmptyUntypedList_Reflective() +// { +// AbstractClassifierInstance parent = newMaterialGroup("cs"); +// AbstractClassifierInstance values = new ArrayList(); +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addReferenceValue(MaterialGroup_materials(), values)); +// Assert.assertThrows(IllegalArgumentException.class, () -> +// parent.getReferenceValues(MaterialGroup_materials()).size() == 0); +// } +// +// @Test +// public void EmptyListMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newMaterialGroup("cs"); +// AbstractClassifierInstance values = new List(); +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addReferenceValue(MaterialGroup_materials(), values)); +// Assert.assertThrows(IllegalArgumentException.class, () -> +// parent.getReferenceValues(MaterialGroup_materials()).size() == 0); +// } +// +// @Test +// public void EmptyListSubtype_Reflective() +// { +// AbstractClassifierInstance parent = newMaterialGroup("cs"); +// AbstractClassifierInstance values = new List(); +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addReferenceValue(MaterialGroup_materials(), values)); +// Assert.assertThrows(IllegalArgumentException.class, () -> +// parent.getReferenceValues(MaterialGroup_materials()).size() == 0); +// } +// +// @Test +// public void EmptySet_Reflective() +// { +// AbstractClassifierInstance parent = newMaterialGroup("cs"); +// AbstractClassifierInstance values = new HashSet(); +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addReferenceValue(MaterialGroup_materials(), values)); +// Assert.assertThrows(IllegalArgumentException.class, () -> +// parent.getReferenceValues(MaterialGroup_materials()).size() == 0); +// } +// +// @Test +// public void EmptyListNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newMaterialGroup("cs"); +// AbstractClassifierInstance values = new List(); +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addReferenceValue(MaterialGroup_materials(), values)); +// Assert.assertThrows(IllegalArgumentException.class, () -> +// parent.getReferenceValues(MaterialGroup_materials()).size() == 0); +// } +// +// @Test +// public void EmptyList_Reset_Reflective() +// { +// AbstractClassifierInstance parent = newMaterialGroup("cs"); +// AbstractClassifierInstance value = newCircle("myId"); +// parent.addReferenceValue(MaterialGroup_materials(), new List { value }); +// AbstractClassifierInstance values = new List(); +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addReferenceValue(MaterialGroup_materials(), values)); +// CollectionAssert.assertEquals(new List { value }, +// parent.getReferenceValues(MaterialGroup_materials()).ToList()); +// } +// +//// #endregion +// +//// #region NullCollection +// +// @Test +// public void NullArray_Reflective() +// { +// AbstractClassifierInstance parent = newMaterialGroup("cs"); +// AbstractClassifierInstance values = new DynamicNode[] { null }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addReferenceValue(MaterialGroup_materials(), values)); +// Assert.assertThrows(IllegalArgumentException.class, () -> +// parent.getReferenceValues(MaterialGroup_materials()).size() == 0); +// } +// +// @Test +// public void NullUntypedList_Reflective() +// { +// AbstractClassifierInstance parent = newMaterialGroup("cs"); +// AbstractClassifierInstance values = new ArrayList() { null }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addReferenceValue(MaterialGroup_materials(), values)); +// Assert.assertThrows(IllegalArgumentException.class, () -> +// parent.getReferenceValues(MaterialGroup_materials()).size() == 0); +// } +// +// @Test +// public void NullListMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newMaterialGroup("cs"); +// AbstractClassifierInstance values = new List() { null }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addReferenceValue(MaterialGroup_materials(), values)); +// Assert.assertThrows(IllegalArgumentException.class, () -> +// parent.getReferenceValues(MaterialGroup_materials()).size() == 0); +// } +// +// @Test +// public void NullListSubtype_Reflective() +// { +// AbstractClassifierInstance parent = newMaterialGroup("cs"); +// AbstractClassifierInstance values = new List() { null }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addReferenceValue(MaterialGroup_materials(), values)); +// Assert.assertThrows(IllegalArgumentException.class, () -> +// parent.getReferenceValues(MaterialGroup_materials()).size() == 0); +// } +// +// @Test +// public void NullListNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newMaterialGroup("cs"); +// AbstractClassifierInstance values = new List() { null }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addReferenceValue(MaterialGroup_materials(), values)); +// Assert.assertThrows(IllegalArgumentException.class, () -> +// parent.getReferenceValues(MaterialGroup_materials()).size() == 0); +// } +// +// @Test +// public void NullSet_Reflective() +// { +// AbstractClassifierInstance parent = newMaterialGroup("cs"); +// AbstractClassifierInstance values = new HashSet() { null }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addReferenceValue(MaterialGroup_materials(), values)); +// Assert.assertThrows(IllegalArgumentException.class, () -> +// parent.getReferenceValues(MaterialGroup_materials()).size() == 0); +// } +// +//// #endregion +// +//// #region SingleCollection +// +// @Test +// public void SingleArray_Reflective() +// { +// AbstractClassifierInstance parent = newMaterialGroup("cs"); +// AbstractClassifierInstance value = newLine("s"); +// AbstractClassifierInstance values = new DynamicNode[] { value }; +// parent.addReferenceValue(MaterialGroup_materials(), values); +// Assert.assertNull(value.getParent()); +// Assert.assertTrue((parent.getReferenceValues(MaterialGroup_materials()).contains(value)); +// } +// +// @Test +// public void SingleArray_Existing_Reflective() +// { +// AbstractClassifierInstance circle = newCircle("cc"); +// AbstractClassifierInstance parent = newMaterialGroup("cs"); +// parent.addReferenceValue(MaterialGroup_materials(), new DynamicNode[] { circle }); +// AbstractClassifierInstance value = newLine("s"); +// AbstractClassifierInstance values = new DynamicNode[] { value }; +// parent.addReferenceValue(MaterialGroup_materials(), values); +// Assert.assertNull(circle.getParent()); +// Assert.assertNull(value.getParent()); +// CollectionAssert.assertEquals(new List { value }, +// (parent.getReferenceValues(MaterialGroup_materials()).ToList()); +// } +// +// @Test +// public void SingleUntypedArray_Reflective() +// { +// AbstractClassifierInstance parent = newMaterialGroup("cs"); +// AbstractClassifierInstance value = newLine("s"); +// AbstractClassifierInstance values = new object[] { value }; +// parent.addReferenceValue(MaterialGroup_materials(), values); +// Assert.assertNull(value.getParent()); +// Assert.assertTrue((parent.getReferenceValues(MaterialGroup_materials()).contains(value)); +// } +// +// @Test +// public void SingleUntypedList_Reflective() +// { +// AbstractClassifierInstance parent = newMaterialGroup("cs"); +// AbstractClassifierInstance value = newLine("s"); +// AbstractClassifierInstance values = new ArrayList() { value }; +// parent.addReferenceValue(MaterialGroup_materials(), values); +// Assert.assertNull(value.getParent()); +// Assert.assertTrue((parent.getReferenceValues(MaterialGroup_materials()).contains(value)); +// } +// +// @Test +// public void SingleListMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newMaterialGroup("cs"); +// AbstractClassifierInstance value = newLine("s"); +// AbstractClassifierInstance values = new List() { value }; +// parent.addReferenceValue(MaterialGroup_materials(), values); +// Assert.assertNull(value.getParent()); +// Assert.assertTrue((parent.getReferenceValues(MaterialGroup_materials()).contains(value)); +// } +// +// @Test +// public void SingleListSubtype_Reflective() +// { +// AbstractClassifierInstance parent = newMaterialGroup("cs"); +// AbstractClassifierInstance value = newLine("s"); +// AbstractClassifierInstance values = new List() { value }; +// parent.addReferenceValue(MaterialGroup_materials(), values); +// Assert.assertNull(value.getParent()); +// Assert.assertTrue((parent.getReferenceValues(MaterialGroup_materials()).contains(value)); +// } +// +// @Test +// public void SingleSet_Reflective() +// { +// AbstractClassifierInstance parent = newMaterialGroup("cs"); +// AbstractClassifierInstance value = newLine("s"); +// AbstractClassifierInstance values = new HashSet() { value }; +// parent.addReferenceValue(MaterialGroup_materials(), values); +// Assert.assertNull(value.getParent()); +// Assert.assertTrue((parent.getReferenceValues(MaterialGroup_materials()).contains(value)); +// } +// +// @Test +// public void SingleListNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newMaterialGroup("cs"); +// AbstractClassifierInstance value = newCoord("c"); +// AbstractClassifierInstance values = new List() { value }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addReferenceValue(MaterialGroup_materials(), values)); +// Assert.assertThrows(IllegalArgumentException.class, () -> +// parent.getReferenceValues(MaterialGroup_materials()).size() == 0); +// } +// +// @Test +// public void SingleUntypedListNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newMaterialGroup("cs"); +// AbstractClassifierInstance value = newCoord("c"); +// AbstractClassifierInstance values = new ArrayList() { value }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addReferenceValue(MaterialGroup_materials(), values)); +// Assert.assertThrows(IllegalArgumentException.class, () -> +// parent.getReferenceValues(MaterialGroup_materials()).size() == 0); +// } +// +// @Test +// public void SingleUntypedArrayNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newMaterialGroup("cs"); +// AbstractClassifierInstance value = newCoord("c"); +// AbstractClassifierInstance values = new object[] { value }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addReferenceValue(MaterialGroup_materials(), values)); +// Assert.assertThrows(IllegalArgumentException.class, () -> +// parent.getReferenceValues(MaterialGroup_materials()).size() == 0); +// } +// +//// #endregion +// +//// #region MultipleCollection +// +// @Test +// public void MultipleArray_Reflective() +// { +// AbstractClassifierInstance parent = newMaterialGroup("cs"); +// AbstractClassifierInstance valueA = newLine("sA"); +// AbstractClassifierInstance valueB = newLine("sB"); +// AbstractClassifierInstance values = new DynamicNode[] { valueA, valueB }; +// parent.addReferenceValue(MaterialGroup_materials(), values); +// Assert.assertNull(valueA.getParent()); +// Assert.assertTrue((parent.getReferenceValues(MaterialGroup_materials()).contains(valueA)); +// Assert.assertNull(valueB.getParent()); +// Assert.assertTrue((parent.getReferenceValues(MaterialGroup_materials()).contains(valueB)); +// } +// +// @Test +// public void MultipleUntypedArray_Reflective() +// { +// AbstractClassifierInstance parent = newMaterialGroup("cs"); +// AbstractClassifierInstance valueA = newLine("sA"); +// AbstractClassifierInstance valueB = newLine("sB"); +// AbstractClassifierInstance values = new object[] { valueA, valueB }; +// parent.addReferenceValue(MaterialGroup_materials(), values); +// Assert.assertNull(valueA.getParent()); +// Assert.assertTrue((parent.getReferenceValues(MaterialGroup_materials()).contains(valueA)); +// Assert.assertNull(valueB.getParent()); +// Assert.assertTrue((parent.getReferenceValues(MaterialGroup_materials()).contains(valueB)); +// } +// +// @Test +// public void MultipleUntypedList_Reflective() +// { +// AbstractClassifierInstance parent = newMaterialGroup("cs"); +// AbstractClassifierInstance valueA = newLine("sA"); +// AbstractClassifierInstance valueB = newLine("sB"); +// AbstractClassifierInstance values = new ArrayList() { valueA, valueB }; +// parent.addReferenceValue(MaterialGroup_materials(), values); +// Assert.assertNull(valueA.getParent()); +// Assert.assertTrue((parent.getReferenceValues(MaterialGroup_materials()).contains(valueA)); +// Assert.assertNull(valueB.getParent()); +// Assert.assertTrue((parent.getReferenceValues(MaterialGroup_materials()).contains(valueB)); +// } +// +// @Test +// public void MultipleListMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newMaterialGroup("cs"); +// AbstractClassifierInstance valueA = newLine("sA"); +// AbstractClassifierInstance valueB = newLine("sB"); +// AbstractClassifierInstance values = new List() { valueA, valueB }; +// parent.addReferenceValue(MaterialGroup_materials(), values); +// Assert.assertNull(valueA.getParent()); +// Assert.assertTrue((parent.getReferenceValues(MaterialGroup_materials()).contains(valueA)); +// Assert.assertNull(valueB.getParent()); +// Assert.assertTrue((parent.getReferenceValues(MaterialGroup_materials()).contains(valueB)); +// } +// +// @Test +// public void MultipleListSubtype_Reflective() +// { +// AbstractClassifierInstance parent = newMaterialGroup("cs"); +// AbstractClassifierInstance valueA = newLine("sA"); +// AbstractClassifierInstance valueB = newLine("sB"); +// AbstractClassifierInstance values = new List() { valueA, valueB }; +// parent.addReferenceValue(MaterialGroup_materials(), values); +// Assert.assertNull(valueA.getParent()); +// Assert.assertTrue((parent.getReferenceValues(MaterialGroup_materials()).contains(valueA)); +// Assert.assertNull(valueB.getParent()); +// Assert.assertTrue((parent.getReferenceValues(MaterialGroup_materials()).contains(valueB)); +// } +// +// @Test +// public void MultipleSet_Reflective() +// { +// AbstractClassifierInstance parent = newMaterialGroup("cs"); +// AbstractClassifierInstance valueA = newLine("sA"); +// AbstractClassifierInstance valueB = newLine("sB"); +// AbstractClassifierInstance values = new HashSet() { valueA, valueB }; +// parent.addReferenceValue(MaterialGroup_materials(), values); +// Assert.assertNull(valueA.getParent()); +// Assert.assertTrue((parent.getReferenceValues(MaterialGroup_materials()).contains(valueA)); +// Assert.assertNull(valueB.getParent()); +// Assert.assertTrue((parent.getReferenceValues(MaterialGroup_materials()).contains(valueB)); +// } +// +// @Test +// public void MultipleSingleEnumerable_Reflective() +// { +// AbstractClassifierInstance parent = newMaterialGroup("cs"); +// AbstractClassifierInstance valueA = newLine("sA"); +// AbstractClassifierInstance valueB = newLine("sB"); +// AbstractClassifierInstance values = new SingleEnumerable() { valueA, valueB }; +// parent.addReferenceValue(MaterialGroup_materials(), values); +// Assert.assertNull(valueA.getParent()); +// Assert.assertTrue((parent.getReferenceValues(MaterialGroup_materials()).contains(valueA)); +// Assert.assertNull(valueB.getParent()); +// Assert.assertTrue((parent.getReferenceValues(MaterialGroup_materials()).contains(valueB)); +// } +// +// @Test +// public void MultipleListNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newMaterialGroup("cs"); +// AbstractClassifierInstance valueA = newCoord("cA"); +// AbstractClassifierInstance valueB = newCoord("cB"); +// AbstractClassifierInstance values = new List() { valueA, valueB }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addReferenceValue(MaterialGroup_materials(), values)); +// Assert.assertThrows(IllegalArgumentException.class, () -> +// parent.getReferenceValues(MaterialGroup_materials()).size() == 0); +// } +// +// @Test +// public void MultipleUntypedListNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newMaterialGroup("cs"); +// AbstractClassifierInstance valueA = newCoord("cA"); +// AbstractClassifierInstance valueB = newCoord("cB"); +// AbstractClassifierInstance values = new ArrayList() { valueA, valueB }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addReferenceValue(MaterialGroup_materials(), values)); +// Assert.assertThrows(IllegalArgumentException.class, () -> +// parent.getReferenceValues(MaterialGroup_materials()).size() == 0); +// } +// +// @Test +// public void MultipleUntypedArrayNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newMaterialGroup("cs"); +// AbstractClassifierInstance valueA = newCoord("cA"); +// AbstractClassifierInstance valueB = newCoord("cB"); +// AbstractClassifierInstance values = new object[] { valueA, valueB }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addReferenceValue(MaterialGroup_materials(), values)); +// Assert.assertThrows(IllegalArgumentException.class, () -> +// parent.getReferenceValues(MaterialGroup_materials()).size() == 0); +// } +// +// @Test +// public void ResultUnmodifiable_Set() +// { +// AbstractClassifierInstance parent = newMaterialGroup("g"); +// AbstractClassifierInstance valueA = newLine("sA"); +// AbstractClassifierInstance valueB = newLine("sB"); +// AbstractClassifierInstance values = new DynamicNode[] { valueA, valueB }; +// parent.addReferenceValue(MaterialGroup_materials(), values); +// AbstractClassifierInstance result = parent.getReferenceValues(MaterialGroup_materials()); +// Assert.IsInstanceOfType>(result); +// } +// +// @Test +// public void ResultUnmodifiable_Unset() +// { +// AbstractClassifierInstance parent = newMaterialGroup("g"); +// Assert.assertThrows(IllegalArgumentException.class, () -> parent.getReferenceValues(MaterialGroup_materials())); +// } +// +//// #endregion +} \ No newline at end of file diff --git a/core/src/test/java/lionweb/core/m2/dynamic/test/ReferenceTests_Single_Optional.java b/core/src/test/java/lionweb/core/m2/dynamic/test/ReferenceTests_Single_Optional.java new file mode 100644 index 00000000..0604e416 --- /dev/null +++ b/core/src/test/java/lionweb/core/m2/dynamic/test/ReferenceTests_Single_Optional.java @@ -0,0 +1,373 @@ +// Copyright 2024 TRUMPF Laser SE and other contributors +// +// 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. +// +// SPDX-FileCopyrightText: 2024 TRUMPF Laser SE and other contributors +// SPDX-License-Identifier: Apache-2.0 + +package lionweb.core.m2.dynamic.test; + +import io.lionweb.lioncore.java.model.impl.AbstractClassifierInstance; +import org.junit.Assert; +import org.junit.Test; + +public class ReferenceTests_Single_Optional extends DynamicNodeTestsBase +{ +//// #region Single +// +// @Test +// public void Single_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("g"); +// AbstractClassifierInstance reference = newLine("myId"); +// parent.addReferenceValue(OffsetDuplicate_altSource(), reference); +// Assert.assertNull(reference.getParent()); +// Assert.assertSame(reference, parent.getReferenceValues(OffsetDuplicate_altSource())); +// } +// +// @Test +// public void Existing_Reflective() +// { +// AbstractClassifierInstance oldReference = newLine("old"); +// AbstractClassifierInstance parent = newOffsetDuplicate("g"); +// parent.addReferenceValue(OffsetDuplicate_altSource(), oldReference); +// AbstractClassifierInstance reference = newLine("myId"); +// parent.addReferenceValue(OffsetDuplicate_altSource(), reference); +// Assert.assertNull(oldReference.getParent()); +// Assert.assertNull(reference.getParent()); +// Assert.assertSame(reference, parent.getReferenceValues(OffsetDuplicate_altSource())); +// } +// +//// #endregion +// +//// #region Null +// +// @Test +// public void Null_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("g"); +// parent.addReferenceValue(OffsetDuplicate_altSource(), null); +// Assert.assertNull(parent.getReferenceValues(OffsetDuplicate_altSource())); +// } +// +//// #endregion +// +//// #region EmptyCollection +// +// @Test +// public void EmptyArray_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("g"); +// AbstractClassifierInstance values = new DynamicNode[0]; +// Assert.assertThrows(IllegalArgumentException.class, () => +// parent.addReferenceValue(OffsetDuplicate_altSource(), values)); +// } +// +// @Test +// public void EmptyUntypedList_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("g"); +// AbstractClassifierInstance values = new ArrayList(); +// Assert.assertThrows(IllegalArgumentException.class, () => +// parent.addReferenceValue(OffsetDuplicate_altSource(), values)); +// } +// +// @Test +// public void EmptyListMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("g"); +// AbstractClassifierInstance values = new List(); +// Assert.assertThrows(IllegalArgumentException.class, () => +// parent.addReferenceValue(OffsetDuplicate_altSource(), values)); +// } +// +// @Test +// public void EmptySet_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("g"); +// AbstractClassifierInstance values = new HashSet(); +// Assert.assertThrows(IllegalArgumentException.class, () => +// parent.addReferenceValue(OffsetDuplicate_altSource(), values)); +// } +// +// @Test +// public void EmptyListNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("g"); +// AbstractClassifierInstance values = new List(); +// Assert.assertThrows(IllegalArgumentException.class, () => +// parent.addReferenceValue(OffsetDuplicate_altSource(), values)); +// } +// +//// #endregion +// +//// #region NullCollection +// +// @Test +// public void NullArray_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("g"); +// AbstractClassifierInstance values = new DynamicNode[] { null }; +// Assert.assertThrows(IllegalArgumentException.class, () => +// parent.addReferenceValue(OffsetDuplicate_altSource(), values)); +// } +// +// @Test +// public void NullUntypedList_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("g"); +// AbstractClassifierInstance values = new ArrayList() { null }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addReferenceValue(OffsetDuplicate_altSource(), values)); +// } +// +// @Test +// public void NullListMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("g"); +// AbstractClassifierInstance values = new List() { null }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addReferenceValue(OffsetDuplicate_altSource(), values)); +// } +// +// @Test +// public void NullListNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("g"); +// AbstractClassifierInstance values = new List() { null }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addReferenceValue(OffsetDuplicate_altSource(), values)); +// } +// +// @Test +// public void NullSet_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("g"); +// AbstractClassifierInstance values = new HashSet() { null }; +// Assert.assertThrows(IllegalArgumentException.class, () => +// parent.addReferenceValue(OffsetDuplicate_altSource(), values)); +// } +// +//// #endregion +// +//// #region SingleCollection +// +// @Test +// public void SingleArray_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("g"); +// AbstractClassifierInstance value = newLine("s"); +// AbstractClassifierInstance values = new DynamicNode[] { value }; +// +// Assert.assertThrows(IllegalArgumentException.class, () => +// parent.addReferenceValue(OffsetDuplicate_altSource(), values)); +// Assert.assertNull(parent.getReferenceValues(OffsetDuplicate_altSource())); +// Assert.assertNull(value.getParent()); +// } +// +// @Test +// public void SingleUntypedArray_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("g"); +// AbstractClassifierInstance value = newLine("s"); +// AbstractClassifierInstance values = new object[] { value }; +// Assert.assertThrows(IllegalArgumentException.class, () => +// parent.addReferenceValue(OffsetDuplicate_altSource(), values)); +// Assert.assertNull(parent.getReferenceValues(OffsetDuplicate_altSource())); +// Assert.assertNull(value.getParent()); +// } +// +// @Test +// public void SingleUntypedList_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("g"); +// AbstractClassifierInstance value = newLine("s"); +// AbstractClassifierInstance values = new ArrayList() { value }; +// Assert.assertThrows(IllegalArgumentException.class, () => +// parent.addReferenceValue(OffsetDuplicate_altSource(), values)); +// Assert.assertNull(parent.getReferenceValues(OffsetDuplicate_altSource())); +// Assert.assertNull(value.getParent()); +// } +// +// @Test +// public void SingleListMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("g"); +// AbstractClassifierInstance value = newLine("s"); +// AbstractClassifierInstance values = new List() { value }; +// Assert.assertThrows(IllegalArgumentException.class, () => +// parent.addReferenceValue(OffsetDuplicate_altSource(), values)); +// Assert.assertNull(parent.getReferenceValues(OffsetDuplicate_altSource())); +// Assert.assertNull(value.getParent()); +// } +// +// @Test +// public void SingleSet_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("g"); +// AbstractClassifierInstance value = newLine("s"); +// AbstractClassifierInstance values = new HashSet() { value }; +// Assert.assertThrows(IllegalArgumentException.class, () => +// parent.addReferenceValue(OffsetDuplicate_altSource(), values)); +// Assert.assertNull(parent.getReferenceValues(OffsetDuplicate_altSource())); +// Assert.assertNull(value.getParent()); +// } +// +// @Test +// public void SingleListNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("g"); +// AbstractClassifierInstance value = newCoord("c"); +// AbstractClassifierInstance values = new List() { value }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addReferenceValue(OffsetDuplicate_altSource(), values)); +// } +// +// @Test +// public void SingleUntypedListNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("g"); +// AbstractClassifierInstance value = newCoord("c"); +// AbstractClassifierInstance values = new ArrayList() { value }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addReferenceValue(OffsetDuplicate_altSource(), values)); +// } +// +// @Test +// public void SingleUntypedArrayNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("g"); +// AbstractClassifierInstance value = newCoord("c"); +// AbstractClassifierInstance values = new object[] { value }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addReferenceValue(OffsetDuplicate_altSource(), values)); +// } +// +//// #endregion +// +//// #region MultipleCollection +// +// @Test +// public void MultipleArray_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("g"); +// AbstractClassifierInstance valueA = newLine("sA"); +// AbstractClassifierInstance valueB = newLine("sB"); +// AbstractClassifierInstance values = new DynamicNode[] { valueA, valueB }; +// Assert.assertThrows(IllegalArgumentException.class, () => +// parent.addReferenceValue(OffsetDuplicate_altSource(), values)); +// Assert.assertNull(parent.getReferenceValues(OffsetDuplicate_altSource())); +// Assert.assertNull(valueA.getParent()); +// Assert.assertNull(valueB.getParent()); +// } +// +// @Test +// public void MultipleUntypedArray_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("g"); +// AbstractClassifierInstance valueA = newLine("sA"); +// AbstractClassifierInstance valueB = newLine("sB"); +// AbstractClassifierInstance values = new object[] { valueA, valueB }; +// Assert.assertThrows(IllegalArgumentException.class, () => +// parent.addReferenceValue(OffsetDuplicate_altSource(), values)); +// Assert.assertNull(parent.getReferenceValues(OffsetDuplicate_altSource())); +// Assert.assertNull(valueA.getParent()); +// Assert.assertNull(valueB.getParent()); +// } +// +// @Test +// public void MultipleUntypedList_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("g"); +// AbstractClassifierInstance valueA = newLine("sA"); +// AbstractClassifierInstance valueB = newLine("sB"); +// AbstractClassifierInstance values = new ArrayList() { valueA, valueB }; +// Assert.assertThrows(IllegalArgumentException.class, () => +// parent.addReferenceValue(OffsetDuplicate_altSource(), values)); +// Assert.assertNull(parent.getReferenceValues(OffsetDuplicate_altSource())); +// Assert.assertNull(valueA.getParent()); +// Assert.assertNull(valueB.getParent()); +// } +// +// @Test +// public void MultipleListMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("g"); +// AbstractClassifierInstance valueA = newLine("sA"); +// AbstractClassifierInstance valueB = newLine("sB"); +// AbstractClassifierInstance values = new List() { valueA, valueB }; +// Assert.assertThrows(IllegalArgumentException.class, () => +// parent.addReferenceValue(OffsetDuplicate_altSource(), values)); +// Assert.assertNull(parent.getReferenceValues(OffsetDuplicate_altSource())); +// Assert.assertNull(valueA.getParent()); +// Assert.assertNull(valueB.getParent()); +// } +// +// @Test +// public void MultipleSet_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("g"); +// AbstractClassifierInstance valueA = newLine("sA"); +// AbstractClassifierInstance valueB = newLine("sB"); +// AbstractClassifierInstance values = new HashSet() { valueA, valueB }; +// Assert.assertThrows(IllegalArgumentException.class, () => +// parent.addReferenceValue(OffsetDuplicate_altSource(), values)); +// Assert.assertNull(parent.getReferenceValues(OffsetDuplicate_altSource())); +// Assert.assertNull(valueA.getParent()); +// Assert.assertNull(valueB.getParent()); +// } +// +// @Test +// public void MultipleListNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("g"); +// AbstractClassifierInstance valueA = newCoord("cA"); +// AbstractClassifierInstance valueB = newCoord("cB"); +// AbstractClassifierInstance values = new List() { valueA, valueB }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addReferenceValue(OffsetDuplicate_altSource(), values)); +// Assert.assertNull(parent.getReferenceValues(OffsetDuplicate_altSource())); +// Assert.assertNull(valueA.getParent()); +// Assert.assertNull(valueB.getParent()); +// } +// +// @Test +// public void MultipleUntypedListNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("g"); +// AbstractClassifierInstance valueA = newCoord("cA"); +// AbstractClassifierInstance valueB = newCoord("cB"); +// AbstractClassifierInstance values = new ArrayList() { valueA, valueB }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addReferenceValue(OffsetDuplicate_altSource(), values)); +// Assert.assertNull(parent.getReferenceValues(OffsetDuplicate_altSource())); +// Assert.assertNull(valueA.getParent()); +// Assert.assertNull(valueB.getParent()); +// } +// +// @Test +// public void MultipleUntypedArrayNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("g"); +// AbstractClassifierInstance valueA = newCoord("cA"); +// AbstractClassifierInstance valueB = newCoord("cB"); +// AbstractClassifierInstance values = new object[] { valueA, valueB }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addReferenceValue(OffsetDuplicate_altSource(), values)); +// Assert.assertNull(parent.getReferenceValues(OffsetDuplicate_altSource())); +// Assert.assertNull(valueA.getParent()); +// Assert.assertNull(valueB.getParent()); +// } +// +//// #endregion +} \ No newline at end of file diff --git a/core/src/test/java/lionweb/core/m2/dynamic/test/ReferenceTests_Single_Required.java b/core/src/test/java/lionweb/core/m2/dynamic/test/ReferenceTests_Single_Required.java new file mode 100644 index 00000000..2ba4ba7e --- /dev/null +++ b/core/src/test/java/lionweb/core/m2/dynamic/test/ReferenceTests_Single_Required.java @@ -0,0 +1,374 @@ +// Copyright 2024 TRUMPF Laser SE and other contributors +// +// 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. +// +// SPDX-FileCopyrightText: 2024 TRUMPF Laser SE and other contributors +// SPDX-License-Identifier: Apache-2.0 + +package lionweb.core.m2.dynamic.test; + +import io.lionweb.lioncore.java.model.impl.AbstractClassifierInstance; +import org.junit.Assert; +import org.junit.Test; + +public class ReferenceTests_Single_Required extends DynamicNodeTestsBase +{ +//// #region Single +// +// @Test +// public void Single_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("od"); +// AbstractClassifierInstance reference = newLine("myId"); +// parent.addReferenceValue(OffsetDuplicate_source(), reference); +// Assert.assertNull(reference.getParent()); +// Assert.assertSame(reference, parent.getReferenceValues(OffsetDuplicate_source())); +// } +// +// @Test +// public void Existing_Reflective() +// { +// AbstractClassifierInstance oldReference = newLine("old"); +// AbstractClassifierInstance parent = newOffsetDuplicate("od"); +// parent.addReferenceValue(OffsetDuplicate_source(), oldReference); +// AbstractClassifierInstance reference = newLine("myId"); +// parent.addReferenceValue(OffsetDuplicate_source(), reference); +// Assert.assertNull(oldReference.getParent()); +// Assert.assertNull(reference.getParent()); +// Assert.assertSame(reference, parent.getReferenceValues(OffsetDuplicate_source())); +// } +// +//// #endregion +// +//// #region Null +// +// @Test +// public void Null_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("od"); +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addReferenceValue(OffsetDuplicate_source(), null)); +// Assert.assertThrows(IllegalArgumentException.class, () -> parent.getReferenceValues(OffsetDuplicate_source())); +// } +// +//// #endregion +// +//// #region EmptyCollection +// +// @Test +// public void EmptyArray_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("od"); +// AbstractClassifierInstance values = new DynamicNode[0]; +// Assert.assertThrows(IllegalArgumentException.class, () -> +// parent.addReferenceValue(OffsetDuplicate_source(), values)); +// } +// +// @Test +// public void EmptyUntypedList_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("od"); +// AbstractClassifierInstance values = new ArrayList(); +// Assert.assertThrows(IllegalArgumentException.class, () -> +// parent.addReferenceValue(OffsetDuplicate_source(), values)); +// } +// +// @Test +// public void EmptyListMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("od"); +// AbstractClassifierInstance values = new List(); +// Assert.assertThrows(IllegalArgumentException.class, () -> +// parent.addReferenceValue(OffsetDuplicate_source(), values)); +// } +// +// @Test +// public void EmptySet_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("od"); +// AbstractClassifierInstance values = new HashSet(); +// Assert.assertThrows(IllegalArgumentException.class, () -> +// parent.addReferenceValue(OffsetDuplicate_source(), values)); +// } +// +// @Test +// public void EmptyListNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("od"); +// AbstractClassifierInstance values = new List(); +// Assert.assertThrows(IllegalArgumentException.class, () -> +// parent.addReferenceValue(OffsetDuplicate_source(), values)); +// } +// +//// #endregion +// +//// #region NullCollection +// +// @Test +// public void NullArray_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("od"); +// AbstractClassifierInstance values = new DynamicNode[] { null }; +// Assert.assertThrows(IllegalArgumentException.class, () -> +// parent.addReferenceValue(OffsetDuplicate_source(), values)); +// } +// +// @Test +// public void NullUntypedList_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("od"); +// AbstractClassifierInstance values = new ArrayList() { null }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addReferenceValue(OffsetDuplicate_source(), values)); +// } +// +// @Test +// public void NullListMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("od"); +// AbstractClassifierInstance values = new List() { null }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addReferenceValue(OffsetDuplicate_source(), values)); +// } +// +// @Test +// public void NullListNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("od"); +// AbstractClassifierInstance values = new List() { null }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addReferenceValue(OffsetDuplicate_source(), values)); +// } +// +// @Test +// public void NullSet_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("od"); +// AbstractClassifierInstance values = new HashSet() { null }; +// Assert.assertThrows(IllegalArgumentException.class, () -> +// parent.addReferenceValue(OffsetDuplicate_source(), values)); +// } +// +//// #endregion +// +//// #region SingleCollection +// +// @Test +// public void SingleArray_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("od"); +// AbstractClassifierInstance value = newLine("s"); +// AbstractClassifierInstance values = new DynamicNode[] { value }; +// +// Assert.assertThrows(IllegalArgumentException.class, () -> +// parent.addReferenceValue(OffsetDuplicate_source(), values)); +// Assert.assertThrows(IllegalArgumentException.class, () -> parent.getReferenceValues(OffsetDuplicate_source())); +// Assert.assertNull(value.getParent()); +// } +// +// @Test +// public void SingleUntypedArray_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("od"); +// AbstractClassifierInstance value = newLine("s"); +// AbstractClassifierInstance values = new Object[] { value }; +// Assert.assertThrows(IllegalArgumentException.class, () -> +// parent.addReferenceValue(OffsetDuplicate_source(), values)); +// Assert.assertThrows(IllegalArgumentException.class, () -> parent.getReferenceValues(OffsetDuplicate_source())); +// Assert.assertNull(value.getParent()); +// } +// +// @Test +// public void SingleUntypedList_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("od"); +// AbstractClassifierInstance value = newLine("s"); +// AbstractClassifierInstance values = new ArrayList() { value }; +// Assert.assertThrows(IllegalArgumentException.class, () -> +// parent.addReferenceValue(OffsetDuplicate_source(), values)); +// Assert.assertThrows(IllegalArgumentException.class, () -> parent.getReferenceValues(OffsetDuplicate_source())); +// Assert.assertNull(value.getParent()); +// } +// +// @Test +// public void SingleListMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("od"); +// AbstractClassifierInstance value = newLine("s"); +// AbstractClassifierInstance values = new List() { value }; +// Assert.assertThrows(IllegalArgumentException.class, () -> +// parent.addReferenceValue(OffsetDuplicate_source(), values)); +// Assert.assertThrows(IllegalArgumentException.class, () -> parent.getReferenceValues(OffsetDuplicate_source())); +// Assert.assertNull(value.getParent()); +// } +// +// @Test +// public void SingleSet_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("od"); +// AbstractClassifierInstance value = newLine("s"); +// AbstractClassifierInstance values = new HashSet() { value }; +// Assert.assertThrows(IllegalArgumentException.class, () -> +// parent.addReferenceValue(OffsetDuplicate_source(), values)); +// Assert.assertThrows(IllegalArgumentException.class, () -> parent.getReferenceValues(OffsetDuplicate_source())); +// Assert.assertNull(value.getParent()); +// } +// +// @Test +// public void SingleListNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("od"); +// AbstractClassifierInstance value = newCoord("c"); +// AbstractClassifierInstance values = new List() { value }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addReferenceValue(OffsetDuplicate_source(), values)); +// } +// +// @Test +// public void SingleUntypedListNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("od"); +// AbstractClassifierInstance value = newCoord("c"); +// AbstractClassifierInstance values = new ArrayList() { value }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addReferenceValue(OffsetDuplicate_source(), values)); +// } +// +// @Test +// public void SingleUntypedArrayNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("od"); +// AbstractClassifierInstance value = newCoord("c"); +// AbstractClassifierInstance values = new Object[] { value }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addReferenceValue(OffsetDuplicate_source(), values)); +// } +// +//// #endregion +// +//// #region MultipleCollection +// +// @Test +// public void MultipleArray_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("od"); +// AbstractClassifierInstance valueA = newLine("sA"); +// AbstractClassifierInstance valueB = newLine("sB"); +// AbstractClassifierInstance values = new DynamicNode[] { valueA, valueB }; +// Assert.assertThrows(IllegalArgumentException.class, () -> +// parent.addReferenceValue(OffsetDuplicate_source(), values)); +// Assert.assertThrows(IllegalArgumentException.class, () -> parent.getReferenceValues(OffsetDuplicate_source())); +// Assert.assertNull(valueA.getParent()); +// Assert.assertNull(valueB.getParent()); +// } +// +// @Test +// public void MultipleUntypedArray_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("od"); +// AbstractClassifierInstance valueA = newLine("sA"); +// AbstractClassifierInstance valueB = newLine("sB"); +// AbstractClassifierInstance values = new object[] { valueA, valueB }; +// Assert.assertThrows(IllegalArgumentException.class, () -> +// parent.addReferenceValue(OffsetDuplicate_source(), values)); +// Assert.assertThrows(IllegalArgumentException.class, () -> parent.getReferenceValues(OffsetDuplicate_source())); +// Assert.assertNull(valueA.getParent()); +// Assert.assertNull(valueB.getParent()); +// } +// +// @Test +// public void MultipleUntypedList_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("od"); +// AbstractClassifierInstance valueA = newLine("sA"); +// AbstractClassifierInstance valueB = newLine("sB"); +// AbstractClassifierInstance values = new ArrayList() { valueA, valueB }; +// Assert.assertThrows(IllegalArgumentException.class, () -> +// parent.addReferenceValue(OffsetDuplicate_source(), values)); +// Assert.assertThrows(IllegalArgumentException.class, () -> parent.getReferenceValues(OffsetDuplicate_source())); +// Assert.assertNull(valueA.getParent()); +// Assert.assertNull(valueB.getParent()); +// } +// +// @Test +// public void MultipleListMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("od"); +// AbstractClassifierInstance valueA = newLine("sA"); +// AbstractClassifierInstance valueB = newLine("sB"); +// AbstractClassifierInstance values = new List() { valueA, valueB }; +// Assert.assertThrows(IllegalArgumentException.class, () -> +// parent.addReferenceValue(OffsetDuplicate_source(), values)); +// Assert.assertThrows(IllegalArgumentException.class, () -> parent.getReferenceValues(OffsetDuplicate_source())); +// Assert.assertNull(valueA.getParent()); +// Assert.assertNull(valueB.getParent()); +// } +// +// @Test +// public void MultipleSet_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("od"); +// AbstractClassifierInstance valueA = newLine("sA"); +// AbstractClassifierInstance valueB = newLine("sB"); +// AbstractClassifierInstance values = new HashSet() { valueA, valueB }; +// Assert.assertThrows(IllegalArgumentException.class, () -> +// parent.addReferenceValue(OffsetDuplicate_source(), values)); +// Assert.assertThrows(IllegalArgumentException.class, () -> parent.getReferenceValues(OffsetDuplicate_source())); +// Assert.assertNull(valueA.getParent()); +// Assert.assertNull(valueB.getParent()); +// } +// +// @Test +// public void MultipleListNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("od"); +// AbstractClassifierInstance valueA = newCoord("cA"); +// AbstractClassifierInstance valueB = newCoord("cB"); +// AbstractClassifierInstance values = new List() { valueA, valueB }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addReferenceValue(OffsetDuplicate_source(), values)); +// Assert.assertThrows(IllegalArgumentException.class, () -> parent.getReferenceValues(OffsetDuplicate_source())); +// Assert.assertNull(valueA.getParent()); +// Assert.assertNull(valueB.getParent()); +// } +// +// @Test +// public void MultipleUntypedListNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("od"); +// AbstractClassifierInstance valueA = newCoord("cA"); +// AbstractClassifierInstance valueB = newCoord("cB"); +// AbstractClassifierInstance values = new ArrayList() { valueA, valueB }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addReferenceValue(OffsetDuplicate_source(), values)); +// Assert.assertThrows(IllegalArgumentException.class, () -> parent.getReferenceValues(OffsetDuplicate_source())); +// Assert.assertNull(valueA.getParent()); +// Assert.assertNull(valueB.getParent()); +// } +// +// @Test +// public void MultipleUntypedArrayNonMatchingType_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("od"); +// AbstractClassifierInstance valueA = newCoord("cA"); +// AbstractClassifierInstance valueB = newCoord("cB"); +// AbstractClassifierInstance values = new Object[] { valueA, valueB }; +// Assert.assertThrows(IllegalArgumentException.class, +// () -> parent.addReferenceValue(OffsetDuplicate_source(), values)); +// Assert.assertThrows(IllegalArgumentException.class, () -> parent.getReferenceValues(OffsetDuplicate_source())); +// Assert.assertNull(valueA.getParent()); +// Assert.assertNull(valueB.getParent()); +// } +// +//// #endregion +} \ No newline at end of file diff --git a/core/src/test/java/lionweb/core/m2/dynamic/test/ReflectionTests.java b/core/src/test/java/lionweb/core/m2/dynamic/test/ReflectionTests.java new file mode 100644 index 00000000..95f7eec5 --- /dev/null +++ b/core/src/test/java/lionweb/core/m2/dynamic/test/ReflectionTests.java @@ -0,0 +1,110 @@ +// Copyright 2024 TRUMPF Laser SE and other contributors +// +// 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. +// +// SPDX-FileCopyrightText: 2024 TRUMPF Laser SE and other contributors +// SPDX-License-Identifier: Apache-2.0 + +package lionweb.core.m2.dynamic.test; + +import examples.shapes.dynamic.ShapesDynamic; +import io.lionweb.lioncore.java.language.LionCoreBuiltins; +import io.lionweb.lioncore.java.model.Node; +import io.lionweb.lioncore.java.model.impl.AbstractClassifierInstance; +import lionweb.utils.tests.CollectionAssert; +import org.junit.Assert; +import org.junit.Test; + +public class ReflectionTests extends DynamicNodeTestsBase +{ +// @Test +// public void GetClassifier() +// { +// AbstractClassifierInstance node = newCircle("id"); +// Assert.assertEquals(getClassifierByKey("key-Circle"), node.getClassifier(), +// new LanguageEntityIdentityComparer()); +// } + +// #region inherited + +// #region property + + @Test + public void SetGetInheritedProperty() + { + AbstractClassifierInstance node = newCircle("id"); + node.setPropertyValue(LionCoreBuiltins.getINamed().getPropertyByID("LionCore-builtins-INamed-name"), "hi"); + Assert.assertEquals("hi", node.getPropertyValue(LionCoreBuiltins.getINamed().getPropertyByID("LionCore-builtins-INamed-name"))); + } + + @Test + public void GetInheritedProperty_Unset() + { + AbstractClassifierInstance node = newCircle("id"); + Assert.assertThrows(IllegalArgumentException.class, () -> node.getPropertyValue(LionCoreBuiltins.getINamed().getPropertyByID("LionCore-builtins-INamed-name"))); + } + +// #endregion + +// #region containment + +// @Test +// public void SetGetInheritedContainment() +// { +// Node child = newDocumentation("c"); +// AbstractClassifierInstance parent = newCircle("id"); +// parent.addChild(Shape_shapeDocs(), child); +// Assert.assertSame(child, parent.getChildren(Shape_shapeDocs())); +// } + + @Test + public void GetInheritedContainment_Unset() + { + AbstractClassifierInstance parent = newCircle("id"); + Assert.assertSame(null, parent.getChildren(Shape_shapeDocs())); + } + +// @Test +// public void InheritedContainment_DetachChild() +// { +// Node child = newDocumentation("c"); +// AbstractClassifierInstance parent = newCircle("id"); +// parent.addChild(Shape_shapeDocs(), child); +// parent.removeChild(child); +// Assert.assertNull(child.getParent()); +// Assert.assertNull(parent.getChildren(Shape_shapeDocs())); +// } + +// @Test +// public void InheritedContainment_GetContainmentOf() +// { +// Node child = newDocumentation("c"); +// AbstractClassifierInstance parent = newCircle("id"); +// parent.addChild(Shape_shapeDocs(), child); +// Assert.assertEquals(Shape_shapeDocs(), parent.GetContainmentOf(child)); +// } + +// @Test +// public void InheritedContainment_CollectAllSetFeatures() +// { +// Node child = newDocumentation("c"); +// AbstractClassifierInstance parent = newCircle("id"); +// parent.addChild(Shape_shapeDocs(), child); +// CollectionAssert.assertEquals(new List { Shape_shapeDocs }, +// parent.CollectAllSetFeatures().ToList()); +// } + +// #endregion + +// #endregion +} \ No newline at end of file diff --git a/core/src/test/java/lionweb/core/m2/dynamic/test/SetFeaturesTests.java b/core/src/test/java/lionweb/core/m2/dynamic/test/SetFeaturesTests.java new file mode 100644 index 00000000..cb6b543a --- /dev/null +++ b/core/src/test/java/lionweb/core/m2/dynamic/test/SetFeaturesTests.java @@ -0,0 +1,413 @@ +// Copyright 2024 TRUMPF Laser SE and other contributors +// +// 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. +// +// SPDX-FileCopyrightText: 2024 TRUMPF Laser SE and other contributors +// SPDX-License-Identifier: Apache-2.0 + +package lionweb.core.m2.dynamic.test; + +import com.google.common.collect.Lists; +import io.lionweb.lioncore.java.model.Node; +import io.lionweb.lioncore.java.model.impl.AbstractClassifierInstance; +import lionweb.utils.tests.CollectionAssert; +import org.junit.Test; + +import java.util.Collections; + +public class SetFeaturesTests extends DynamicNodeTestsBase +{ +//// #region property +// +//// #region string +// +// @Test +// public void String_Init() +// { +// AbstractClassifierInstance parent = newDocumentation("od"); +// CollectionAssert.AreEqual(Collections.emptyList(), parent.CollectAllSetFeatures().ToList()); +// } +// +// @Test +// public void String_Set_Reflective() +// { +// AbstractClassifierInstance parent = newDocumentation("od"); +// parent.setPropertyValue(Documentation_text(), "hello"); +// CollectionAssert.AreEqual(Lists.newArrayList(Documentation_text()), +// parent.CollectAllSetFeatures().ToList()); +// } +// +// @Test +// public void String_Unset_Reflective() +// { +// AbstractClassifierInstance parent = newDocumentation("od"); +// parent.setPropertyValue(Documentation_text(), "hello"); +// parent.setPropertyValue(Documentation_text(), null); +// CollectionAssert.AreEqual(Collections.emptyList(), parent.CollectAllSetFeatures().ToList()); +// } +// +//// #endregion +// +//// #region integer +// +// @Test +// public void Integer_Init() +// { +// AbstractClassifierInstance parent = newCircle("od"); +// CollectionAssert.AreEqual(Collections.emptyList(), parent.CollectAllSetFeatures().ToList()); +// } +// +// @Test +// public void Integer_Set_Reflective() +// { +// AbstractClassifierInstance parent = newCircle("od"); +// parent.setPropertyValue(Circle_r(), 10); +// CollectionAssert.AreEqual(Lists.newArrayList(Circle_r()), +// parent.CollectAllSetFeatures().ToList()); +// } +// +//// #endregion +// +//// #region boolean +// +// @Test +// public void Boolean_Init() +// { +// AbstractClassifierInstance parent = newDocumentation("od"); +// CollectionAssert.AreEqual(Collections.emptyList(), parent.CollectAllSetFeatures().ToList()); +// } +// +// @Test +// public void Boolean_Set_Reflective() +// { +// AbstractClassifierInstance parent = newDocumentation("od"); +// parent.setPropertyValue(Documentation_technical(), true); +// CollectionAssert.AreEqual(Lists.newArrayList(Documentation_technical()), +// parent.CollectAllSetFeatures().ToList()); +// } +// +// @Test +// public void Boolean_Unset_Reflective() +// { +// AbstractClassifierInstance parent = newDocumentation("od"); +// parent.setPropertyValue(Documentation_technical(), true); +// parent.setPropertyValue(Documentation_technical(), null); +// CollectionAssert.AreEqual(Collections.emptyList(), parent.CollectAllSetFeatures().ToList()); +// } +// +//// #endregion +// +//// #region enum +// +// @Test +// public void Enum_Init() +// { +// AbstractClassifierInstance parent = newMaterialGroup("od"); +// CollectionAssert.AreEqual(Collections.emptyList(), parent.CollectAllSetFeatures().ToList()); +// } +// +// @Test +// public void Enum_Set_Reflective() +// { +// AbstractClassifierInstance parent = newMaterialGroup("od"); +// parent.setPropertyValue(MaterialGroup_matterState(), MatterState_Gas()); +// CollectionAssert.AreEqual(Lists.newArrayList( MaterialGroup_matterState() ), +// parent.CollectAllSetFeatures().ToList()); +// } +// +// @Test +// public void Enum_Unset_Reflective() +// { +// AbstractClassifierInstance parent = newMaterialGroup("od"); +// parent.setPropertyValue(MaterialGroup_matterState(), MatterState_Gas()); +// parent.setPropertyValue(MaterialGroup_matterState(), null); +// CollectionAssert.AreEqual(Collections.emptyList(), parent.CollectAllSetFeatures().ToList()); +// } +// +//// #endregion +// +//// #endregion +// +//// #region containment +// +//// #region single +// +//// #region optional +// +// @Test +// public void ContainmentSingleOptional_Init() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// CollectionAssert.AreEqual(Collections.emptyList(), parent.CollectAllSetFeatures().ToList()); +// } +// +// @Test +// public void ContainmentSingleOptional_Set_Reflective() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// Node doc = newDocumentation("myId"); +// parent.addChild(Geometry_documentation(), doc); +// CollectionAssert.AreEqual(Lists.newArrayList( Geometry_documentation() ), +// parent.CollectAllSetFeatures().ToList()); +// } +// +// @Test +// public void ContainmentSingleOptional_Unset_Reflective() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// Node doc = newDocumentation("myId"); +// parent.addChild(Geometry_documentation(), doc); +// parent.addChild(Geometry_documentation(), null); +// CollectionAssert.AreEqual(Collections.emptyList(), parent.CollectAllSetFeatures().ToList()); +// } +// +//// #endregion +// +//// #region required +// +// @Test +// public void ContainmentSingleRequired_Init() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("g"); +// CollectionAssert.AreEqual(Collections.emptyList(), parent.CollectAllSetFeatures().ToList()); +// } +// +// @Test +// public void ContainmentSingleRequired_Set_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("g"); +// Node coord = newCoord("myId"); +// parent.addChild(OffsetDuplicate_offset(), coord); +// CollectionAssert.AreEqual(Lists.newArrayList( OffsetDuplicate_offset() ), +// parent.CollectAllSetFeatures().ToList()); +// } +// +//// #endregion +// +//// #endregion +// +//// #region multiple +// +//// #region optional +// +// @Test +// public void ContainmentMultipleOptional_Init() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// CollectionAssert.AreEqual(Collections.emptyList(), parent.CollectAllSetFeatures().ToList()); +// } +// +// @Test +// public void ContainmentMultipleOptional_Set_Reflective() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// parent.addChild(Geometry_shapes(), newCircle("myId")); +// CollectionAssert.AreEqual(Lists.newArrayList( Geometry_shapes() ), +// parent.CollectAllSetFeatures().ToList()); +// } +// +// @Test +// public void ContainmentMultipleOptional_Reset_Reflective() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// AbstractClassifierInstance value = newCircle("myId"); +// parent.addChild(Geometry_shapes(), value); +// parent.addChild(Geometry_shapes(), null); +// CollectionAssert.AreEqual(Collections.emptyList(), +// parent.CollectAllSetFeatures().ToList()); +// } +// +// @Test +// public void ContainmentMultipleOptional_Overwrite_Reflective() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// AbstractClassifierInstance value = newCircle("myA"); +// parent.addChild(Geometry_shapes(), value); +// parent.addChild(Geometry_shapes(), newCircle("myB")); +// CollectionAssert.AreEqual(Lists.newArrayList( Geometry_shapes() ), +// parent.CollectAllSetFeatures().ToList()); +// } +// +//// #endregion +// +//// #region required +// +// @Test +// public void ContainmentMultipleRequired_Init() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// CollectionAssert.AreEqual(Collections.emptyList(), parent.CollectAllSetFeatures().ToList()); +// } +// +// @Test +// public void ContainmentMultipleRequired_Set_Reflective() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// parent.addChild(Geometry_shapes(), newCircle("myId")); +// CollectionAssert.AreEqual(Lists.newArrayList( Geometry_shapes() ), +// parent.CollectAllSetFeatures().ToList()); +// } +// +// @Test +// public void ContainmentMultipleRequired_Overwrite_Reflective() +// { +// AbstractClassifierInstance parent = newGeometry("g"); +// Node valueA = newCircle("myA"); +// parent.addChild(Geometry_shapes(), valueA ); +// Node valueB = newCircle("myB"); +// parent.addChild(Geometry_shapes(), valueB); +// CollectionAssert.AreEqual(Lists.newArrayList( Geometry_shapes() ), +// parent.CollectAllSetFeatures().ToList()); +// } +// +//// #endregion +// +//// #endregion +// +//// #endregion +// +//// #region reference +// +//// #region single +// +//// #region optional +// +// @Test +// public void ReferenceSingleOptional_Init() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("g"); +// CollectionAssert.AreEqual(Collections.emptyList(), parent.CollectAllSetFeatures().ToList()); +// } +// +// @Test +// public void ReferenceSingleOptional_Set_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("g"); +// parent.addReferenceValue(OffsetDuplicate_altSource(), newLine("myId")); +// CollectionAssert.AreEqual(Lists.newArrayList( OffsetDuplicate_altSource() ), +// parent.CollectAllSetFeatures().ToList()); +// } +// +// @Test +// public void ReferenceSingleOptional_Unset_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("g"); +// parent.addReferenceValue(OffsetDuplicate_altSource(), newLine("myId")); +// parent.addReferenceValue(OffsetDuplicate_altSource(), null); +// CollectionAssert.AreEqual(Collections.emptyList(), parent.CollectAllSetFeatures().ToList()); +// } +// +//// #endregion +// +//// #region required +// +// @Test +// public void ReferenceSingleRequired_Init() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("g"); +// CollectionAssert.AreEqual(Collections.emptyList(), parent.CollectAllSetFeatures().ToList()); +// } +// +// @Test +// public void ReferenceSingleRequired_Set_Reflective() +// { +// AbstractClassifierInstance parent = newOffsetDuplicate("g"); +// parent.addReferenceValue(OffsetDuplicate_source(), newLine("myId")); +// CollectionAssert.AreEqual(Lists.newArrayList( OffsetDuplicate_source() ), +// parent.CollectAllSetFeatures().ToList()); +// } +// +//// #endregion +// +//// #endregion +// +//// #region multiple +// +//// #region optional +// +// @Test +// public void ReferenceMultipleOptional_Init() +// { +// AbstractClassifierInstance parent = newReferenceGeometry("g"); +// CollectionAssert.AreEqual(Collections.emptyList(), parent.CollectAllSetFeatures().ToList()); +// } +// +// @Test +// public void ReferenceMultipleOptional_Set_Reflective() +// { +// AbstractClassifierInstance parent = newReferenceGeometry("g"); +// parent.addReferenceValue(ReferenceGeometry_shapes(), newCircle("myId") ); +// CollectionAssert.AreEqual(Lists.newArrayList( ReferenceGeometry_shapes() ), +// parent.CollectAllSetFeatures().ToList()); +// } +// +// @Test +// public void ReferenceMultipleOptional_Reset_Reflective() +// { +// AbstractClassifierInstance parent = newReferenceGeometry("g"); +// AbstractClassifierInstance value = newCircle("myId"); +// parent.addReferenceValue(ReferenceGeometry_shapes(), value); +// parent.addReferenceValue(ReferenceGeometry_shapes(), null); +// CollectionAssert.AreEqual(Collections.emptyList(), +// parent.CollectAllSetFeatures().ToList()); +// } +// +// @Test +// public void ReferenceMultipleOptional_Overwrite_Reflective() +// { +// AbstractClassifierInstance parent = newReferenceGeometry("g"); +// AbstractClassifierInstance value = newCircle("myA"); +// parent.addReferenceValue(ReferenceGeometry_shapes(),value); +// parent.addReferenceValue(ReferenceGeometry_shapes(), newCircle("myB")); +// CollectionAssert.AreEqual(Lists.newArrayList( ReferenceGeometry_shapes()), +// parent.CollectAllSetFeatures().ToList()); +// } +// +//// #endregion +// +//// #region required +// +// @Test +// public void ReferenceMultipleRequired_Init() +// { +// AbstractClassifierInstance parent = newMaterialGroup("g"); +// CollectionAssert.AreEqual(Collections.emptyList(), parent.CollectAllSetFeatures().ToList()); +// } +// +// @Test +// public void ReferenceMultipleRequired_Set_Reflective() +// { +// AbstractClassifierInstance parent = newMaterialGroup("g"); +// parent.addReferenceValue(MaterialGroup_materials(), newCircle("myId") ); +// CollectionAssert.AreEqual(Lists.newArrayList( MaterialGroup_materials() ), +// parent.CollectAllSetFeatures().ToList()); +// } +// +// @Test +// public void ReferenceMultipleRequired_Overwrite_Reflective() +// { +// AbstractClassifierInstance parent = newMaterialGroup("g"); +// AbstractClassifierInstance valueA = newCircle("myA"); +// parent.addReferenceValue(MaterialGroup_materials(), valueA ); +// AbstractClassifierInstance valueB = newCircle("myB"); +// parent.addReferenceValue(MaterialGroup_materials(), valueB ); +// CollectionAssert.AreEqual(Lists.newArrayList( MaterialGroup_materials() ), +// parent.CollectAllSetFeatures().ToList()); +// } +// +//// #endregion +// +//// #endregion +// +//// #endregion +} \ No newline at end of file From cd9d2d23bd55d15a97faa7ec1d695d314d453703 Mon Sep 17 00:00:00 2001 From: Niko Stotz Date: Sat, 29 Jun 2024 15:24:23 +0200 Subject: [PATCH 4/4] trial to add generated Kotlin classes and first test --- core/build.gradle.kts | 2 + .../examples/shapes/m2/BillOfMaterials.class | Bin 0 -> 5519 bytes .../classes/examples/shapes/m2/Circle.class | Bin 0 -> 4219 bytes .../examples/shapes/m2/CompositeShape.class | Bin 0 -> 5654 bytes .../classes/examples/shapes/m2/Coord.class | Bin 0 -> 2583 bytes .../examples/shapes/m2/Documentation.class | Bin 0 -> 2741 bytes .../classes/examples/shapes/m2/Geometry.class | Bin 0 -> 3477 bytes .../classes/examples/shapes/m2/IShape.class | Bin 0 -> 696 bytes .../classes/examples/shapes/m2/Line.class | Bin 0 -> 4312 bytes .../examples/shapes/m2/MaterialGroup.class | Bin 0 -> 4544 bytes .../examples/shapes/m2/MatterState.class | Bin 0 -> 1901 bytes .../examples/shapes/m2/OffsetDuplicate.class | Bin 0 -> 6656 bytes .../shapes/m2/ReferenceGeometry.class | Bin 0 -> 2797 bytes .../classes/examples/shapes/m2/Shape.class | Bin 0 -> 2326 bytes .../test/PropertyTests_Boolean_Optional.java | 143 ++++++++++++++++++ 15 files changed, 145 insertions(+) create mode 100644 core/src/test/classes/examples/shapes/m2/BillOfMaterials.class create mode 100644 core/src/test/classes/examples/shapes/m2/Circle.class create mode 100644 core/src/test/classes/examples/shapes/m2/CompositeShape.class create mode 100644 core/src/test/classes/examples/shapes/m2/Coord.class create mode 100644 core/src/test/classes/examples/shapes/m2/Documentation.class create mode 100644 core/src/test/classes/examples/shapes/m2/Geometry.class create mode 100644 core/src/test/classes/examples/shapes/m2/IShape.class create mode 100644 core/src/test/classes/examples/shapes/m2/Line.class create mode 100644 core/src/test/classes/examples/shapes/m2/MaterialGroup.class create mode 100644 core/src/test/classes/examples/shapes/m2/MatterState.class create mode 100644 core/src/test/classes/examples/shapes/m2/OffsetDuplicate.class create mode 100644 core/src/test/classes/examples/shapes/m2/ReferenceGeometry.class create mode 100644 core/src/test/classes/examples/shapes/m2/Shape.class create mode 100644 core/src/test/java/lionweb/core/m2/generated/test/PropertyTests_Boolean_Optional.java diff --git a/core/build.gradle.kts b/core/build.gradle.kts index 0d6b0d5e..7cc023c9 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -27,6 +27,8 @@ val javadocConfig by configurations.creating { dependencies { // Use JUnit test framework. testImplementation(libs.junit) + testImplementation("com.strumenta.kolasu:kolasu-core:1.5.61") + testImplementation(files("src/test/classes")) // This dependency is exported to consumers, that is to say found on their compile classpath. api("org.apache.commons:commons-math3:3.6.1") diff --git a/core/src/test/classes/examples/shapes/m2/BillOfMaterials.class b/core/src/test/classes/examples/shapes/m2/BillOfMaterials.class new file mode 100644 index 0000000000000000000000000000000000000000..5715fe7a502cb80ef0f509ef92f5d31e2ecb0bd4 GIT binary patch literal 5519 zcmcIn-A^3X760AY?`45u0UH+E?BaC{3+n|!?AQ<-J8{Aizz#S#iPI*-GQhy@EZI9t zoVKd+l)N`mrR1@d+CKQ9kzyxmrOI_wRmyw+mp)Wg&z+eaW`;3lBNd4|_uP-){hg0{ z?%5yz`sQq+wV~=2bzP}8)!C(8oil+0DqU&`-F|<1MSDMwTvQbrM8O|TKtZs;vv?{tS?8W0qGMwA18&yp& z?H<%hnohpfm1?Q18x1-|tB}`I4E>cIwX(Nj?Z2Zml$uHl87_`mPOB>VcIo!Uu3Bli z%^X=1Alu}Y6uQuzL?>j1gid2zhKhj-ut<8?C^$?CTP{ zNv+piaZWKqdIUs`mp4N&C;WX;6}Z^zi2qw+5Avm7b&(6BNy<1kDXxTv@^;E( z_%SdT`~YpF8J}r>f;Y<+g!@G}k%LpXj#q`2Z!pAn6u$EsRTJi8P-YlAaTO86VhRf= zC-D}RDDRsI#6>2Cl_YM9sqFItGlsX5SQSg74VBXq#lVP5RQ;2b&VJetG zl?sth)D5cK>iRu(;|AyTie{E4lzT&aDy5ZPYKy+uWawG4>yKsCP&O4qq4iSjAVh^J z6HP)iAk**B_ybKylhoUsV(cGJKATQT1Csgw26!j!i~Mio2w!oXAL%v8TU_N^)|sM;>(V zT=?Ph&|eL5XE(wW%9gO)cvO8rP_JzHwMk(@SV& zpYA11S67;~4YhGs6xiZc)+dq6wa45hNStnAy{l56#5qoTf{ z3E)8+WBmvlOi@-0Q{0E?OC>F}oFoZ9he6*c=^Zy^s%V|L51qM$IY%|_Gv}zFC5#r9 zSl>f3Jvs=XNz#|JGeY0uM7ra9^c2&*)DDKz{q!k(hk?TQBb+HrJi>6H_z1beVE7U8 z-)gC-p3qL{BInE`L$f z-((8Q1Tj3IvB9uy19CTs?zRUPF>32kq8R}jDSV4Ff2NKE!A}?v#7%HXSqp3~))`}t zX@r@3P{6nic#RMwfnZwTP-8dZDQktJU6eG)&?y%7gvmc9cv;|=Pzqo>>}R|BOtzB_ zTg#DCn6?35wb`b|(=)$s8iO-BFSEbG{qE*?Up0LPUW83b3#17KoULQq(`ozTygsSTInHr|m;v={5PuN85(r{?_~an-j>+9jOp^zJc+E`3AzgZ5 z<}EU#$VS$pXS3YvF`WQ@LZ{gLpmzd~H(oTdIq#O@C-_eWxOKey5!k>eyJXi@%JxL~UA7;joC zd`c)$gi{?IorF!bt$jk>zRz<4`k#n}{)nXLKF0FgkUYFY{o%*B^HEF4xrO{=tkKLv z!j>RTh(PL~(z_L&y%-}E-l3yN1>15A>$qnJ`)}wg((%2*_#Y4nKOFx%q^}VPJsf`m zX<5*ip#Sf2-y9TFNFH{{Ig)cOIZtxFC5I1rbs`#z{|9|BNZsAt4nI2C@#j5!fS(al z=lWRB;V(?x8u%rBe@}Ejq9qE)1}dcN=6!_9P|MgVV;eivg;vHc_U?mmR8hN+3mh+S z=p2I_8IC$fl4GA^gd@$-#}VatiKE1EnPZyc3dhSFS2?b6T;iDGxX3ZeQQ#QonB|z` Vc!gu0<2uK>3H5>5E|~4d{{x!X1@iy^ literal 0 HcmV?d00001 diff --git a/core/src/test/classes/examples/shapes/m2/Circle.class b/core/src/test/classes/examples/shapes/m2/Circle.class new file mode 100644 index 0000000000000000000000000000000000000000..2cba8184c4cc84534aa49c415871eb1d2d128fee GIT binary patch literal 4219 zcmbtWT~iy^8GepfNh={>k&Vr#EgOhIfCbq3GSrC!NiA296bP~Fw8szIlIu3M7bZ6aMk{V(r?h8zTMg58WXW_K zH?Sp3tFE`&tko6-GCpp)k~(yO3;V8Dvz^l3VZCHKp4D*7TB+qxKBta@%^#cb?b4TdO(B+h1`p-VI)9@&?}@Kb#mm#JW0EU0o!WmyLt2s!0{Y&)o3fv;n6gnDr%{||`e$c4ft zj;*g2>P7rap?*g|-!DRKI!(H4{(~n+~uD7cuXLOu|f&z0D7H&yRE&mZH?YlKoHcK@= z2A^A7r3%-NtgTy8x>Y-PBG^{@7Rxrv?@W*%hVR8#T(LZJ+w@GrPSg)O_<{-b$*2!F zul9NV&{oteciVG9G@pMlpH1{9{NM90T8q)0Rg|Ioi{k6&Np=ROilry?qu=ZO)KAQc zcgFK6BQcnm?cl0$O>#|fO>@<`W{&=pN*LKY8DmIE-TvXr4(^AQWVjzu(&7Gs((w0l z#zpSwMAs961Aphc@OQowf9JcQlDKomC{XFrylz|`)cVEj=@$JPmk}1i%#P)J;#rbao$=Z7>OS{FYfZsHx0w582z zy>m!^M#&C=>^@Cm8+Kx8C4) zkhaeF7;?CXE{vfYljuQ-EiB2u9@yvkI4ODx@1S-HdBQ(ac>UH=k3BJYJnhrMD+U); zNmUmXcm-EN_$5-zHj>5fFz^>{5>S{_Y`}j}%6~2p2>nMRCon;zK^)%Zs*vQS@>BlR zdFSIhDtoEW-nl@ob)OuHeohqPv_cbLoW@LOI*M`lB*v~&F<1_7L)~3cFAh!~@p5nhS-Px$rk6?oCaP z3~1luEtRIgZqVn2R)!0$J}bm5OmgUnG9qc50R z(8KD2T}Y+%f8lHziJn}v>Ni@c+Q7&7HG#LP{v+xoaOi(se9rY7(!Zg|Cla5+WCphG zqoa&!8QW!8c)%@o%GiZ{A3|ae`}gsR#JEIFLYFu%VMx>^M*MGH;*vy4;=07E60b?T xE-@`JBXL!tBrz*7CowN^O)5KABqk&#CEk#DQ{slig2bZ4hrYFs{qM4b^B+tkWD)=X literal 0 HcmV?d00001 diff --git a/core/src/test/classes/examples/shapes/m2/CompositeShape.class b/core/src/test/classes/examples/shapes/m2/CompositeShape.class new file mode 100644 index 0000000000000000000000000000000000000000..4ba2148cce762a4cf6c8c18ee9b4df26ac72f014 GIT binary patch literal 5654 zcmcIoYf~H78Geq?WhDeG0&Ffe<|1Pxffq1NY8zu?@I@{V*QCUW+a!xviv?*#bXLUa zC86z1`Ug6hX+EYioqq6#cBa^wcBbQ!Z~4%F(SOnD^gU-6v066Zv?&97&U-G;`<(Z7 z&hYiW|ME8g)A$v`pz%~MZ?JVkid2&>gVMoo!->&X|^I z&oWd;7Xub9R0_4SVcEKER;+7_oBEEfm2|79t=Lu5D!L;z+bn5|Cby5u0hoEI{aR*~ z;n{bgbS8+nt7O*C=!C_`(;Z%{REyfCVXswn)8d+LSrx}LTwAW#%e7MJ8be&VgDl4t z#2NaxDt5`Vw9TEeW?HsUwe*sfw}kz;S>Q1=GjtU;jKY=+@j$QYWrG$nTp0D3{Ef9u zqi|qiuM;w>NwlCffh5`(!WQjT(9RIq)~hy==wN7BH@Uu6GS&%P40SOm#*SGMqJq;5 z#((FDptCI)PxM;Jp08NkuGR{6rMje7w~Q)zJc$T;5(uN0VJOILjq#R59B1MP;VeVS zV+l9-l4!>{F+ISbI@5=dm_!GL#N==iT~6;jLtl_mH&&83jSFJOC>hb-Fge3;(DKF{ zBZnu8hAm@S_?#gfr=WVfBlGIHG#K$Qx3Zr-cH~hF%_*EoT@zoBb8C(gPLBV8rV>64i5AV z)yCs)P`Wd(RFJ~s=Lv;giyl7bO*#@T!jLT_$af|wW4{Mff zmW{l%V{((SYVPo@Dps0BOSfxPDi&d<*^= zxOCGyuhj+xEi1NO*jm!J-EE1LO08Nj?wA6&$HiDZ!VHsC%fb}$5o+n}N9X(rNl|JQ zYD40|cVvv-c{KA=IbZaxrXc|AscverxiR(vec9X|`mD!MO25^g1 zU&k0`>A*Me8g60+b2K`Gk7>=UqZV1@NFoBRDMU{gASB1cu|;*57tdR1w0ZG>r2{yo zh~X2OJr{9p=U6c4JBD$B6erebEd>`M**~NIkJJf4a2DnV@fF;X&H|U4*EtLq3BUom zNv&X+%%vu!fygq4HV}AG7w?p_u71`eCZyX1_n2TK{LV0iOD?pRzwaoGh5 z;5g{#=->r$6k*uFv7Oxbx*IuOj%h!~8vz_0kA1Hpc-wIWS6#pWu4zA42RDf85OH-h zT=R3D3FJKD=X~>(IbT1H^N63bgZnKx&r-@9jn|By^IQODZ@jis*3Er$EO>I(iB|_N zh^r_gzF4?bUWY{)5gBCq*+uzNSlU_W{DLfxa@%`ysuHU~%E?LZJ27OxI+r|u^& z6X~ZQkVfCoyOwI2C`zAD#S~>&JE;u+6`{9tW8*#Hp2!P)Uxb6B#wn*-y~Jqsa;nwK zsV4qgAj_#%FQ-~VIn6gD=c|-fHI79r5eab$gU%pI*WaqP zetNkpswyPJY0=2lFiEN_Wv)i(vXMu8jyIem?h#cb~Ph=iZz{*KV+h%`ORy+mk95E-MtFR?BM1sReDJ#w1lv_~ExdBh`UNX{I{ zVL>j0UHY~n7E}I(&KN>%^doc3$<<=r@kR2&6QW+v)%WH0U&!xA_$9S_1h+v;OpZ-# z(Op`4jHW!wd02T=uuWZjkVh5#F&Kx9+GFIn_}$_3k3XE@Xy^ElqeFf#aCC8;=7@64 zaJMEmoa%iu$yD(es+iacCNbDqh_dezR3~8@^+&c{NA0?7Fw?*6anYaYQu4 zW~+^=KSyP>R4R=vYKV-EEv6AgJP8A)25p1?QW{C563~$*x}QdOfDRCSl}08&JsJ#u zwJJ39mG`4ILz@-XzoinD2!sO0s7fB6C7d`%KGNuRuq_4ACjp{J@?`5?gU6cM38r^~ zQ?#yl>-Sj)b+T6x8ZLXy75lF1FEyQNL)cEE;rWhV^{6j+{z9u(n~^1nC0T&iG^AzV zk!AODr&aSclt=du&Z3secb$8VU2_^M_O+$EZpEJ&+utFLV;Gis#x$6#j#$0OR%ys= z$0#*?cg1bSae_x=+1Q(LoJ?W@Hrv>Ag(4Mmzi2r%wjwtglAlE!dDWqLVrQx5vRP5j zUv--rdR~sAVX7QDV>MRpOLxgGQ-16&ofpEZR8>70FtX;dDG9C4P7^Vr?NKhthcR4_F7+enoiyI-R3U042fd@Q*;#vp28{)K1KEy<#m;7o*uwK zM(#xdImXB%%ijllT2%RZxsxLTrOeB+Qj?i=rODh8zB2QS5@fb1rB$@}E4rRg(IHbw zV$xNHP6r0<&>0kPh)*Q#cW5mG#}wslqC36wfkoR}M($I@GUyK_VeKW63neiSPQuzt zBJkdy#9%0i>|PT2P!fm3N$hA@P>H~Me-c9-62q+Qu6AgliI0RjsM3Wy91V3)#|(Gi zmw=6vO}@;jle3)q6Z-A`fx%~Z{b$0!Ef~90r@N`n*rhsSmy+LTj$K(!3jIa^D}mz} zr7ja(WcV26iJW14{T)m>iL*H)+SaYJIV0ZIvvWl<_zlH?!92a9h@?|;(#JbTEVsvU zL`M1@le7KS&?$t$> F{{hah#0dZZ literal 0 HcmV?d00001 diff --git a/core/src/test/classes/examples/shapes/m2/Documentation.class b/core/src/test/classes/examples/shapes/m2/Documentation.class new file mode 100644 index 0000000000000000000000000000000000000000..4249aeb477e08f423227584bf8661136f9df92ef GIT binary patch literal 2741 zcma)7+fy4=82_D3ve_&tY*NCV(o))nq;!Fz)k1IdVnYM1rP3DEb_pw4*z97?2J4LD z^r`*_&ghFXJ~%$~L1*k`bjCsY=HKF<;5dF~cN>zzh{NQZ@B8+<{Jz`a&wqaX9l!)0 zG8{G^8I=v&Br z=4!S*$q@C-N1g(O;n2G4*_NZPZB}&4@yx1Y*m}Vc9=TQGai|QLQrRr6ht{`@s!=gX zk>Nxmh?~o6X33k}4QqHIi6joFXhADOBrEtBG!;>#7}C29l2C9k0SWC43C}E*9jj#6 z3~Vup4s?nyT_T0D#Tf>R`&F0Hjjx*C9m<%YJv+QRASv+I3Yo^7!orHW#-~VSa-?yDyEQ)A>*Hb1QyHub)#SFaIMCx-rO z2WSC|W!t2wP>ia1Rk+%BlIy;cxQI()lBXGBu2&XY&^W=NBEwj5&vmwG+dngx^&;JO z&E-p+yCuti0|-xK-K2R)(K*ueJdmsyZt1M)87qcokhWCWjL-|i#E}pOXhYUX{>T#C zC{Zgka(`_-9#W+)$^UIVRwb=f^{*CHQd)^6#^)8flY@?I*1iOyKN^DsfF2j4BCDrO!T|=Fcr!l0F~MTDO0cJ4Md4 zSx5FR{?1!U<)dn8VK+urP3M7Ua@w54y#GR4ACAD6P*L8=;vx@7Ag%^O_|b zcZWU}cA>!-tzVRyF3}&oos`=>;$*txzLZ`~x?6~+H-mKU6Ze2_F({dQI`I;1xfe+1 z^3RaT^*uxP&%W6rooR9`V-_lIpbbT|V+KnkKO7jN2ff6Rn=r7TL^uf_k~ATO7=RS| z&>zOuNlGn1EcXjCKM^58#1eo(afJV5pb+|ROecjy7ziC*q+1f&`ScNygh*fqyYMH6 z{yGA^I^HB@APOZ=#swNtsT2lrlxR_(MvUE0NzjO~xCh1*hHxx2J{#habG=Q~3^EL? z14MEikxYm>$v%bS^+E|SO@(561a2e`}?C`egj3!L9ss;lHKQW z`M&4SgSa1&S`<=?N~ZLmBXn>ftZ=6=eU7)LdbNQv(cLd`_Tf~oXjlMQlv$zCox~JL zKqU@Fmf;-E(>H;pLbphKBA5RGvFOwMACSI9Eb=tJ1!-19I7z>kxa6ym$T6B^NA zGz7>NMB~ceXpcim`fUn2JW;RK1g_vJfvC^i1+tRxv47sBjRd|R{u-&g$8jA6D$&dm zA_d$ipjec}EOqWkG@ z^PFLbXdaqI;@wF>-B{@ZuqrmP}p9>bjWE|)4UJUQ!1BSlCk|Tnt7^cP6a9QV$%ZzZt`WF?g zNX60aMWVLkM;=n*9dz-~t)nd$b*eL2E9=(;)S;Kht`-mDxPq(V^0>wjvg|c+@g(<) z#xT|({=qrIFrN3l=Zkb%eyK0hRc@L0^yN#OTLr_pLWzH1L#GsvQ#-aBbB09TyF+Jn zTU*g=jW$Z9tpGhZOf*r^fPrn$`cp&9vNT#5XRLMm`RSO{DLKE}&tsC(Umc27xtW%l zV$K(8oL;6*-uX`M+_WGp&lU_wDA} zZv!(?B_X~$<3S}!V*+ZCrCN{)ndS}*ZDTWSN*irEG9fGN-N8Gu!K-V;m; zlb|WT^739xss%5SW2?IP$ksVkZ`8fxPj5J5W7X8`N|}l$HD57pqon7|ErT1Bs+acO zO}g0J3Tw?9rao6GE$ijGBArDVS_Q4RsFe*d_ZEj5v8oSd9cc4{tra$AwN1|~wqRAt z1^v1qfV(`5#eHlrPL&^|43g-FUPWp@b7nbwPJNhEk)1g`fi$jNYoa;bYY5;G?a;|m zWMV3ljJ<&}noLrgevS5Y<|R7Qqc4&A%>jB$ZIX_RqX!C7XvZ;h(~m~$eJ%v8^w5mJ z97+@$8VLfsVO@oW})PAp_45hKso5#d(u@A;n}m^D{!h7n#2y z{fJQDMP?h)tT#~gXgl1g(+2;^`phub;a!8{GIki%VkvINGlhKd!^#24-a-8BA<{05P&e6-!&oRJ}=E!i2a$IywZaD2Zr(OCVcy<)r literal 0 HcmV?d00001 diff --git a/core/src/test/classes/examples/shapes/m2/IShape.class b/core/src/test/classes/examples/shapes/m2/IShape.class new file mode 100644 index 0000000000000000000000000000000000000000..341b3534b7ea9c62b3e473d3bfd74f1bd4ea1147 GIT binary patch literal 696 zcmaJ<%Wl&^6g^|NaT7vG%PXP0p;d)crj6LKp#mXUG6hkIF0w$A_!3-?$5rmQw7Yx` z-@pPzEcqzJbwP+qZ5Q|4$DDcGbLZ!;Z{Gnt!$XB09hu_55^Mf!4#X9G9q-m*1f|f~ zH-|=B;s={Il6~VceZf`@yCX3x0fUNc%zBS6E5T zRZi|(J-e0D5()3gMZ8lA3AyuEiH$M2kDk~oteyLa$FJyx*TCeq5XeFp?NZ8 zewxcM?btb*yp%CAvB@29Xk#9i2MA*<#<&urgCz;E9OEjk4WJm;abtiv M#!W_-(PP~D4L<|BJ^%m! literal 0 HcmV?d00001 diff --git a/core/src/test/classes/examples/shapes/m2/Line.class b/core/src/test/classes/examples/shapes/m2/Line.class new file mode 100644 index 0000000000000000000000000000000000000000..89d1497650cc2ec43c6220edf4d143a2167a4f62 GIT binary patch literal 4312 zcmcIn-A@}=7XRJBA7f*};6Q>QAt43_Y>0sn+6FdlzPfP=G@E20X|^AOnZjUuhWd`P z-IrCQmAdbJsMKm7R{OBphe+E>o3v`BRhGW>Z>p+2=g!2j%`~o7S|R41bMN{1osWAi z{P5Ga{|2xKDRA8S*sSeWEm@Si<~}X8h2pC1SaAq};gG{SEEY$PKy1Z!Z10jlWok7< z@S0n0)GWs{J==AbSNF_^X0d8IJHt-5JD zvS>Pv>pPLfb=O;ORIAGZ2^9`ukUDgMv5M>VGP~hxT3;4IU_N=lO63+BS3Mup@(TgJj5r?#O7y?o0nRQP`TA;^r zwsi~&SpQqX!eY2)eP}kS-c{F;UcFKF-1?eXuUPeE#uLS{BqBI2a3(Cg)~mF*y$7oed-LQ!`ro~*)m~z+-+2_)Q;t;-r|}G zOiWFO3AaNgE!n0u`3n-uJrrLdz1i0<>Btj9p4X{d0)yoAP@j?j3Ht&=t*sCwhVAJL zp6e`dA{@A%9g<|gzU0YJu)ZK0jgiso&NdOGqljeLt?j!GU8;G37tBH{bH0^Xq|}$) z{XYo&Db!heIuFMlR)Vf~G)zeqnHw^eq~2Je!ZECgZNGa3{uv5SX@!~lf8Z{)gdg1U z&=w3rxrk*B|xPq%mT*sRNMrY5(aU+QmAB9a| zRe(6&N@A5oVs%T>1P~D9I%a*;FspQb+B)@lIPcKCdfD`((P?f~`8Mii-MY@Ex{kl5 z?G*0dE|0(8($I6gT^^mSb0iQHm|vwfF7mii&qJ}|R!!L`R_U4ey|qQJkLzq&TbHGD z%eMb`P+}_}6wwaqFYI|M? z@7bfdq&BRn-)E1Si*Y0waGHKBsTsYBHE55w4V@PK;LrN-vquZsoVYTXjv3mBHrGRI zgw`mnFbxHOEv6ZXn+ao>rEYxxNe|H(mJH|-mI~<6COvPQAex-$y5>7jlyadc z36^PK`u{#oXx|-+#vL#%cEq(c<=q59;2*Cr1bvhdL6`lSc2E zh@LX~=vXoH0u0I*v}oZ z-l%O^^}F28+=g!1tZtZfoB3dKqSIFM$!{~-N7K4oSu^(owd5VQQ7>C>+H5!z*w{FP z2J*eb-uXpPgV@oRc$kDks$d-RBQ>^B1!UpS`J(Sdof3H$Ra|H9~(L}*}KoH3AB#*p#_0t~JB6oh;_F!Tnkj3!k`7gYEZ_lr2$UM#S8%$IA% zl%lA)Qj9vzXnfQ&m<>#~VjSzlIN25BIm)OXYzW4&PK>_2FpS(eZ5RhIry7nMq7~zK zC&pYCj00G}`Jcx)-igt-7lx6$wgcm0D8_6j#7?+y;n56*P z`cZVn^-8l*T9s9!bXR`0nVnW;Rl)AcuZ1eB)OJ^~>YVa`0{p>LL4%+>~ z%xos|HGai~^R4^CA=kV}x#n=lHHSlv|1(g-Ar}mX)(iadL183t39pkg26>kt^2J;k zibnqUIdq;Et3%OfK##2rMdJZIzCIK+bYc=Dl)V_CQAp6A;<68YpRB|XN%i*jk!|{e zEbwrjZU9e^c{cqNzg`(NPVEvs_7pcic+QMJ#affe`pjce@-xEirqf7T$J?|+rh?oE z+`?~y3-&3kJS;c!g});jd0hApv@a0td0cn~ZH;};(C;_cP@C+Z_^}p#ocQq;K1+P| zIUiv#8aT#2#Nzso7>q;f@9$S_>|ck?X2mwKiF<^!d1Y@a?T^%V4|Q7qO4ja^$U71b z@H;BPyARM)!h0pWU&044iNsb3Wo$oykg)LK158LvO6*AbzXur!LtP|`m( zSd^HTxFB&}Vn$+C;+#ZLA}4WHVoG9KVoqW~VoBl^iB~0Flej2xOPShK-z(~C{}(vA Bd0+ql literal 0 HcmV?d00001 diff --git a/core/src/test/classes/examples/shapes/m2/MaterialGroup.class b/core/src/test/classes/examples/shapes/m2/MaterialGroup.class new file mode 100644 index 0000000000000000000000000000000000000000..11b3ba62f404e3d19d6e32c4b4bad89e442553a7 GIT binary patch literal 4544 zcmb_eT~iy^8Gg=6NGl=3N(2Xkg%v|E2xI|v(hsN|$0V_cASt-ShP25d*07)tqO)?- zn~bmAnO=7~(_VI_NiTfS&eTq(ooQX?uD_|%>2r1$vBC>BGrrjKweS0!=lwe8{O5mv z|0jT}XbR-4FU{J1)sjWIWA3x7%@&tT$7Q3<>15PYtD0^W*s&uUurinV4|TNDj}Dy=H6 za}#R<4`1P4^C#?e?L|aJ%8llBao2J-o2FftMYCRS&{n&_@p8jiZdI#u0^K#!Iq-sx zguw7#!>QW!;_m%g(XR7X-K-W%b*D)TyCUQ07U-|+Sd~2=R%yh1W3Mxs_00g+D@HT#+O#6v| zzGKRro4nuLW3j~3I^;46q)Hq&Qn-$Hl6V(41twm)>f?AXiT9O`ar8uw<5m(S^()r2 zB#&wVK_)TlioU8&f;ZRjxufMc5i)HqoSerMbY*cLb(xqvUJ&X07W?SgU zUapn>TX)HF%q`O~DXrD+NBAfbs!6B@bo3tAzqHkCnxm~5A<9o5Tuy2On)^L{5bWGl zy)UU5-AVPwVB_{WJN?VY?nowPXoK2xB$G0tgL)>K(WYb5U0jWGHTLX} zG0o5y6Gp$1x%K_S$YQT?_E64UNf@syS$AA81~?|Tu4^9fY!62PX!nl`P6e^pXPl$L z;H+*84MqpV^!Z!g|1QD}vs@kKSgZ_sRPH=`*h4x!G+;2QCyeC9sNQX)R&qh`PN6eK z4~2RSgBY%noxjsYhQIra*Pi`3#tU8B;<5ZjcyJG&mkbZ1VffK5Y+Lou980ni67IW2 zUf$z)Xr)zm?3z`o-?ydB?7ngM0#lOqcHMMZP1bVME9u^{UALB7wN0yeTUCR~;zq@+ zu9s0Hz&bWK!y^+;m7>yFos{NuyuhL+zdN1pK{&eoB+y zm=E+0dre7CX2zAJ%F09A6kg27JL}1{ZAsyh8v(^PuGpv$q%lFGJ%#= zZL%Y7X-uKu1BP(T9_8xchH)JtMQ?}8u8#wpi) z=T{FejH}AjBYwToj{OLKcEn!1kk{3AP=d;CP{NeM1MybdOF zF6%|raQ68+`vLO<+CpySHPNMH{0+(dD@ zNk%dDQ~lBCSHFj@s;b-{?efRjrT%E#ALo|yr1%8aJc`K?j{spGd^IMX`sq# zR3SaV!u*hNVTa@F6MXRb!6f$ti<~^7oM)>_1s&({Au$UKf8Z1}T>t<8 literal 0 HcmV?d00001 diff --git a/core/src/test/classes/examples/shapes/m2/MatterState.class b/core/src/test/classes/examples/shapes/m2/MatterState.class new file mode 100644 index 0000000000000000000000000000000000000000..c84a77fd5923e7f2182fc77369b683ec43830439 GIT binary patch literal 1901 zcma)6ZC4vb6n$j%>X7L5X73(o?J#s8z zh==?UO|6o#&VAo%SA6bUDi}klyvz5w;c&NUth$}nLiuc``NesLfq(m`h%&?%Y}fV| z8HTfcAuE2{cAN8NuF4R}=Bhg4P?Lxu!4UNy+Ja%?yo?OVj788gE^k>3>C@pEE`}Cf zd&hRU!@x{Jw9lQ6MHwcux!ULr9zKT~E zVhzW03GGle*M~PWnAb6iu_Q)tS;Y{88UWq=nql@oxXYaneXiea#o+2C>Vm~Hw*OZfO_sfO)7Z8A zdYjv>Fu3b_)R?wM@`mScbR37$XqnZG?JZLlX6(gqbYzi}70DBynP-)c3D2>2bQGY= zy=&AIj{QwXE)~P2Y3j=+7dmD_eU=g~H0a3G%Nhzv@=9nZYM9aSHqufjOqXhX{03yI zxIy?{#MT-$#Rm)*B#r;jTgaY@at7ZzmT@zQC9E(^mm6No5PrMUvRt1Vdmh!iV>raz zw^rRK(|p&eFAL!{?0`>#9NDwJV;H2d(Dw$=QJ!(SZuxwN`CR8rAm+Q|$)LsR_w4P9F5m(O4zTM1=l;nx7hfg5)nG zD!5CdY$o7KGJSy0NSX-Ea6ty8pNfkZAbzAYh!k1hBUyol1TG;>J2L!mU_sFiG5jmW zyLk0yTBX9#^?t2qlO-=1Cz)3A$9TO9McS|+s~+xPl5$C}4Bj9dGIA=|0iuVP3S)-( z-^6{|jnnR1!J+A1kSslm*{s#3nwefeCzytr}DTU7#YQ MP!K2z%m{4%4fr6zhyVZp literal 0 HcmV?d00001 diff --git a/core/src/test/classes/examples/shapes/m2/OffsetDuplicate.class b/core/src/test/classes/examples/shapes/m2/OffsetDuplicate.class new file mode 100644 index 0000000000000000000000000000000000000000..fc19a796b54ba363a3ffa681609f3cd818454684 GIT binary patch literal 6656 zcmc&(-E$My7609}zAR+C7B<-CGXjGpS;#U8No)fF3|PcADNYRuX_K|Q*uv7v(OntR zkA!}aem!TVed$ae+CK2m&cr0s&U7ew=uG=B^sWC!r}Uh=%X%emEz{`?fcM^W?>T3G z=iKvg*Zl3@fBZ9mm+^CflzGpnu2oE#mn+5^4b`#ywcEF)X-_rQD&>-4n^6dX{s6vt zmWZN5ATn9D%Jx}-$HOxLj8nBzqiR~VVV7&x#LOLI-N;uAYdJq}*UQ%OM3BtITCKh` zF;l8l^U|(6;`!BD#gL7BwYFqd^4HDVX5F+(=7Ldan1M=KUfdR1dO_eHFU*9=AU`N4 zPn`X~nRj%iR$tEFG3~{=QMP2>u&kPMFfu<^v*#L>%7nnN?YM}=Sge@D)~SMqyewmg z3mjUl*_E=Dzq4M=mo3|@TSg^cwD^!^xg?`V2=tX!%+jj+rnii`Q8kHC;KZ;mF0L)! zF-vwpq@))T*p2Qux}Xb$ERv2PNdZ_>F&jfKtu84%dj;asEY&HJ72Pjj{%=PcWYv^; z+h|nmi#3a*vt-xmvqpW@tWPk)Fb3lYVLzo;(2+JrWdd;=?1Y9x0!g0_+}ubYi6gxI zlE7e)HYZUM=*3ZHJ4UBsRP6a$qh2xvvd@u02^_}>)-jyGUI$YqfqrK;LXNdp%93Lv zAdgyV2E|5V*|b&gvinJDI2|O{>GlP<$T# zZL5jnXdjf5!_R?)O}Y9U0^34S$47o~!i0~;nRU_HyqCWMU9{t;pT@*Od?qs5PCxIKd8OOW0C7`$ZCyH;x@lDdD`AgJfQ^cV3lts zBonULD}1Z*H*}X#;L6TR?Y8+MPzcskp=q4hn!e>$%9YwG9m zeQ(fr$9)v<#}3CeeV1C*X^VID7!9!}pT_zh-yhRP#f3A;h^`H4qa8GcXbjUBp)s1= zt;YuA$xxEG`o(A`t;b!yT|7Sdbwtw>S3C8Wn413TK?luKG!MJ;qco4Id5?a~ugTpX z^2r_d=Ck?p@#d4y zeA0dTUfSNL_tUll-Yh+!57PF2{Qzw%#Le3WmGVPMxjLg}<%iYw5xw`x?;Okb8+*&zKBB4Rp#wi6slOAdD2>Hza@UvW8AjC^Hb+KsqxJ-as}p5ZOTP4+_cydZx&kTyPSnF^Wl= zUBDQok;SLPH|+qR-8@kQ#dQ$R*e#k`V`p%UDe{Mja%GV}Ovn^oV>2VJTcY?etqn!U zPWEl{lReeEGOEsoeUYaf3PFT3pX2cFX`+GcU_~Gc7;C~|aIyN2P>@BZNP-o;K_jD1 zWRtHb*OAXQ{lfYpuD-nvpJ#i5eiOq7#uh{wjbp)Syh@C%7*nknb8RuchSyz10T@%Q z7#)2<7&%y*F!o>^69E{9S}~q%gRzI=)HnQg`zp_g)`2YGZ$WcJ{4AjVuP#<8{-uWX0WS5=(sarEsFg`vB&PIuh$!8qvg2W*j<{5AoC?S@7d*m(Y}&Px08$ES8mx^;Fmwbdz1V1!z(mTJ;M7RJR^o4VbLSfe?_$8w}>;4M=-thEJ=Gr z&LJMsdo}Re_d|Qi(GZ13DI}g!2Xp2c{fEG_dJ)4MZey9C0SoR~39O(@O4wna)5tyi zZYKL1ghLOre}VQ(ggYK)A48jE3r6VYOH|b&TS0WnM-LG_r+svm=&X;<5uJNR zhc>P0Ml2fp7kbH>ZvNw0K-jz(y9*07vc>BmeAXI%s-EAcs0Ii>J|vd9goI6Zk;W}_ z6tP~!-6HPcBbwq{MSL6IxdkEdU3`2CdCC7ik@OpB9F#~(+?VK;I4W^m;)KLriGGQQ z#94`R66Yl@NK8o-BrZvuk~l5#s>Ev&uS<+eOh`;hoRPRJaYbTOVoYLMq9}1y;!TMe TiCKv`i52xOOFeI>=lA{tw&Ci% literal 0 HcmV?d00001 diff --git a/core/src/test/classes/examples/shapes/m2/ReferenceGeometry.class b/core/src/test/classes/examples/shapes/m2/ReferenceGeometry.class new file mode 100644 index 0000000000000000000000000000000000000000..882170b83989fcb4452e59a003a20a9739a6523f GIT binary patch literal 2797 zcmb7G%~Kpz5dXc|ui0UNSqO$eObj3_Y+x3QUjd0EhOlHI7FhVfA@x{ZU|@Cz=gner zu{gzxXRGw+L37}sRhn2@Wg$6O<<)=3vg|jzE)ce;-NU}G>HhVv`*ru*zyAI8cL3LL zk6}PO%y@XX-pu(5TCMLJD6q|%M{L#uUS~(PFYM2uQ1$gLSd>aw zHF2l;!WQ4)zUyC-wT#cinpL3rL$Nj^rB}4WMxxrs zwxELOqH*+8aWkX~)#xmUfUom_lZIB>jZo`lYDlU93~ZauAKGe{qt!Z<+TRCz8AI#V z!r#GOZK>%ALo-_pb!5^I&N@x{;TL-M!QOi1x+Dxs-=!kY`xo9`bMGn7>Yi4Xd zZ6=SO&OLt|neR1?9xX?Trmme-qR(u;(`=#7sR`X|?NLx|bI-qu%qPuuIyGs{mikU= zeRTM^jm)(XrJkrBHxqqPT{mNgPvU9i+62Ru`f)ybM<`0Y^(w2{-gn5su(M$*kGLM zHyWmdrk)hq&C*W81n$rrC%<)?b(*OuA%Z#D&C+*`W@F?TT1K)zqy0zPX~@&qMlvAX zC`l!88}qb#sUi&%Y1)xqXo*!VC2*I{5|opnsWdv!Sv6$Q8O0v4k)P2111%~x6f4C- zVW%nrRqP7)b0@f`(N$x9oe&iB_zSF$BUaePYi#4hzm=?1uuri)Ut`-(LMPbLbJ-w6 zYNQk~729!gT`^4l2JPeQGrX+at^ietC2PczC&JiMbGnx_j)&At;u0f-@6)XEV`wD%9b(b_>>tp+K`gSLJ%F~LFt5_@7g*t8^a$NRB%%L< za|r@CN~xh*EQXMy(9u6S0}Pe$6I;4oyT=d z(h^g7yo2dgFo_#@cNHBHX^9z$ltin_J!kn{{aR` Bp-2D# literal 0 HcmV?d00001 diff --git a/core/src/test/classes/examples/shapes/m2/Shape.class b/core/src/test/classes/examples/shapes/m2/Shape.class new file mode 100644 index 0000000000000000000000000000000000000000..d0438cf45fe53d2a9ef3b837c01c42712bf265e8 GIT binary patch literal 2326 zcmb7FSx*~R6#nkmc#C6JYB{^yR5xi%BE~TME|6yN-6T2~1|keq zLrY19#EM}X-YUaVsTP4;cl5vq&v5MJ+M#x=sitP{t6QFH*!#;<+YGVN)OHqWT+1Mi zEJNClh%^Pm==({t$e}Y01$lJt{TdsfNqKEA(VGu5cgmdw;$OuLw28g{ygww zyfhVsZV!)Ptme4;>LK^)u4dRm)ok1GG#R^~ynCBX)0EtzjeFt)GAHwtTp_*LhpQ>v zWVqFEJkzk%!(&S|Y>&IPW~xpxvNa8j_Q9s~%BeeUC=2C75$S_%I$0n|^Y8C>2-gNC0v!02Ev4Tk6a|AkM4IwWvVX`JUD^y$a=(nq2oB zcSCa<+@*e!os`K?q00>2;TM}~ z9Bc5OsFi7)_1lP{>#f-h?rFQ4rx8lAj$?GAnH9$jeK0Qe-^^>YH&*)R=i#_g3#S4jid{CM1AekVUJo`1FzCO4Z_ox9&^gpqHVqig22<{EMxZjN8(I=|g*q?s+J>FWH6A&CY;o$V{u<0Euk z;`AkuqEV3#Dy8)abzp+zAW20&pO^L$v`cr5cE2RV544g!+gW~%>*eWJ=qk^=Lh(;u z`70U=WCD0V;}WUeCnNVzrJdnG4ZY~26%mBy2eB$Xsp4)G zpW+@(u~enXKiB~i_zcTC=oRP_SP}SKU{xR|&?!(5cqot&m=L%lFey+H=oc6e7!tT4 O@JL`y;ITkOVEunhxF3uF literal 0 HcmV?d00001 diff --git a/core/src/test/java/lionweb/core/m2/generated/test/PropertyTests_Boolean_Optional.java b/core/src/test/java/lionweb/core/m2/generated/test/PropertyTests_Boolean_Optional.java new file mode 100644 index 00000000..06f76e20 --- /dev/null +++ b/core/src/test/java/lionweb/core/m2/generated/test/PropertyTests_Boolean_Optional.java @@ -0,0 +1,143 @@ +// Copyright 2024 TRUMPF Laser SE and other contributors +// +// 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. +// +// SPDX-FileCopyrightText: 2024 TRUMPF Laser SE and other contributors +// SPDX-License-Identifier: Apache-2.0 + +package lionweb.core.m2.generated.test; + +import examples.shapes.m2.Documentation; +import org.junit.Assert; +import org.junit.Test; + +public class PropertyTests_Boolean_Optional +{ +// #region Single + + @Test + public void Setter() + { + Documentation parent = new Documentation("od", false); + boolean value = true; + parent.setTechnical(value); + Assert.assertEquals(true, parent.getTechnical()); + } + +// @Test +// public void Reflective() +// { +// var parent = new Documentation("od"); +// var value = true; +// parent.Set(ShapesLanguage.Instance.Documentation_technical, value); +// Assert.AreEqual(true, parent.Technical); +// } +// +// @Test +// public void Get_Reflective() +// { +// var parent = new Documentation("od") { Technical = true }; +// Assert.AreEqual(true, parent.Get(ShapesLanguage.Instance.Documentation_technical)); +// } +// +// @Test +// public void False_Reflective() +// { +// var parent = new Documentation("od"); +// var value = false; +// parent.Set(ShapesLanguage.Instance.Documentation_technical, value); +// Assert.AreEqual(false, parent.Technical); +// } +// +// @Test +// public void String_Reflective() +// { +// var parent = new Documentation("od"); +// var value = "10"; +// Assert.ThrowsException(() => +// parent.Set(ShapesLanguage.Instance.Documentation_technical, value)); +// Assert.AreEqual(null, parent.Technical); +// } +// +// @Test +// public void Integer_Reflective() +// { +// var parent = new Documentation("od"); +// var value = 10; +// Assert.ThrowsException(() => +// parent.Set(ShapesLanguage.Instance.Documentation_technical, value)); +// Assert.AreEqual(null, parent.Technical); +// } +// +// @Test +// public void Constructor() +// { +// var parent = new Documentation("myId") { Technical = true }; +// Assert.AreEqual(true, parent.Technical); +// } +// +//// #endregion +// +//// #region Null +// +// @Test +// public void Null() +// { +// var parent = new Documentation("od"); +// object value = null; +// parent.Technical = (bool?)value; +// Assert.AreEqual(null, parent.Technical); +// } +// +// @Test +// public void Null_Setter() +// { +// var parent = new Documentation("od"); +// object value = null; +// parent.SetTechnical((bool?)value); +// Assert.AreEqual(null, parent.Technical); +// } +// +// @Test +// public void Null_Reflective() +// { +// var parent = new Documentation("od"); +// object value = null; +// parent.Set(ShapesLanguage.Instance.Documentation_technical, null); +// Assert.AreEqual(null, parent.Technical); +// } +// +// @Test +// public void Null_Get() +// { +// var parent = new Documentation("od"); +// Assert.AreEqual(null, parent.Technical); +// } +// +// @Test +// public void Null_Get_Reflective() +// { +// var parent = new Documentation("od"); +// Assert.AreEqual(null, parent.Get(ShapesLanguage.Instance.Documentation_technical)); +// } +// +// @Test +// public void Null_Constructor() +// { +// object value = null; +// var parent = new Documentation("od") { Technical = (bool?)value }; +// Assert.AreEqual(null, parent.Text); +// } + +// #endregion +} \ No newline at end of file