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 00000000..5715fe7a Binary files /dev/null and b/core/src/test/classes/examples/shapes/m2/BillOfMaterials.class differ 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 00000000..2cba8184 Binary files /dev/null and b/core/src/test/classes/examples/shapes/m2/Circle.class differ 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 00000000..4ba2148c Binary files /dev/null and b/core/src/test/classes/examples/shapes/m2/CompositeShape.class differ diff --git a/core/src/test/classes/examples/shapes/m2/Coord.class b/core/src/test/classes/examples/shapes/m2/Coord.class new file mode 100644 index 00000000..a40717f4 Binary files /dev/null and b/core/src/test/classes/examples/shapes/m2/Coord.class differ 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 00000000..4249aeb4 Binary files /dev/null and b/core/src/test/classes/examples/shapes/m2/Documentation.class differ diff --git a/core/src/test/classes/examples/shapes/m2/Geometry.class b/core/src/test/classes/examples/shapes/m2/Geometry.class new file mode 100644 index 00000000..96257b5c Binary files /dev/null and b/core/src/test/classes/examples/shapes/m2/Geometry.class differ 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 00000000..341b3534 Binary files /dev/null and b/core/src/test/classes/examples/shapes/m2/IShape.class differ 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 00000000..89d14976 Binary files /dev/null and b/core/src/test/classes/examples/shapes/m2/Line.class differ 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 00000000..11b3ba62 Binary files /dev/null and b/core/src/test/classes/examples/shapes/m2/MaterialGroup.class differ 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 00000000..c84a77fd Binary files /dev/null and b/core/src/test/classes/examples/shapes/m2/MatterState.class differ 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 00000000..fc19a796 Binary files /dev/null and b/core/src/test/classes/examples/shapes/m2/OffsetDuplicate.class differ 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 00000000..882170b8 Binary files /dev/null and b/core/src/test/classes/examples/shapes/m2/ReferenceGeometry.class differ 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 00000000..d0438cf4 Binary files /dev/null and b/core/src/test/classes/examples/shapes/m2/Shape.class differ 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..1d69e001 --- /dev/null +++ b/core/src/test/java/lionweb/core/m2/dynamic/test/ContainmentTests_Annotation.java @@ -0,0 +1,1191 @@ +// 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; +import java.util.List; + +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(IllegalArgumentException.class, () -> 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.assertEquals(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.assertEquals(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.assertEquals(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.assertEquals(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.assertEquals(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(IllegalArgumentException.class, () -> parent.Set(null, null)); +// } + +// @Test +// public void Null_Insert_Empty() +// { +// AbstractClassifierInstance parent = newLine("g"); +// Assert.assertThrows(IllegalArgumentException.class, () -> 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(IllegalArgumentException.class, () -> 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(IllegalArgumentException.class, +// () -> 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(IllegalArgumentException.class, () -> 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(IllegalArgumentException.class, () -> 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(IllegalArgumentException.class, +// () -> 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(IllegalArgumentException.class, +// () -> 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(IllegalArgumentException.class, +// () -> 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.assertEquals(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.assertEquals(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.assertEquals(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.assertEquals(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.assertEquals(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(IllegalArgumentException.class, +// () -> 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(IllegalArgumentException.class, +// () -> 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(IllegalArgumentException.class, +// () -> 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.assertEquals(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.assertEquals(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.assertEquals(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.assertEquals(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.assertEquals(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.assertEquals(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.assertEquals(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.assertEquals(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.assertEquals(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.assertEquals(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.assertEquals(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.assertEquals(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.assertEquals(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.assertEquals(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.assertEquals(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.assertEquals(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(IllegalArgumentException.class, +// () -> 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(IllegalArgumentException.class, +// () -> 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(IllegalArgumentException.class, +// () -> 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(IllegalArgumentException.class, () -> 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(IllegalArgumentException.class, () -> 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(IllegalArgumentException.class, () -> 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.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.addAnnotation(valueA); + parent.addAnnotation(valueB); + List result = parent.getAnnotations(); + Assert.assertThrows(UnsupportedOperationException.class, () -> result.add(valueA)); + } + + @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 +} \ 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 new file mode 100644 index 00000000..faa289a5 --- /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.assertEquals(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/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 new file mode 100644 index 00000000..aa4ea469 --- /dev/null +++ b/core/src/test/java/lionweb/core/m2/dynamic/test/DynamicNodeTestsBase.java @@ -0,0 +1,295 @@ +// 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.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 { + 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 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 Containment CompositeShape_parts() { + return (Containment) getFeatureByKey(getClassifierByKey("key-CompositeShape"), "key-parts"); + } + + protected Containment CompositeShape_disabledParts() { + return (Containment) getFeatureByKey(getClassifierByKey("key-CompositeShape"), "key-disabled-parts"); + } + + protected Containment CompositeShape_evilPart() { + return (Containment) getFeatureByKey(getClassifierByKey("key-CompositeShape"), "key-evil-part"); + } + + protected Containment Geometry_documentation() { + return (Containment) getFeatureByKey(getClassifierByKey("key-Geometry"), "key-documentation"); + } + + protected Containment OffsetDuplicate_offset() { + return (Containment) getFeatureByKey(getClassifierByKey("key-OffsetDuplicate"), "key-offset"); + } + + protected Property Documentation_technical() + { + return (Property) getFeatureByKey(getClassifierByKey("key-Documentation"), "key-technical"); + } + + protected Property MaterialGroup_matterState() + { + return (Property) getFeatureByKey(getClassifierByKey("key-MaterialGroup"), "key-matter-state"); + } + + protected Containment MaterialGroup_defaultShape() + { + return (Containment) getFeatureByKey(getClassifierByKey("key-MaterialGroup"), "key-default-shape"); + } + + protected Property Circle_r() + { + return (Property) getFeatureByKey(getClassifierByKey("key-Circle"), "key-r"); + } + + protected Containment Circle_center() + { + return (Containment) getFeatureByKey(getClassifierByKey("key-Circle"), "key-center"); + } + + protected Containment Line_start() + { + return (Containment) getFeatureByKey(getClassifierByKey("key-Line"), "key-start"); + } + + protected Containment Line_end() + { + return (Containment) getFeatureByKey(getClassifierByKey("key-Line"), "key-end"); + } + + protected Property Documentation_text() + { + return (Property) getFeatureByKey(getClassifierByKey("key-Documentation"), "key-text"); + } + + protected Reference MaterialGroup_materials() + { + return (Reference) getFeatureByKey(getClassifierByKey("key-MaterialGroup"), "key-group-materials"); + } + + protected Reference OffsetDuplicate_altSource() + { + return (Reference) getFeatureByKey(getClassifierByKey("key-OffsetDuplicate"), "key-alt-source"); + } + + protected Reference OffsetDuplicate_source() + { + return (Reference) getFeatureByKey(getClassifierByKey("key-OffsetDuplicate"), "key-source"); + } + + protected Containment OffsetDuplicate_docs() + { + return (Containment) getFeatureByKey(getClassifierByKey("key-OffsetDuplicate"), "key-docs"); + } + + protected Containment OffsetDuplicate_secretDocs() + { + return (Containment) getFeatureByKey(getClassifierByKey("key-OffsetDuplicate"), "key-secret-docs"); + } + + protected Containment BillOfMaterials_groups() + { + return (Containment) getFeatureByKey(getClassifierByKey("key-BillOfMaterials"), "key-groups"); + } + + protected Containment BillOfMaterials_altGroups() + { + return (Containment) getFeatureByKey(getClassifierByKey("key-BillOfMaterials"), "key-alt-groups"); + } + + protected Containment BillOfMaterials_defaultGroup() + { + return (Containment) getFeatureByKey(getClassifierByKey("key-BillOfMaterials"), "key-default-group"); + } + + protected Containment Shape_shapeDocs() + { + return (Containment) getFeatureByKey(getClassifierByKey("key-Shape"), "key-shape-docs"); + } + + protected Enum MatterState_Gas() + { + return null; +// return getGetFactory().GetEnumerationLiteral( +// MatterState +// .Literals +// .First(l => l.Key == "key-gas") +// ); + } + + protected Enum MatterState_Liquid() + { + return null; +// return getGetFactory().GetEnumerationLiteral( +// MatterState +// .Literals +// .First(l => l.Key == "key-liquid") +// ); + } + + 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 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 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