/
SmarterWireTest.java
65 lines (49 loc) · 1.45 KB
/
SmarterWireTest.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
package com.artemis;
import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;
import com.artemis.annotations.Wire;
import com.artemis.component.ComponentX;
import com.artemis.component.ComponentY;
import com.artemis.managers.TagManager;
import com.artemis.systems.EntityProcessingSystem;
import com.artemis.systems.VoidEntitySystem;
public class SmarterWireTest {
private World world;
private EntityFactory entityFactory;
private TiledMapSystem tiledMapSystem;
@Before
public void init() {
world = new World();
entityFactory = world.setManager(new EntityFactory());
tiledMapSystem = world.setSystem(new TiledMapSystem());
world.initialize();
world.process();
}
@Test
public void ensure_mappers_are_injected() {
assertNotNull(entityFactory.x);
assertNotNull(entityFactory.y);
}
@Test
public void abstract_managers_are_resolved() {
assertNotNull(tiledMapSystem.factory);
assertTrue(tiledMapSystem.factory.getClass() == EntityFactory.class);
}
@Wire
abstract class AbstractEntityFactory extends Manager {
protected ComponentMapper<ComponentX> x;
}
@Wire(injectInherited=true)
class EntityFactory extends AbstractEntityFactory {
private ComponentMapper<ComponentY> y;
}
@Wire
class TiledMapSystem extends VoidEntitySystem {
// no concrete factory available in library, game should provide.
protected AbstractEntityFactory factory;
@Override
protected void processSystem() {
}
}
}