Skip to content

Commit

Permalink
213: updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
LorenzoBettini committed Jun 30, 2020
1 parent ded62fd commit 7393902
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package edelta.tests

import com.google.common.base.Joiner
import com.google.inject.Inject
import edelta.tests.additional.EdeltaEContentAdapter.EdeltaEContentAdapterException
import edelta.testutils.EdeltaTestUtils
import java.util.List
import org.eclipse.emf.ecore.resource.ResourceSet
Expand Down Expand Up @@ -1185,8 +1184,7 @@ class EdeltaCompilerTest extends EdeltaAbstractTest {
)
}

// TODO exception should not be thrown
@Test(expected=EdeltaEContentAdapterException)
@Test
def void testCompilationOfRenameReferencesAcrossEPackagesWithRealEcoreFiles2() {
// it is crucial to use real ecore files so that we mimick what happens in
// the workbench and make sure that original ecores are not modified.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -938,8 +938,7 @@ class EdeltaInterpreterTest extends EdeltaAbstractTest {
]
}
// TODO exception should not be thrown
@Test(expected=EdeltaInterpreterWrapperException)
@Test
def void testRenameReferencesAcrossEPackagesModifyingOnePackageOnly() {
'''
package test
Expand All @@ -954,15 +953,15 @@ class EdeltaInterpreterTest extends EdeltaAbstractTest {
'''.parseWithTestEcoresWithReferences => [
val map = interpretProgram
val testecoreforreferences1 = map.get("testecoreforreferences1")
// TODO this should be copied as well
// val testecoreforreferences2 = map.get("testecoreforreferences2")
val testecoreforreferences2 = map.get("testecoreforreferences2")
val person = testecoreforreferences1.getEClassByName("Person")
assertThat(person.EStructuralFeatures.filter(EReference).map[EOpposite.name])
.containsOnly("renamedPersons")
// TODO
// val workplace = testecoreforreferences2.getEClassByName("WorkPlace")
// assertThat(workplace.EStructuralFeatures.filter(EReference).map[name])
// .containsOnly("renamedPersons")
val workplace = testecoreforreferences2.getEClassByName("WorkPlace")
assertThat(workplace.EStructuralFeatures.filter(EReference).map[name])
.containsOnly("renamedPersons")
assertThat(person.EStructuralFeatures.filter(EReference).head.EOpposite)
.isSameAs(workplace.EStructuralFeatures.filter(EReference).head)
val unresolvedEcoreRefs =
derivedStateHelper.getUnresolvedEcoreReferences(eResource)
assertThat(unresolvedEcoreRefs).isEmpty
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@
*/
package edelta.tests.additional;

import java.util.List;

import org.eclipse.emf.ecore.resource.Resource;

import edelta.edelta.EdeltaModifyEcoreOperation;
import edelta.edelta.EdeltaProgram;
import edelta.resource.EdeltaDerivedStateComputer;
import edelta.resource.derivedstate.EdeltaCopiedEPackagesMap;
Expand All @@ -33,12 +30,10 @@ protected void recordEcoreReferenceOriginalENamedElement(Resource resource) {
}

@Override
protected void copyEPackages(List<EdeltaModifyEcoreOperation> modifyEcoreOperations,
protected void copyEPackages(EdeltaProgram program,
EdeltaCopiedEPackagesMap copiedEPackagesMap) {
final var originalEPackages =
((EdeltaProgram) modifyEcoreOperations.get(0).eContainer()).getMetamodels();
originalEPackages.stream()
program.getMetamodels().stream()
.forEach(p -> p.eAdapters().add(new EdeltaEContentAdapter()));
super.copyEPackages(modifyEcoreOperations, copiedEPackagesMap);
super.copyEPackages(program, copiedEPackagesMap);
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package edelta.tests.additional;

import java.util.List;

import com.google.inject.Singleton;

import edelta.edelta.EdeltaModifyEcoreOperation;
import edelta.edelta.EdeltaProgram;
import edelta.resource.EdeltaDerivedStateComputer;
import edelta.resource.derivedstate.EdeltaCopiedEPackagesMap;
Expand All @@ -24,13 +21,11 @@ public void unloadDerivedPackages(final EdeltaCopiedEPackagesMap copiedEPackages
}

@Override
protected void copyEPackages(List<EdeltaModifyEcoreOperation> modifyEcoreOperations,
protected void copyEPackages(EdeltaProgram program,
EdeltaCopiedEPackagesMap copiedEPackagesMap) {
final var originalEPackages =
((EdeltaProgram) modifyEcoreOperations.get(0).eContainer()).getMetamodels();
originalEPackages.stream()
program.getMetamodels().stream()
.forEach(p -> p.eAdapters().add(new EdeltaEContentAdapter()));
super.copyEPackages(modifyEcoreOperations, copiedEPackagesMap);
super.copyEPackages(program, copiedEPackagesMap);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import com.google.inject.Inject;
import edelta.tests.EdeltaAbstractTest;
import edelta.tests.EdeltaInjectorProviderTestableDerivedStateComputer;
import edelta.tests.additional.EdeltaEContentAdapter;
import edelta.testutils.EdeltaTestUtils;
import java.util.ArrayList;
import java.util.Collections;
Expand Down Expand Up @@ -2449,7 +2448,7 @@ public void testExecutionOfRenameReferencesAcrossEPackagesWithRealEcoreFiles() {
true);
}

@Test(expected = EdeltaEContentAdapter.EdeltaEContentAdapterException.class)
@Test
public void testCompilationOfRenameReferencesAcrossEPackagesWithRealEcoreFiles2() {
StringConcatenation _builder = new StringConcatenation();
_builder.append("package test");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1435,7 +1435,7 @@ public void testRenameReferencesAcrossEPackages() {
ObjectExtensions.<EdeltaProgram>operator_doubleArrow(_parseWithTestEcoresWithReferences, _function);
}

@Test(expected = EdeltaInterpreterWrapperException.class)
@Test
public void testRenameReferencesAcrossEPackagesModifyingOnePackageOnly() {
StringConcatenation _builder = new StringConcatenation();
_builder.append("package test");
Expand All @@ -1460,11 +1460,18 @@ public void testRenameReferencesAcrossEPackagesModifyingOnePackageOnly() {
final Procedure1<EdeltaProgram> _function = (EdeltaProgram it) -> {
final EdeltaCopiedEPackagesMap map = this.interpretProgram(it);
final EPackage testecoreforreferences1 = map.get("testecoreforreferences1");
final EPackage testecoreforreferences2 = map.get("testecoreforreferences2");
final EClass person = this.getEClassByName(testecoreforreferences1, "Person");
final Function1<EReference, String> _function_1 = (EReference it_1) -> {
return it_1.getEOpposite().getName();
};
Assertions.<String>assertThat(IterableExtensions.<EReference, String>map(Iterables.<EReference>filter(person.getEStructuralFeatures(), EReference.class), _function_1)).containsOnly("renamedPersons");
final EClass workplace = this.getEClassByName(testecoreforreferences2, "WorkPlace");
final Function1<EReference, String> _function_2 = (EReference it_1) -> {
return it_1.getName();
};
Assertions.<String>assertThat(IterableExtensions.<EReference, String>map(Iterables.<EReference>filter(workplace.getEStructuralFeatures(), EReference.class), _function_2)).containsOnly("renamedPersons");
Assertions.<EReference>assertThat(IterableExtensions.<EReference>head(Iterables.<EReference>filter(person.getEStructuralFeatures(), EReference.class)).getEOpposite()).isSameAs(IterableExtensions.<EReference>head(Iterables.<EReference>filter(workplace.getEStructuralFeatures(), EReference.class)));
final EdeltaUnresolvedEcoreReferences unresolvedEcoreRefs = this.derivedStateHelper.getUnresolvedEcoreReferences(it.eResource());
Assertions.<EdeltaEcoreReference>assertThat(unresolvedEcoreRefs).isEmpty();
};
Expand Down

0 comments on commit 7393902

Please sign in to comment.