-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[test] Add tests for EReference name change mono and multi valued
- Loading branch information
1 parent
98002aa
commit e11bdfd
Showing
6 changed files
with
167 additions
and
1 deletion.
There are no files selected for viewing
77 changes: 77 additions & 0 deletions
77
.../eclipse/sirius/emfjson/tests/internal/unit/load/ExtendedMetaDataAttributesLoadTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023 Obeo. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Obeo - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.sirius.emfjson.tests.internal.unit.load; | ||
|
||
import org.eclipse.emf.ecore.EClass; | ||
import org.eclipse.emf.ecore.EStructuralFeature; | ||
import org.eclipse.emf.ecore.util.BasicExtendedMetaData; | ||
import org.eclipse.emf.ecore.util.ExtendedMetaData; | ||
import org.eclipse.sirius.emfjson.resource.JsonResource; | ||
import org.eclipse.sirius.emfjson.tests.internal.AbstractEMFJsonTests; | ||
import org.junit.Test; | ||
|
||
/** | ||
* Tests loading with ExtendedMetaData. | ||
*/ | ||
public class ExtendedMetaDataAttributesLoadTests extends AbstractEMFJsonTests { | ||
|
||
/** | ||
* {@inheritDoc} | ||
* | ||
* @see org.eclipse.sirius.emfjson.tests.internal.AbstractEMFJsonTests#getRootPath() | ||
*/ | ||
@Override | ||
protected String getRootPath() { | ||
return "/unit/references/extendedmetadata/"; //$NON-NLS-1$ | ||
} | ||
|
||
/** | ||
* Change the name of a monovalued EReference. | ||
*/ | ||
@Test | ||
public void testChangeReferenceNameMono() { | ||
ExtendedMetaData metaData = new BasicExtendedMetaData() { | ||
@Override | ||
public EStructuralFeature getElement(EClass eClass, String namespace, String name) { | ||
if ("NodeSingleValueReference".equals(eClass.getName()) && "singleValuedReferenceOld".equals(name)) { | ||
// $NON-NLS-1$ //$NON-NLS-2$ | ||
return eClass.getEStructuralFeature("singleValuedReference"); //$NON-NLS-1$ | ||
} | ||
// return super.getElement(eClass, namespace, name); // Doesn't work | ||
return eClass.getEStructuralFeature(name); | ||
} | ||
}; | ||
|
||
this.options.put(JsonResource.OPTION_EXTENDED_META_DATA, metaData); | ||
this.testLoad("TestChangeReferenceNameMono.xmi"); //$NON-NLS-1$ | ||
} | ||
|
||
/** | ||
* Change the name of a multivalued EReference. | ||
*/ | ||
@Test | ||
public void testChangeReferenceNameMulti() { | ||
ExtendedMetaData metaData = new BasicExtendedMetaData() { | ||
@Override | ||
public EStructuralFeature getElement(EClass eClass, String namespace, String name) { | ||
if ("NodeMultiValuedAttribute".equals(eClass.getName()) && "multiStringAttributeOld".equals(name)) { //$NON-NLS-1$ //$NON-NLS-2$ | ||
return eClass.getEStructuralFeature("multiStringAttribute"); //$NON-NLS-1$ | ||
} | ||
// return super.getElement(eClass, namespace, name); // Doesn't work | ||
return eClass.getEStructuralFeature(name); | ||
} | ||
}; | ||
|
||
this.options.put(JsonResource.OPTION_EXTENDED_META_DATA, metaData); | ||
this.testLoad("TestChangeReferenceNameMulti.xmi"); //$NON-NLS-1$ | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
...ests/src/main/resources/unit/references/extendedmetadata/TestChangeReferenceNameMono.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"json": { | ||
"version": "1.0", | ||
"encoding": "utf-8" | ||
}, | ||
"ns": { | ||
"nodes": "http://www.obeo.fr/EMFJson" | ||
}, | ||
"schemaLocation": { | ||
"http://www.obeo.fr/EMFJson": "../../../nodes.ecore" | ||
}, | ||
"content": [ | ||
{ | ||
"eClass": "nodes:NodeSingleValueReference", | ||
"data": { | ||
"name": "Node1", | ||
"singleValuedReferenceOld": "Node2" | ||
} | ||
}, | ||
{ | ||
"eClass": "nodes:NodeSingleValueReference", | ||
"data": { | ||
"name": "Node2" | ||
} | ||
} | ||
] | ||
} |
12 changes: 12 additions & 0 deletions
12
...tests/src/main/resources/unit/references/extendedmetadata/TestChangeReferenceNameMono.xmi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="ASCII"?> | ||
<xmi:XMI xmi:version="2.0" | ||
xmlns:xmi="http://www.omg.org/XMI" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns:nodes="http://www.obeo.fr/EMFJson" | ||
xsi:schemaLocation="http://www.obeo.fr/EMFJson ../../../nodes.ecore"> | ||
<nodes:NodeSingleValueReference | ||
name="Node1" | ||
singleValuedReference="Node2"/> | ||
<nodes:NodeSingleValueReference | ||
name="Node2"/> | ||
</xmi:XMI> |
36 changes: 36 additions & 0 deletions
36
...sts/src/main/resources/unit/references/extendedmetadata/TestChangeReferenceNameMulti.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"json": { | ||
"version": "1.0", | ||
"encoding": "utf-8" | ||
}, | ||
"ns": { | ||
"nodes": "http://www.obeo.fr/EMFJson" | ||
}, | ||
"schemaLocation": { | ||
"http://www.obeo.fr/EMFJson": "../../../nodes.ecore" | ||
}, | ||
"content": [ | ||
{ | ||
"eClass": "nodes:NodeMultiValuedReference", | ||
"data": { | ||
"name": "Node1", | ||
"multiValuedReference": [ | ||
"Node2", | ||
"Node3" | ||
] | ||
} | ||
}, | ||
{ | ||
"eClass": "nodes:NodeMultiValuedReference", | ||
"data": { | ||
"name": "Node2" | ||
} | ||
}, | ||
{ | ||
"eClass": "nodes:NodeMultiValuedReference", | ||
"data": { | ||
"name": "Node3" | ||
} | ||
} | ||
] | ||
} |
14 changes: 14 additions & 0 deletions
14
...ests/src/main/resources/unit/references/extendedmetadata/TestChangeReferenceNameMulti.xmi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="ASCII"?> | ||
<xmi:XMI xmi:version="2.0" | ||
xmlns:xmi="http://www.omg.org/XMI" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns:nodes="http://www.obeo.fr/EMFJson" | ||
xsi:schemaLocation="http://www.obeo.fr/EMFJson ../../../nodes.ecore"> | ||
<nodes:NodeMultiValuedReference | ||
name="Node1" | ||
multiValuedReference="Node2 Node3"/> | ||
<nodes:NodeMultiValuedReference | ||
name="Node2"/> | ||
<nodes:NodeMultiValuedReference | ||
name="Node3"/> | ||
</xmi:XMI> |