Skip to main content
summaryrefslogtreecommitdiffstats
blob: f599051699e066c44ba86b5bc2a5d8b9e2afa7de (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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/*******************************************************************************
 * Copyright (c) 2012, 2014 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.emf.compare.tests.unit;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;

import java.util.ArrayList;
import java.util.List;

import org.eclipse.emf.compare.CompareFactory;
import org.eclipse.emf.compare.Conflict;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.junit.Test;

/**
 * Tests the behavior of the {@link Conflict} class.
 * 
 * @generated
 */
public class ConflictTest extends AbstractCompareTest {
	/**
	 * Tests the behavior of reference <code>differences</code>'s accessors.
	 * 
	 * @generated
	 */
	@Test
	public void testDifferences() {
		EStructuralFeature feature = org.eclipse.emf.compare.ComparePackage.eINSTANCE
				.getConflict_Differences();
		Conflict conflict = CompareFactory.eINSTANCE.createConflict();
		conflict.eAdapters().add(new MockEAdapter());
		org.eclipse.emf.compare.Diff differencesValue = org.eclipse.emf.compare.CompareFactory.eINSTANCE
				.createDiff();
		List<org.eclipse.emf.compare.Diff> listDifferences = new ArrayList<org.eclipse.emf.compare.Diff>(1);
		listDifferences.add(differencesValue);

		assertFalse(conflict.eIsSet(feature));
		assertTrue(conflict.getDifferences().isEmpty());

		conflict.getDifferences().add(differencesValue);
		assertTrue(notified);
		notified = false;
		assertTrue(conflict.getDifferences().contains(differencesValue));
		assertSame(conflict.getDifferences(), conflict.eGet(feature));
		assertSame(conflict.getDifferences(), conflict.eGet(feature, false));
		assertTrue(conflict.eIsSet(feature));
		assertTrue(differencesValue.getConflict() == conflict);

		conflict.eUnset(feature);
		assertTrue(notified);
		notified = false;
		assertTrue(conflict.getDifferences().isEmpty());
		assertSame(conflict.getDifferences(), conflict.eGet(feature));
		assertSame(conflict.getDifferences(), conflict.eGet(feature, false));
		assertFalse(conflict.eIsSet(feature));
		assertFalse(differencesValue.getConflict() == conflict);

		conflict.eSet(feature, listDifferences);
		assertTrue(notified);
		notified = false;
		assertTrue(conflict.getDifferences().contains(differencesValue));
		assertSame(conflict.getDifferences(), conflict.eGet(feature));
		assertSame(conflict.getDifferences(), conflict.eGet(feature, false));
		assertTrue(conflict.eIsSet(feature));
		assertTrue(differencesValue.getConflict() == conflict);
	}

	/**
	 * Tests the behavior of attribute <code>kind</code>'s accessors.
	 * 
	 * @generated
	 */
	@Test
	public void testKind() {
		EStructuralFeature feature = org.eclipse.emf.compare.ComparePackage.eINSTANCE.getConflict_Kind();
		Conflict conflict = CompareFactory.eINSTANCE.createConflict();
		conflict.eAdapters().add(new MockEAdapter());
		org.eclipse.emf.compare.ConflictKind kindValue = (org.eclipse.emf.compare.ConflictKind)feature
				.getDefaultValue();
		for (org.eclipse.emf.compare.ConflictKind aConflictKind : org.eclipse.emf.compare.ConflictKind.VALUES) {
			if (kindValue.getValue() != aConflictKind.getValue()) {
				kindValue = aConflictKind;
				break;
			}
		}

		assertFalse(conflict.eIsSet(feature));
		assertEquals(feature.getDefaultValue(), conflict.getKind());

		conflict.setKind(kindValue);
		assertTrue(notified);
		notified = false;
		assertEquals(kindValue, conflict.getKind());
		assertEquals(conflict.getKind(), conflict.eGet(feature));
		assertTrue(conflict.eIsSet(feature));

		conflict.eUnset(feature);
		assertTrue(notified);
		notified = false;
		assertEquals(feature.getDefaultValue(), conflict.getKind());
		assertEquals(conflict.getKind(), conflict.eGet(feature));
		assertFalse(conflict.eIsSet(feature));

		conflict.eSet(feature, kindValue);
		assertTrue(notified);
		notified = false;
		assertEquals(kindValue, conflict.getKind());
		assertEquals(conflict.getKind(), conflict.eGet(feature));
		assertTrue(conflict.eIsSet(feature));

		conflict.setKind(null);
		assertTrue(notified);
		notified = false;
		assertEquals(feature.getDefaultValue(), conflict.getKind());
		assertEquals(conflict.getKind(), conflict.eGet(feature));
		assertFalse(conflict.eIsSet(feature));
	}

}

Back to the top