use of org.eclipse.emf.compare.Comparison in project InformationSystem by ObeoNetwork.
the class DiffContentService method isInAddOrDelete.
/**
* It checks if the given difference is about an added or deleted object.<br>
* It enables to choose to keep involved differences under an add or delete.
*
* @param diff
* @return
*/
private static boolean isInAddOrDelete(Diff diff) {
Match match = diff.getMatch();
Comparison comparison = match.getComparison();
EObject left = match.getLeft();
if (left != null) {
return isInAddOrDelete(comparison, left);
}
EObject right = match.getRight();
if (right != null) {
return isInAddOrDelete(comparison, right);
}
return false;
}
use of org.eclipse.emf.compare.Comparison in project InformationSystem by ObeoNetwork.
the class TableChangeBuilder method handleAddChange.
@Override
protected Diff handleAddChange(ReferenceChange change) {
Comparison comparison = change.getMatch().getComparison();
TableContainer tableContainer = (TableContainer) change.getMatch().getRight();
Table table = (Table) change.getValue();
return createAddTable(comparison, tableContainer, table, change);
}
use of org.eclipse.emf.compare.Comparison in project InformationSystem by ObeoNetwork.
the class AbtractGeneratorTest method assertGen.
protected void assertGen(String testCase, String genFileName) throws Exception {
Comparison databaseChangeSet = diff(testCase + "/v2.database", testCase + "/v1.database");
File folder = new File("testFolder");
AcceleoTextGenerationListener acceleoTextGenerationListener = generate(databaseChangeSet, folder);
String path = folder.getAbsolutePath() + File.separator + "" + getTimeStamp() + File.separator;
GeneratedFile generatedFile = new GeneratedFile(path + genFileName, testCase + File.separator + "expected.sql");
assertSQL(acceleoTextGenerationListener, generatedFile);
}
use of org.eclipse.emf.compare.Comparison in project InformationSystem by ObeoNetwork.
the class DatabaseTransformationTest method testDatabaseTransformation.
@SuppressWarnings("unchecked")
@Test
public void testDatabaseTransformation() {
Comparison expected = (Comparison) this.expectedResourceWrapper.getResource().getContents().get(0);
Comparison actual = (Comparison) this.actualResourceWrapper.getResource().getContents().get(0);
try {
// Comparing Comparisons using EMFCompare does not seem to do well.
// We thus compare the Comparisons in a rough way manually, errors
// can be caught in later stages.
DatabaseTransformationTestSuite.INSTANCE.compareComparisons(expected, actual);
// Only check for the same number of matches... :-/
assertEquals(EMFUtils.getAllContentsOfType(ComparePackage.Literals.MATCH, expected).size(), EMFUtils.getAllContentsOfType(ComparePackage.Literals.MATCH, actual).size());
} catch (AssertionError e) {
System.out.println("Actual model being used for transformation:");
try {
this.actualResourceWrapper.getResource().save(System.out, null);
} catch (final IOException ex) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("Expected model being used for transformation:");
try {
this.expectedResourceWrapper.getResource().save(System.out, null);
} catch (final IOException ex) {
// TODO Auto-generated catch block
e.printStackTrace();
}
throw e;
}
}
use of org.eclipse.emf.compare.Comparison in project InformationSystem by ObeoNetwork.
the class DatabaseTransformationTestSuite method transform.
private Comparison transform(Comparison originalComparison) {
IPostProcessor transformer = new DatabasePostProcessor();
Comparison comparison = EcoreUtil.copy(originalComparison);
transformer.postComparison(comparison, null);
return comparison;
}
Aggregations