Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 19f2e56c70a9814abfe5d10fcd67f6d0fe2bc33d (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
/*******************************************************************************
 * Copyright (c) 2013 CEA LIST.
 * 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
 ******************************************************************************/
package org.eclipse.papyrus.layers.stackmodel.layers.impl;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import org.eclipse.gmf.runtime.notation.Diagram;
import org.eclipse.gmf.runtime.notation.NotationFactory;
import org.eclipse.papyrus.layers.stackmodel.NotFoundException;
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.junit.After;
import org.junit.Before;
import org.junit.Test;


/**
 * @author cedric dumoulin
 *
 */
public class LayersStackApplicationImplTest {

	/**
	 * @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.LayersStackApplicationImpl#LayersStackApplicationImpl()}.
	 */
	@Test
	public void testLayersStackApplicationImpl() {
		// Create instance
		LayersStackApplication application = LayersFactory.eINSTANCE.createLayersStackApplication();
		assertNotNull("instance created", application);
	}

	/**
	 * Test method for {@link org.eclipse.papyrus.layers.stackmodel.layers.impl.LayersStackApplicationImpl#init()}.
	 */
	@Test
	public void testInit() {
		// Create instance
		LayersStackApplication application = LayersFactory.eINSTANCE.createLayersStackApplication();

		// Check other instances creation
		assertNotNull("propertyRegistry created", application.getPropertyRegistry());
		assertNotNull("layerDescriptorRegistry created", application.getLayerDescriptorRegistry());
		assertNotNull("propertySetterRegistry  created", application.getPropertySetterRegistry());
		assertNotNull("LayerOperatorDescriptorRegistry  created", application.getLayerOperatorDescriptorRegistry());

	}

	/**
	 * Test method for {@link org.eclipse.papyrus.layers.stackmodel.layers.impl.LayersStackApplicationImpl#getLayersStacks()}.
	 */
	@Test
	public void testGetLayersStacks() {
		// Create instance
		LayersStackApplication application = LayersFactory.eINSTANCE.createLayersStackApplication();

		// Check other instances creation
		assertNotNull("stacks list created", application.getLayersStacks());
	}

	/**
	 * Test method for {@link org.eclipse.papyrus.layers.stackmodel.layers.impl.LayersStackApplicationImpl#getPropertyRegistry()}.
	 */
	@Test
	public void testGetPropertyRegistry() {
		// Create instance
		LayersStackApplication application = LayersFactory.eINSTANCE.createLayersStackApplication();

		// Check other instances creation
		assertNotNull("propertyRegistry created", application.getPropertyRegistry());
	}

	/**
	 * Test method for {@link org.eclipse.papyrus.layers.stackmodel.layers.impl.LayersStackApplicationImpl#getLayerDescriptorRegistry()}.
	 */
	@Test
	public void testGetLayerDescriptorRegistry() {
		// Create instance
		LayersStackApplication application = LayersFactory.eINSTANCE.createLayersStackApplication();

		// Check other instances creation
		assertNotNull("layerDescriptorRegistry created", application.getLayerDescriptorRegistry());
	}

	/**
	 * Test method for {@link org.eclipse.papyrus.layers.stackmodel.layers.impl.LayersStackApplicationImpl#removeLayersStackFor(org.eclipse.gmf.runtime.notation.Diagram)}.
	 */
	@Test
	public void testRemoveLayersStackFor() {
		// Create instance
		LayersStackApplication application = LayersFactory.eINSTANCE.createLayersStackApplication();
		Diagram diagram = NotationFactory.eINSTANCE.createDiagram();

		// try to get a layer stack
		application.getLayersStackFor(diagram);

		// Create a second stack
		Diagram diagram2 = NotationFactory.eINSTANCE.createDiagram();
		LayersStack stack2 = application.getLayersStackFor(diagram2);

		// Remove first stack
		application.removeLayersStackFor(diagram);
		// Check if not exist
		assertFalse("stack is detached", application.isLayersStackAttachedFor(diagram));
		assertTrue("stack is attached", application.isLayersStackAttachedFor(diagram2));
		assertSame("get found previous stack", stack2, application.getLayersStackFor(diagram2));
	}

	/**
	 * Test method for {@link org.eclipse.papyrus.layers.stackmodel.layers.impl.LayersStackApplicationImpl#isLayersStackAttachedFor(org.eclipse.gmf.runtime.notation.Diagram)}.
	 */
	@Test
	public void testIsLayersStackAttachedFor() {
		// Create instance
		LayersStackApplication application = LayersFactory.eINSTANCE.createLayersStackApplication();
		Diagram diagram = NotationFactory.eINSTANCE.createDiagram();

		// check if there is a stack
		assertFalse("no stack is found", application.isLayersStackAttachedFor(diagram));

		// try to get a layer stack
		LayersStack stack = application.getLayersStackFor(diagram);
		assertNotNull("stack is created", stack);

		assertTrue("stack is attached", application.isLayersStackAttachedFor(diagram));
	}

	/**
	 * Test method for {@link org.eclipse.papyrus.layers.stackmodel.layers.impl.LayersStackApplicationImpl#lookupLayersStackFor(org.eclipse.gmf.runtime.notation.Diagram)}.
	 *
	 * @throws NotFoundException
	 */
	@Test
	public void testLookupLayersStackFor() throws NotFoundException {
		// Create instance
		LayersStackApplication application = LayersFactory.eINSTANCE.createLayersStackApplication();
		Diagram diagram = NotationFactory.eINSTANCE.createDiagram();

		// Try to lookup. Should found nothing
		try {
			application.lookupLayersStackFor(diagram);
			fail("An NotFoundException should be throw");
		} catch (NotFoundException e) {
		}

		// try to get a layer stack
		LayersStack stack = application.getLayersStackFor(diagram);
		assertNotNull("stack is created", stack);

		assertSame("lookup found stack", stack, application.lookupLayersStackFor(diagram));
	}

	/**
	 * Test method for {@link org.eclipse.papyrus.layers.stackmodel.layers.impl.LayersStackApplicationImpl#getLayersStackFor(org.eclipse.gmf.runtime.notation.Diagram)}.
	 */
	@Test
	public void testGetLayersStackFor() {
		// Create instance
		LayersStackApplication application = LayersFactory.eINSTANCE.createLayersStackApplication();
		Diagram diagram = NotationFactory.eINSTANCE.createDiagram();

		// try to get a layer stack
		LayersStack stack = application.getLayersStackFor(diagram);
		assertNotNull("stack is created", stack);

		// Create a second stack
		Diagram diagram2 = NotationFactory.eINSTANCE.createDiagram();
		LayersStack stack2 = application.getLayersStackFor(diagram2);
		assertNotNull("stack is created", stack2);

		// Get them again
		assertSame("get found previuous stack", stack, application.getLayersStackFor(diagram));
		assertSame("get found previuous stack", stack2, application.getLayersStackFor(diagram2));

	}

	/**
	 * Test method for {@link org.eclipse.papyrus.layers.stackmodel.layers.impl.LayersStackApplicationImpl#createLayersStackFor(org.eclipse.gmf.runtime.notation.Diagram)}.
	 */
	@Test
	public void testCreateLayersStackFor() {
		// Create instance
		LayersStackApplication application = LayersFactory.eINSTANCE.createLayersStackApplication();
		Diagram diagram = NotationFactory.eINSTANCE.createDiagram();

		// try to get a layer stack
		LayersStack stack = application.createLayersStackFor(diagram);
		assertNotNull("stack is created", stack);

	}

}

Back to the top