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
|
/*******************************************************************************
* Copyright (c) 2011 Formal Mind GmbH and University of Dusseldorf.
* 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:
* Michael Jastram - initial API and implementation
******************************************************************************/
package org.eclipse.rmf.pror.reqif10.util;
import static org.junit.Assert.*;
import java.net.URISyntaxException;
import java.util.List;
import org.eclipse.rmf.pror.reqif10.configuration.ConfigFactory;
import org.eclipse.rmf.pror.reqif10.configuration.ConfigPackage;
import org.eclipse.rmf.pror.reqif10.configuration.ProrGeneralConfiguration;
import org.eclipse.rmf.pror.reqif10.configuration.ProrToolExtension;
import org.eclipse.rmf.pror.reqif10.testframework.AbstractItemProviderTest;
import org.eclipse.rmf.pror.reqif10.util.ConfigurationUtil;
import org.eclipse.rmf.reqif10.ReqIf;
import org.eclipse.rmf.reqif10.ReqIfToolExtension;
import org.eclipse.rmf.reqif10.Reqif10Factory;
import org.eclipse.rmf.reqif10.Reqif10Package;
import org.junit.Test;
public class ConfigUtilTest extends AbstractItemProviderTest {
@Test
public void testGetProrToolExtensionNothingThere() throws URISyntaxException {
ReqIf reqif = getTestReqif("simple.reqif");
assertEquals(0, reqif.getToolExtensions().size());
assertNotNull(ConfigurationUtil.getProrToolExtension(reqif, editingDomain));
}
@Test
public void testGetProrToolExtensionAlreadyThere() throws URISyntaxException {
ReqIf reqif = getTestReqif("simple.reqif");
ProrToolExtension extension = ConfigFactory.eINSTANCE.createProrToolExtension();
setViaCommand(reqif, Reqif10Package.Literals.REQ_IF__TOOL_EXTENSIONS, extension );
assertEquals(1, reqif.getToolExtensions().size());
ProrToolExtension retrieved = ConfigurationUtil.getProrToolExtension(reqif, editingDomain);
assertEquals(1, reqif.getToolExtensions().size());
assertSame(extension, retrieved);
}
@Test
public void testGetProrToolExtensionAnotherOneThere() throws URISyntaxException {
ReqIf reqif = getTestReqif("simple.reqif");
ReqIfToolExtension extension = Reqif10Factory.eINSTANCE.createReqIfToolExtension();
setViaCommand(reqif, Reqif10Package.Literals.REQ_IF__TOOL_EXTENSIONS,
extension);
assertEquals(1, reqif.getToolExtensions().size());
assertNotNull(ConfigurationUtil.getProrToolExtension(reqif, editingDomain));
}
@Test
public void testGetDefaultLabelsNothingThere() throws URISyntaxException {
ReqIf reqif = getTestReqif("simple.reqif");
List<String> labels = ConfigurationUtil.getDefaultLabels(reqif);
assertEquals(0, labels.size());
}
@Test
public void testGetDefaultLabelsOnlyGeneralConfigThere() throws URISyntaxException {
ReqIf reqif = getTestReqif("simple.reqif");
ReqIfToolExtension extension = Reqif10Factory.eINSTANCE.createReqIfToolExtension();
setViaCommand(reqif, Reqif10Package.Literals.REQ_IF__TOOL_EXTENSIONS,
extension);
ProrGeneralConfiguration generalConfig = ConfigFactory.eINSTANCE.createProrGeneralConfiguration();
setViaCommand(extension, ConfigPackage.Literals.PROR_TOOL_EXTENSION__GENERAL_CONFIGURATION, generalConfig);
assertNull(generalConfig.getLabelConfiguration());
List<String> labels = ConfigurationUtil.getDefaultLabels(reqif);
assertEquals(0, labels.size());
}
}
|