1 |
|
package liquibase.change.core; |
2 |
|
|
3 |
|
import liquibase.change.AbstractChangeTest; |
4 |
|
import liquibase.change.ColumnConfig; |
5 |
|
import liquibase.database.core.MockDatabase; |
6 |
|
import liquibase.statement.SqlStatement; |
7 |
|
import liquibase.statement.core.InsertStatement; |
8 |
|
import static org.junit.Assert.*; |
9 |
|
import org.junit.Before; |
10 |
|
import org.junit.Test; |
11 |
|
|
12 |
|
|
13 |
|
@link |
14 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (31) |
Complexity: 4 |
Complexity Density: 0.15 |
|
15 |
|
public class InsertDataChangeTest extends AbstractChangeTest { |
16 |
|
|
17 |
|
InsertDataChange refactoring; |
18 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (18) |
Complexity: 1 |
Complexity Density: 0.06 |
|
19 |
6
|
@Before... |
20 |
|
public void setUp() throws Exception { |
21 |
6
|
refactoring = new InsertDataChange(); |
22 |
6
|
refactoring.setTableName("TABLE_NAME"); |
23 |
|
|
24 |
6
|
ColumnConfig col1 = new ColumnConfig(); |
25 |
6
|
col1.setName("id"); |
26 |
6
|
col1.setValueNumeric("123"); |
27 |
|
|
28 |
6
|
ColumnConfig col2 = new ColumnConfig(); |
29 |
6
|
col2.setName("name"); |
30 |
6
|
col2.setValue("Andrew"); |
31 |
|
|
32 |
6
|
ColumnConfig col3 = new ColumnConfig(); |
33 |
6
|
col3.setName("age"); |
34 |
6
|
col3.setValueNumeric("21"); |
35 |
|
|
36 |
6
|
ColumnConfig col4 = new ColumnConfig(); |
37 |
6
|
col4.setName("height"); |
38 |
6
|
col4.setValueNumeric("1.78"); |
39 |
|
|
40 |
6
|
refactoring.addColumn(col1); |
41 |
6
|
refactoring.addColumn(col2); |
42 |
6
|
refactoring.addColumn(col3); |
43 |
6
|
refactoring.addColumn(col4); |
44 |
|
} |
45 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1
PASS
|
|
46 |
1
|
@Override... |
47 |
|
@Test |
48 |
|
public void getRefactoringName() throws Exception { |
49 |
1
|
assertEquals("Insert Row", refactoring.getChangeMetaData().getDescription()); |
50 |
|
} |
51 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1
PASS
|
|
52 |
1
|
@Override... |
53 |
|
@Test |
54 |
|
public void generateStatement() throws Exception { |
55 |
1
|
SqlStatement[] sqlStatements = refactoring.generateStatements(new MockDatabase()); |
56 |
1
|
assertEquals(1, sqlStatements.length); |
57 |
1
|
assertTrue(sqlStatements[0] instanceof InsertStatement); |
58 |
1
|
assertEquals("123", ((InsertStatement) sqlStatements[0]).getColumnValue("id").toString()); |
59 |
1
|
assertEquals("Andrew", ((InsertStatement) sqlStatements[0]).getColumnValue("name").toString()); |
60 |
1
|
assertEquals("21", ((InsertStatement) sqlStatements[0]).getColumnValue("age").toString()); |
61 |
1
|
assertEquals("1.78", ((InsertStatement) sqlStatements[0]).getColumnValue("height").toString()); |
62 |
|
} |
63 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1
PASS
|
|
64 |
1
|
@Override... |
65 |
|
@Test |
66 |
|
public void getConfirmationMessage() throws Exception { |
67 |
1
|
assertEquals("New row inserted into TABLE_NAME", refactoring.getConfirmationMessage()); |
68 |
|
} |
69 |
|
} |