1 |
|
package liquibase.change.core; |
2 |
|
|
3 |
|
import liquibase.change.Change; |
4 |
|
import liquibase.change.ChangeFactory; |
5 |
|
import static org.junit.Assert.*; |
6 |
|
import org.junit.Before; |
7 |
|
import org.junit.Test; |
8 |
|
|
9 |
|
|
10 |
|
@link |
11 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (44) |
Complexity: 9 |
Complexity Density: 0.26 |
|
12 |
|
public class ChangeFactoryTest { |
13 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
14 |
8
|
@Before... |
15 |
|
public void setup() { |
16 |
8
|
ChangeFactory.reset(); |
17 |
|
|
18 |
|
} |
19 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1
PASS
|
|
20 |
1
|
@Test... |
21 |
|
public void getInstance() { |
22 |
1
|
assertNotNull(ChangeFactory.getInstance()); |
23 |
|
|
24 |
1
|
assertTrue(ChangeFactory.getInstance() == ChangeFactory.getInstance()); |
25 |
|
} |
26 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1
PASS
|
|
27 |
1
|
@Test... |
28 |
|
public void register() { |
29 |
1
|
ChangeFactory.getInstance().getRegistry().clear(); |
30 |
|
|
31 |
1
|
assertEquals(0, ChangeFactory.getInstance().getRegistry().size()); |
32 |
|
|
33 |
1
|
ChangeFactory.getInstance().register(CreateTableChange.class); |
34 |
|
|
35 |
1
|
assertEquals(1, ChangeFactory.getInstance().getRegistry().size()); |
36 |
|
} |
37 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 1 |
Complexity Density: 0.1 |
1
PASS
|
|
38 |
1
|
@Test... |
39 |
|
public void unregister_instance() { |
40 |
1
|
ChangeFactory factory = ChangeFactory.getInstance(); |
41 |
|
|
42 |
1
|
factory.getRegistry().clear(); |
43 |
|
|
44 |
1
|
assertEquals(0, factory.getRegistry().size()); |
45 |
|
|
46 |
1
|
AddAutoIncrementChange change = new AddAutoIncrementChange(); |
47 |
|
|
48 |
1
|
factory.register(CreateTableChange.class); |
49 |
1
|
factory.register(change.getClass()); |
50 |
1
|
factory.register(DropTableChange.class); |
51 |
|
|
52 |
1
|
assertEquals(3, factory.getRegistry().size()); |
53 |
|
|
54 |
1
|
factory.unregister(change.getChangeMetaData().getName()); |
55 |
1
|
assertEquals(2, factory.getRegistry().size()); |
56 |
|
} |
57 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 1 |
Complexity Density: 0.11 |
1
PASS
|
|
58 |
1
|
@Test... |
59 |
|
public void unregister_doesNotExist() { |
60 |
1
|
ChangeFactory factory = ChangeFactory.getInstance(); |
61 |
|
|
62 |
1
|
factory.getRegistry().clear(); |
63 |
|
|
64 |
1
|
assertEquals(0, factory.getRegistry().size()); |
65 |
|
|
66 |
1
|
factory.register(CreateTableChange.class); |
67 |
1
|
factory.register(AddAutoIncrementChange.class); |
68 |
1
|
factory.register(DropTableChange.class); |
69 |
|
|
70 |
1
|
assertEquals(3, factory.getRegistry().size()); |
71 |
|
|
72 |
1
|
factory.unregister("doesNoExist"); |
73 |
1
|
assertEquals(3, factory.getRegistry().size()); |
74 |
|
} |
75 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1
PASS
|
|
76 |
1
|
@Test... |
77 |
|
public void create_exists() { |
78 |
1
|
Change change = ChangeFactory.getInstance().create("createTable"); |
79 |
|
|
80 |
1
|
assertNotNull(change); |
81 |
1
|
assertTrue(change instanceof CreateTableChange); |
82 |
|
|
83 |
|
} |
84 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1
PASS
|
|
85 |
1
|
@Test... |
86 |
|
public void builtInGeneratorsAreFound() { |
87 |
1
|
assertTrue(ChangeFactory.getInstance().getRegistry().size() > 10); |
88 |
|
} |
89 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1
PASS
|
|
90 |
1
|
@Test... |
91 |
|
public void create_notExists() { |
92 |
1
|
Change change = ChangeFactory.getInstance().create("badChangeName"); |
93 |
|
|
94 |
1
|
assertNull(change); |
95 |
|
|
96 |
|
} |
97 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1
PASS
|
|
98 |
1
|
@Test... |
99 |
|
public void reset() { |
100 |
1
|
ChangeFactory instance1 = ChangeFactory.getInstance(); |
101 |
1
|
ChangeFactory.reset(); |
102 |
1
|
assertFalse(instance1 == ChangeFactory.getInstance()); |
103 |
|
} |
104 |
|
} |