Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: c47ba71b7640b6c34abd3de15b7872376f316e88 (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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
/*****************************************************************************
 * Copyright (c) 2013 Cedric Dumoulin.
 *
 *    
 * 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:
 *  Cedric Dumoulin  Cedric.dumoulin@lifl.fr - Initial API and implementation
 *
 *****************************************************************************/

package org.eclipse.papyrus.layers.stackmodel.layers.impl;

import static org.junit.Assert.fail;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertEquals;

import org.eclipse.gmf.runtime.notation.Diagram;
import org.eclipse.gmf.runtime.notation.NotationFactory;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.layers.stackmodel.layers.Layer;
import org.eclipse.papyrus.layers.stackmodel.layers.LayersFactory;
import org.eclipse.papyrus.layers.stackmodel.layers.LayersStack;
import org.eclipse.papyrus.layers.stackmodel.layers.LayersStackApplication;
import org.eclipse.papyrus.layers.stackmodel.layers.PropertyRegistry;
import org.eclipse.papyrus.layers.stackmodel.layers.TopLayerOperator;
import org.eclipse.papyrus.layers.stackmodel.layers.util.LayersFactoryTestUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;

/**
 * Test initilaization of Layers when inserted in a tree of layers.
 * Use the LayerStack as container.
 * 
 * @author cedric dumoulin
 *
 */
public class LayerExpressionInitWithApplicationImplTest {

	/**
	 * @throws java.lang.Exception
	 */
	@Before
	public void setUp() throws Exception {
	}

	/**
	 * @throws java.lang.Exception
	 */
	@After
	public void tearDown() throws Exception {
	}

	/**
	 * Test method for {@link org.eclipse.papyrus.layers.stackmodel.layers.impl.LayerExpressionImpl#LayerExpressionImpl()}.
	 */
	@Test
	public void testLayerExpressionImpl() {
		// Create requested objects
		LayersStackApplication application = LayersFactory.eINSTANCE.createLayersStackApplication();
		Diagram diagram = NotationFactory.eINSTANCE.createDiagram();
		// Create stack
		LayersStack stack = application.getLayersStackFor(diagram);
		
		// Create layers
		LayersFactoryTestUtils factory = new LayersFactoryTestUtils(application);
		factory.newTopLayer("top", 
				factory.newLayer("layer1"),
				factory.newLayer("layer2"),
				factory.newTopLayer("container1", 
				  factory.newLayer("layer3") )
				);
		     
	    TopLayerOperator top = (TopLayerOperator)factory.getLayer("top");
	    stack.setLayers(top);
	    TopLayerOperator container1 = (TopLayerOperator)factory.getLayer("top");
		Layer layer1 = (Layer)factory.getLayer("layer1");
		Layer layer2 = (Layer)factory.getLayer("layer2");
		Layer layer3 = (Layer)factory.getLayer("layer3");
		
		
		// Assert
		assertNotNull("object created", top);
		assertEquals("application initialized", application, top.getApplication() );
		
		assertNotNull("object created", container1);
		assertEquals("application initialized", application, container1.getApplication() );

		assertNotNull("object created", layer1);
		assertEquals("application initialized", application, layer1.getApplication() );

		assertNotNull("object created", layer2);
		assertEquals("application initialized", application, layer2.getApplication() );

		assertNotNull("object created", layer3);
		assertEquals("application initialized", application, layer3.getApplication() );
	}

	/**
	 * Test if properties are set after adding a subtree
	 */
	@Test
	public void testAddSubTreeImpl() {
		// Create requested objects
		LayersStackApplication application = LayersFactory.eINSTANCE.createLayersStackApplication();
		Diagram diagram = NotationFactory.eINSTANCE.createDiagram();
		// Create stack
		LayersStack stack = application.getLayersStackFor(diagram);
		
		// Create layers
		LayersFactoryTestUtils factory = new LayersFactoryTestUtils(application);
		factory.newTopLayer("top", 
				factory.newLayer("layer1"),
				factory.newLayer("layer2"),
				factory.newTopLayer("container1", 
				  factory.newLayer("layer3") )
				);
		     
		factory.newTopLayer("container2", 
				factory.newLayer("layer21"),
				factory.newLayer("layer22")
				);
		     
		TopLayerOperator top = (TopLayerOperator)factory.getLayer("top");
		stack.setLayers(top);
	    TopLayerOperator container2 = (TopLayerOperator)factory.getLayer("container2");
		Layer layer21 = (Layer)factory.getLayer("layer21");
		Layer layer22 = (Layer)factory.getLayer("layer22");
		
		// action
		// Add subtree
		top.getLayers().add(container2);
		
		// Assert
		assertNotNull("object created", top);
		assertEquals("application initialized", application, top.getApplication() );
		
		assertNotNull("object created", container2);
		assertEquals("application initialized", application, container2.getApplication() );
		assertEquals("container (stack) initialized", stack, container2.getOwningLayersStack() );

		assertNotNull("object created", layer21);
		assertEquals("application initialized", application, layer21.getApplication() );
		assertEquals("container (stack) initialized", stack, layer21.getOwningLayersStack() );

		assertNotNull("object created", layer22);
		assertEquals("application initialized", application, layer22.getApplication() );
		assertEquals("container (stack) initialized", stack, layer22.getOwningLayersStack() );

	}

	/**
	 * Test method for {@link org.eclipse.papyrus.layers.stackmodel.layers.impl.LayerExpressionImpl#isLayerEnabled()}.
	 */
	@Test
	@Ignore
	public void testIsLayerEnabled() {
		fail("Not yet implemented");
	}

	/**
	 * Test method for {@link org.eclipse.papyrus.layers.stackmodel.layers.impl.LayerExpressionImpl#isBranchEnabled()}.
	 */
	@Test
	@Ignore
	public void testIsBranchEnabled() {
		fail("Not yet implemented");
	}

	/**
	 * Test method for {@link org.eclipse.papyrus.layers.stackmodel.layers.impl.LayerExpressionImpl#getOwningLayersStack()}.
	 */
	@Test
	public void testGetOwningLayersStack() {
		// Create requested objects
		LayersStackApplication application = LayersFactory.eINSTANCE.createLayersStackApplication();
		Diagram diagram = NotationFactory.eINSTANCE.createDiagram();
		// Create stack
		LayersStack stack = application.getLayersStackFor(diagram);
		
		// Create layers
		LayersFactoryTestUtils factory = new LayersFactoryTestUtils(application);
		factory.newTopLayer("top", 
				factory.newLayer("layer1"),
				factory.newLayer("layer2"),
				factory.newTopLayer("container1", 
				  factory.newLayer("layer3") )
				);
		     
	    TopLayerOperator top = (TopLayerOperator)factory.getLayer("top");
	    stack.setLayers(top);
	    TopLayerOperator container1 = (TopLayerOperator)factory.getLayer("top");
		Layer layer1 = (Layer)factory.getLayer("layer1");
		Layer layer2 = (Layer)factory.getLayer("layer2");
		Layer layer3 = (Layer)factory.getLayer("layer3");
		
		
		// Assert
		assertNotNull("object created", top);
		assertEquals("container (stack) initialized", stack, top.getOwningLayersStack() );
		
		assertNotNull("object created", container1);
		assertEquals("container (stack) initialized", stack, container1.getOwningLayersStack() );

		assertNotNull("object created", layer1);
		assertEquals("container (stack) initialized", stack, layer1.getOwningLayersStack() );

		assertNotNull("object created", layer2);
		assertEquals("container (stack) initialized", stack, layer2.getOwningLayersStack() );

		assertNotNull("object created", layer3);
		assertEquals("container (stack) initialized", stack, layer3.getOwningLayersStack() );
	}

}

Back to the top