Skip to content

Commit 20ad0e3

Browse files
committed
added missing test cases consistency
1 parent 3e548e4 commit 20ad0e3

File tree

4 files changed

+40
-17
lines changed

4 files changed

+40
-17
lines changed

modevo-consistency/src/main/java/giis/modevo/consistency/OracleCsv.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,15 @@ public void csvCassandra(String tableName, String keyspace, String properties, S
6565
}
6666

6767
/**
68-
* Auxiliary method of csvCassandra that processes each row and returns
68+
* Auxiliary method of csvCassandra that processes each row and returns
6969
* its content in a string formatted as a CSV.
7070
*/
7171
private String rowProcessing(Row row, String[][] results, boolean[] numeric, int rowNumber, int columnNumber) {
7272
StringBuilder stringRow = new StringBuilder("\"");
7373
for (int i = 0; i < columnNumber; i++) {
7474
String result = row.getString(i);
7575
if (result == null) { //When there is no value stored in the db, skip the iteration
76+
stringRow.append(",\"\"");
7677
continue;
7778
}
7879
if (i==0) {
@@ -119,8 +120,8 @@ private String[][] sortMatrix(String[][] matrixResultSet, int columnNumber, List
119120
matrixResultSet = sortMatrix(matrixResultSet, columnNumber + 1, cassandraRows, 0,
120121
matrixResultSet.length - 1, numericArray);
121122
return matrixResultSet;
122-
}
123-
//For the rest of columns it sorts them when the values of the first column are the same. This also applies
123+
}
124+
//For the rest of columns it sorts them when the values of the first column are the same. This also applies
124125
//for the following of columns
125126
else {
126127
List<Integer> border = equalRanges(beggining, end, columnNumber - 1, matrixResultSet,
@@ -161,8 +162,8 @@ private void sortIteration (boolean numeric, String[][] matrixResultSet, List<St
161162
String next = matrixResultSet[row2][numberColumn];
162163
boolean sort = false;
163164
if (numeric) {
164-
Long currentNumber = Long.valueOf(current);
165-
Long nextNumber = Long.valueOf(next);
165+
long currentNumber = Long.parseLong(current);
166+
long nextNumber = Long.parseLong(next);
166167
if (currentNumber < nextNumber) {
167168
sort = true;
168169
}
@@ -263,7 +264,7 @@ public void convertToCsv(java.sql.ResultSet rs, String path) {
263264

264265
/**
265266
* Returns the names of the tables of a keyspace
266-
* @param tableProjection
267+
* @param tableProjection
267268
*/
268269
public Map<String, List<String>> namesTablesColumnsKeyspace(String keyspace, CassandraConnection connection, Map<String, String> tableProjection) {
269270
Map<String, List<String>> tableColumns = new HashMap<>();
@@ -288,7 +289,7 @@ public Map<String, List<String>> namesTablesColumnsKeyspace(String keyspace, Cas
288289
List<String> columnNamesList = new ArrayList<>();
289290
BoundStatement bsColumns = columnNamesPreparedStatement.bind(keyspace, tableName);
290291
ResultSet resultColumnNames = connection.executeStatement(bsColumns);
291-
Row rowColumnNames = resultColumnNames.one();
292+
Row rowColumnNames = resultColumnNames.one();
292293
while (rowColumnNames != null) {
293294
String columnName = rowColumnNames.getString("column_name");
294295
if (projectionStatementTable.matches(".*\\b" + columnName + "\\b.*")) {

modevo-consistency/src/test/java/test4giis/consistency/TestCheckConsistency.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,30 @@ public void testCustomV7SplitTable() throws IOException {
117117
testConsistency(name.getMethodName(), projectionAfterEvo, "custom", projectionBeforeEvo);
118118
}
119119
@Test
120+
public void testCustomV8JoinColumn() throws IOException {
121+
Map<String, String> projectionAfterEvo = new HashMap<String, String>();
122+
Map<String, String> projectionBeforeEvo = new HashMap<String, String>();
123+
projectionBeforeEvo.put("table1", "SELECT author.id AS idauthor, book.id AS idbook, book.title as title, book.subtitle AS subtitle FROM author INNER JOIN authorbook ON author.id = authorbook.idauthor INNER JOIN book ON book.id = authorbook.idbook;");
124+
projectionAfterEvo.put("table1", "SELECT author.id AS idauthor, book.id AS idbook, CONCAT(book.title, book.subtitle) AS completetitle, book.subtitle AS subtitle, book.title as title FROM author INNER JOIN authorbook ON author.id = authorbook.idauthor INNER JOIN book ON book.id = authorbook.idbook ORDER BY author.id DESC, book.id DESC;");
125+
testConsistency(name.getMethodName(), projectionAfterEvo, "custom", projectionBeforeEvo);
126+
}
127+
@Test
128+
public void testCustomV9RemovePK() throws IOException {
129+
Map<String, String> projectionAfterEvo = new HashMap<String, String>();
130+
Map<String, String> projectionBeforeEvo = new HashMap<String, String>();
131+
projectionBeforeEvo.put("table1beforechange", "SELECT author.id AS idauthor, book.id AS idbook, book.title as title FROM author INNER JOIN authorbook ON author.id = authorbook.idauthor INNER JOIN book ON book.id = authorbook.idbook;");
132+
projectionAfterEvo.put("table1", "SELECT author.id AS idauthor, book.id AS idbook FROM author INNER JOIN authorbook ON author.id = authorbook.idauthor INNER JOIN book ON book.id = authorbook.idbook ORDER BY author.id DESC, book.id DESC;");
133+
testConsistency(name.getMethodName(), projectionAfterEvo, "custom", projectionBeforeEvo);
134+
}
135+
@Test
136+
public void testMindsV3SplitColumn() throws IOException {
137+
Map<String, String> projectionAfterEvo = new HashMap<String, String>();
138+
Map<String, String> projectionBeforeEvo = new HashMap<String, String>();
139+
projectionBeforeEvo.put("comments", "SELECT id, parent_guid FROM comments;");
140+
projectionAfterEvo.put("comments", "SELECT id,parent_guid, CASE WHEN parent_guid < 'F' THEN parent_guid ELSE NULL END AS parent_guid_c1, CASE WHEN parent_guid < 'P' THEN parent_guid ELSE NULL END AS parent_guid_c2, CASE WHEN parent_guid > 'P' THEN parent_guid ELSE NULL END AS parent_guid_c3 FROM comments ORDER BY id DESC;");
141+
testConsistency(name.getMethodName(), projectionAfterEvo, "minds", projectionBeforeEvo);
142+
}
143+
@Test
120144
public void testMindsV10NewTableMigrationFromOneTable() throws IOException {
121145
Map<String, String> projectionAfterEvo = new HashMap<String, String>();
122146
Map<String, String> projectionBeforeEvo = new HashMap<String, String>();

modevo-transform/dat/inp/testMindsV3SplitColumn-schemaChange.xmi

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@
2121
<CriteriaSplit
2222
xmi:id="cs1"
2323
column="c1"
24-
value="f"
25-
operator="g"/>
24+
value="F"
25+
operator="l"/>
2626
<CriteriaSplit
2727
xmi:id="cs2"
2828
column="c2"
29-
value="p"
30-
operator="g"/>
29+
value="P"
30+
operator="l"/>
3131
<CriteriaSplit
3232
xmi:id="cs3"
3333
column="c3"
34-
value="p"
35-
operator="l"/>
34+
value="P"
35+
operator="g"/>
3636
</xmi:XMI>

0 commit comments

Comments
 (0)