Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 9f2c71f40e075eea7c779bb69bd8b2a03d1d1f44 (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
/*****************************************************************************
 * 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:
 *  Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
 *
 *****************************************************************************/
package org.eclipse.papyrus.infra.nattable.model.tests.tests;


import org.eclipse.papyrus.infra.nattable.model.nattable.NattableFactory;
import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattablestyle.BooleanValueStyle;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattablestyle.IntValueStyle;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattablestyle.NamedStyle;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattablestyle.NattablestylePackage;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattablestyle.Style;
import org.eclipse.papyrus.junit.framework.classification.tests.AbstractPapyrusTest;
import org.junit.Assert;
import org.junit.Test;

/**
 * This class provides some test to verify that NOT generated code has not been destroyed
 *
 * @author Vincent Lorenzo
 *
 */
public class StyledElementTests extends AbstractPapyrusTest {

	@Test
	public void test_StyleCreation() {
		Table table = NattableFactory.eINSTANCE.createTable();
		Style style = table.createStyle(NattablestylePackage.eINSTANCE.getIntValueStyle());
		Assert.assertNotNull(style);
		Assert.assertTrue(style instanceof IntValueStyle);
		Assert.assertTrue(table.getStyles().contains(style));
	}

	@Test
	public void test_getNamedStyle() {
		Table table = NattableFactory.eINSTANCE.createTable();
		Style style = table.createStyle(NattablestylePackage.eINSTANCE.getNamedStyle());
		Assert.assertNotNull(style);
		Assert.assertTrue(style instanceof NamedStyle);
		String styleName = "myNiceStyle";
		((NamedStyle) style).setName(styleName);
		Style value = table.getNamedStyle(NattablestylePackage.eINSTANCE.getNamedStyle(), styleName);
		Assert.assertTrue(value == style);

	}

	@Test
	public void test_getStyle() {
		Table table = NattableFactory.eINSTANCE.createTable();
		Style style = table.createStyle(NattablestylePackage.eINSTANCE.getBooleanValueStyle());
		Assert.assertNotNull(style);
		Assert.assertTrue(style instanceof BooleanValueStyle);
		Assert.assertTrue(table.getStyles().contains(style));
		Assert.assertTrue(style == table.getStyle(NattablestylePackage.eINSTANCE.getBooleanValueStyle()));

	}
}

Back to the top