Skip to main content
summaryrefslogtreecommitdiffstats
blob: 68e4e6d732c2f462e1f54750b75cd3c740f545c2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*******************************************************************************
 * Copyright (c) 2015 EclipseSource Muenchen GmbH and others.
 * 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:
 *     Stefan Dirix - initial API and implementation
 *******************************************************************************/
package org.eclipse.emf.compare.uml2.tests.conflict;

import static org.eclipse.emf.compare.utils.EMFComparePredicates.hasConflict;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;

import com.google.common.collect.Iterators;

import java.io.IOException;
import java.util.Iterator;

import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.compare.Comparison;
import org.eclipse.emf.compare.ConflictKind;
import org.eclipse.emf.compare.Diff;
import org.eclipse.emf.compare.merge.IMerger;
import org.eclipse.emf.compare.merge.IMerger.Registry;
import org.eclipse.emf.compare.merge.PseudoConflictMerger;
import org.eclipse.emf.compare.uml2.tests.AbstractUMLInputData;
import org.eclipse.emf.compare.uml2.tests.AbstractUMLTest;
import org.eclipse.emf.compare.uml2.tests.conflict.data.ConflictInputData;
import org.eclipse.emf.ecore.resource.Resource;
import org.junit.Test;

/**
 * Tests the handling of pseudo conflicts within UML models.
 * 
 * @author Stefan Dirix <sdirix@eclipsesource.com>
 */
public class PseudoConflictTest extends AbstractUMLTest {

	/**
	 * Test input data.
	 */
	private ConflictInputData input = new ConflictInputData();

	/**
	 * Tests if EMF Compare uses the {@link PseudoConflictMerger} when merging pseudo conflicts of UML models.
	 * 
	 * @throws IOException
	 *             When an error is thrown while reading the models.
	 */
	@Test
	public void testPseudoConflictMergerPriority() throws IOException {
		final Resource left = input.getA1Left();
		final Resource right = input.getA1Right();
		final Resource origin = input.getA1Origin();

		final Comparison comparison = compare(left, right, origin);
		final EList<Diff> differences = comparison.getDifferences();

		Iterator<Diff> conflicts = Iterators.filter(differences.iterator(), hasConflict(ConflictKind.PSEUDO));

		final Registry registry = getMergerRegistry();

		while (conflicts.hasNext()) {
			Diff conflict = conflicts.next();
			IMerger merger = registry.getHighestRankingMerger(conflict);

			assertThat(merger, instanceOf(PseudoConflictMerger.class));
		}
	}

	@Override
	protected AbstractUMLInputData getInput() {
		return input;
	}
}

Back to the top