-
Notifications
You must be signed in to change notification settings - Fork 5
/
DirectClassTest.java
132 lines (99 loc) · 2.83 KB
/
DirectClassTest.java
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
package org.genericsystem.kernel;
import org.genericsystem.api.core.annotations.DirectClass;
import org.genericsystem.api.core.annotations.InstanceClass;
import org.genericsystem.api.core.annotations.Meta;
import org.genericsystem.api.core.annotations.SystemGeneric;
import org.genericsystem.common.Generic;
import org.testng.annotations.Test;
@Test
public class DirectClassTest extends AbstractTest {
public void test001() {
Engine engine = new Engine(Vehicle1.class);
assert engine.find(Vehicle1.class) instanceof Vehicle1;
}
public void test002() {
Engine engine = new Engine(Vehicle2.class);
assert engine.find(Vehicle2.class) instanceof Vehicle2;
}
public void test003() {
Engine engine = new Engine(Vehicle3.class);
assert engine.find(Vehicle3.class) instanceof Vehicle3;
}
public void test004() {
Engine engine = new Engine(Vehicle4.class);
assert engine.find(Vehicle4.class) instanceof Vehicle4;
}
public void test005() {
Engine engine = new Engine(Vehicle5.class);
assert !(engine.find(Vehicle5.class) instanceof Vehicle5);
}
public void test006() {
Engine engine = new Engine(Vehicle6.class);
assert engine.find(Vehicle6.class) instanceof Vehicle6;
assert engine.find(Vehicle6.class) instanceof Generic;
}
public void test007() {
Engine engine = new Engine(Car.class, CarStandard.class, MyAudi.class, MyBmw.class);
assert engine.find(MyBmw.class) instanceof CarStandard;
assert engine.find(MyAudi.class) instanceof MyAudi;
}
public void test008() {
Engine engine = new Engine(CarStandard.class);
System.out.println(engine.find(CarStandard.class).getClass().getName());
CarStandard cs = engine.find(CarStandard.class);
}
public void test009() {
catchAndCheckCause(() -> new Engine(MyBmw2.class), IllegalStateException.class);
catchAndCheckCause(() -> new Engine(MyBmw3.class), IllegalStateException.class);
}
@SystemGeneric
public static interface Vehicle1 extends Generic {
}
@DirectClass
@SystemGeneric
public static interface Vehicle2 {
}
@SystemGeneric
public static class Vehicle3 implements Generic {
}
@DirectClass
@SystemGeneric
public static class Vehicle4 {
}
@SystemGeneric
public static class Vehicle5 {
}
@DirectClass
@SystemGeneric
public static class Vehicle6 implements Generic {
}
@SystemGeneric
@Meta(Car.class)
public static class Bmw implements Generic {
}
@InstanceClass(CarStandard.class)
@SystemGeneric
public static interface Car {
}
@SystemGeneric
@Meta(Car.class)
public static class CarStandard {
}
@SystemGeneric
@Meta(Car.class)
public static class MyBmw extends CarStandard {
}
@SystemGeneric
@Meta(Car.class)
public static class MyBmw2 {
}
@SystemGeneric
@Meta(Car.class)
public static class MyBmw3 extends Bmw {
}
@DirectClass
@SystemGeneric
@Meta(Car.class)
public static class MyAudi extends CarStandard {
}
}