Skip to main content
summaryrefslogtreecommitdiffstats
blob: 6656e764479048d700cfc67c1ecb8c1ff8dc6ae0 (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
/*******************************************************************************
 * Copyright (c) 2010 Technical University of Denmark.
 * 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:
 *    Patrick Koenemann, DTU Informatics - initial API and implementation
 *******************************************************************************/
package org.eclipse.emf.compare.mpatch.test.junit;

import org.eclipse.emf.compare.mpatch.IndepAddAttributeChange;
import org.eclipse.emf.compare.mpatch.IndepAddElementChange;
import org.eclipse.emf.compare.mpatch.IndepAddReferenceChange;
import org.eclipse.emf.compare.mpatch.IndepMoveElementChange;
import org.eclipse.emf.compare.mpatch.IndepRemoveAttributeChange;
import org.eclipse.emf.compare.mpatch.IndepRemoveElementChange;
import org.eclipse.emf.compare.mpatch.IndepRemoveReferenceChange;
import org.eclipse.emf.compare.mpatch.IndepUpdateAttributeChange;
import org.eclipse.emf.compare.mpatch.IndepUpdateReferenceChange;
import org.eclipse.emf.compare.mpatch.extension.IModelDescriptorCreator;
import org.eclipse.emf.compare.mpatch.extension.ISymbolicReferenceCreator;
import org.eclipse.emf.compare.mpatch.test.util.CommonTestOperations;
import org.eclipse.emf.compare.mpatch.test.util.TestConstants;
import org.junit.Test;

/**
 * This test checks each change type in an individual test case.
 * It calculates the differences, applies them to the unchanged version, and compares it with the changed version.
 * 
 * @author Patrick Koenemann (pk@imm.dtu.dk)
 */
public class IndividualTest {

	/**
	 * Test applicability of {@link IndepAddElementChange}.
	 */
	@Test
	public void testApplyAddElement() {
		testApply(TestConstants.INDIVIDUAL_ADD_REM_ELEMENT_URI1, TestConstants.INDIVIDUAL_ADD_REM_ELEMENT_URI2);
	}

	/**
	 * Test applicability of {@link IndepRemoveElementChange}.
	 */
	@Test
	public void testApplyRemoveElement() {
		testApply(TestConstants.INDIVIDUAL_ADD_REM_ELEMENT_URI2, TestConstants.INDIVIDUAL_ADD_REM_ELEMENT_URI1);
	}

	/**
	 * Test applicability of {@link IndepMoveElementChange}.
	 */
	@Test
	public void testApplyMoveElement() {
		testApply(TestConstants.INDIVIDUAL_MOVE_ELEMENT_URI1, TestConstants.INDIVIDUAL_MOVE_ELEMENT_URI2);
	}

	/**
	 * Test applicability of {@link IndepAddAttributeChange}.
	 */
	@Test
	public void testApplyAddAttribute() {
		testApply(TestConstants.INDIVIDUAL_ADD_REM_ATTRIBUTE_URI1, TestConstants.INDIVIDUAL_ADD_REM_ATTRIBUTE_URI2);
	}

	/**
	 * Test applicability of {@link IndepRemoveAttributeChange}.
	 */
	@Test
	public void testApplyRemoveAttribute() {
		testApply(TestConstants.INDIVIDUAL_ADD_REM_ATTRIBUTE_URI2, TestConstants.INDIVIDUAL_ADD_REM_ATTRIBUTE_URI1);
	}

	/**
	 * Test applicability of {@link IndepUpdateAttributeChange}.
	 */
	@Test
	public void testApplyUpdateAttribute() {
		testApply(TestConstants.INDIVIDUAL_UPDATE_ATTRIBUTE_URI1, TestConstants.INDIVIDUAL_UPDATE_ATTRIBUTE_URI2);
	}

	/**
	 * Test applicability of {@link IndepAddReferenceChange}.
	 */
	@Test
	public void testApplyAddReference() {
		testApply(TestConstants.INDIVIDUAL_ADD_REM_REFERENCE_URI1, TestConstants.INDIVIDUAL_ADD_REM_REFERENCE_URI2);
	}

	/**
	 * Test applicability of {@link IndepRemoveReferenceChange}.
	 */
	@Test
	public void testApplyRemoveReference() {
		testApply(TestConstants.INDIVIDUAL_ADD_REM_REFERENCE_URI2, TestConstants.INDIVIDUAL_ADD_REM_REFERENCE_URI1);
	}

	/**
	 * Test applicability of {@link IndepUpdateReferenceChange}.
	 */
	@Test
	public void testApplyUpdateReference() {
		testApply(TestConstants.INDIVIDUAL_UPDATE_REFERENCE_URI1, TestConstants.INDIVIDUAL_UPDATE_REFERENCE_URI2);
	}

	/** Same as {@link IndividualTest#testApply}. */ 
	private void testApply(String unchangedUri, String changedUri) {
		for (ISymbolicReferenceCreator symrefCreator : TestConstants.SYM_REF_CREATORS) {
			for (IModelDescriptorCreator descriptorCreator : TestConstants.MODEL_DESCRIPTOR_CREATORS) {
				CommonTestOperations.applyMPatchAndValidate(unchangedUri, changedUri, symrefCreator, descriptorCreator);
			}
		}
	}
}

Back to the top