blob: 123fb9e61503646ade536179ba70c9b1d0b98431 (
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
|
/*******************************************************************************
* 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.ui.skynet.renderer;
import java.util.ArrayList;
import java.util.Collection;
import org.eclipse.osee.framework.jdk.core.type.OseeArgumentException;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.ui.skynet.render.PresentationType;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
/**
* Test Case for {@link PresentationType}
*
* @author Roberto E. Escobar
*/
@RunWith(Parameterized.class)
public class PresentationTypeTest {
private final PresentationType target;
public PresentationTypeTest(PresentationType target) {
this.target = target;
}
@Test(expected = OseeArgumentException.class)
public void testEmptyMatches() throws OseeCoreException {
target.matches();
}
@Test
public void testNoMatch() throws OseeCoreException {
Collection<PresentationType> toMatch = new ArrayList<>();
for (PresentationType item : PresentationType.values()) {
if (item != target) {
toMatch.add(item);
boolean actual = target.matches(item);
Assert.assertFalse(actual);
} else {
boolean actual = target.matches(item);
Assert.assertTrue(actual);
}
}
PresentationType[] items = toMatch.toArray(new PresentationType[toMatch.size()]);
boolean actual = target.matches(items);
Assert.assertEquals(false, actual);
}
@Test
public void testMatch() throws OseeCoreException {
Collection<PresentationType> toMatch = new ArrayList<>();
for (PresentationType item : PresentationType.values()) {
toMatch.add(item);
if (item != target) {
boolean actual = target.matches(item);
Assert.assertFalse(actual);
} else {
boolean actual = target.matches(item);
Assert.assertTrue(actual);
}
}
PresentationType[] items = toMatch.toArray(new PresentationType[toMatch.size()]);
boolean actual = target.matches(items);
Assert.assertTrue(actual);
}
@Parameters
public static Collection<Object[]> getData() {
Collection<Object[]> data = new ArrayList<>();
for (PresentationType underTest : PresentationType.values()) {
data.add(new Object[] {underTest});
}
return data;
}
}
|