blob: 83e36b010304aca65b24bf9b29df6f9925c15da3 (
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
|
/*******************************************************************************
* Copyright (c) 2004, 2007 Boeing.
* 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:
* Boeing - initial API and implementation
*******************************************************************************/
package org.eclipse.osee.framework.core.model.access;
import junit.framework.Assert;
import org.junit.Test;
/**
* @author John Misinco
*/
public class ScopeTest {
@Test
public void testGetPath() {
Scope scope = new Scope();
scope.add("foo");
scope.add("bar bar");
scope.addSubPath("baz");
String expectedPath = "/foo/bar_bar#baz";
Assert.assertEquals(expectedPath, scope.getPath());
}
@Test
public void testEquals() {
Scope legacyScopeA = Scope.createLegacyScope();
Scope legacyScopeB = Scope.createLegacyScope();
legacyScopeA.add("foo");
legacyScopeB.addSubPath("bar");
Assert.assertTrue(legacyScopeA.equals(legacyScopeB));
Scope scopeA = new Scope();
Scope scopeB = new Scope();
scopeA.add("foo");
scopeA.addSubPath("bar");
scopeA.add("baz");
scopeB.add("foo");
scopeB.addSubPath("bar");
scopeB.add("baz");
Assert.assertTrue(scopeA.equals(scopeB));
Scope scopeC = new Scope();
Assert.assertFalse(legacyScopeA.equals(scopeA));
Assert.assertFalse(legacyScopeA.equals(scopeC));
}
@Test
public void testIsLegacy() {
Scope legacyScope = Scope.createLegacyScope();
Scope scope = new Scope();
legacyScope.add("foo");
legacyScope.addSubPath("bar");
String expectedScope = "##";
Assert.assertEquals(expectedScope, legacyScope.getPath());
Assert.assertTrue(legacyScope.isLegacy());
Assert.assertFalse(scope.isLegacy());
}
@Test
public void testClone() {
Scope scope = new Scope();
Scope legacyScope = Scope.createLegacyScope();
scope.add("foo").add("bar").addSubPath("baz").addSubPath("baz");
Scope scopeClone = scope.clone();
Assert.assertEquals(scope, scopeClone);
scopeClone = legacyScope.clone();
Assert.assertTrue(legacyScope.equals(scopeClone));
}
}
|