-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTutorialOrderSyncDemoTest.java
More file actions
54 lines (47 loc) · 2.13 KB
/
TutorialOrderSyncDemoTest.java
File metadata and controls
54 lines (47 loc) · 2.13 KB
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
package io.github.evoschema;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.springframework.jdbc.core.JdbcTemplate;
public class TutorialOrderSyncDemoTest extends AbstractEvoSchemaIntegrationTest
{
private static final String CUSTOMER_SCHEMA_SQL = "unittest/tutorial-order-sync-customer-schema.sql";
private static final String FINANCE_SCHEMA_SQL = "unittest/tutorial-order-sync-finance-schema.sql";
@BeforeClass
public static void initSchema()
{
prepareTestEnvironment();
initSchemaForDataSource("customer", CUSTOMER_SCHEMA_SQL);
initSchemaForDataSource("finance", FINANCE_SCHEMA_SQL);
}
@Test
public void shouldRunTutorialOrderSyncDemo()
{
Starter.main(new String[] { "tutorial_order_sync" });
JdbcTemplate baseTemplate = jdbcTemplate("customer");
JdbcTemplate financeTemplate = jdbcTemplate("finance");
Long readyCount = baseTemplate.queryForObject(
"SELECT COUNT(1) FROM customer_orders WHERE status = 'READY'",
Long.class
);
Long syncLogCount = baseTemplate.queryForObject(
"SELECT COUNT(1) FROM order_sync_log WHERE status = 'SYNCED'",
Long.class
);
Long financeSyncedCount = financeTemplate.queryForObject(
"SELECT COUNT(1) FROM finance_orders WHERE sync_status = 'SYNCED'",
Long.class
);
String syncNoteDefault = financeTemplate.queryForObject(
"SELECT COLUMN_DEFAULT FROM information_schema.COLUMNS " +
"WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'finance_orders' AND COLUMN_NAME = 'sync_note'",
String.class
);
Assert.assertEquals(Long.valueOf(2L), readyCount);
Assert.assertEquals(Long.valueOf(2L), syncLogCount);
Assert.assertEquals(Long.valueOf(2L), financeSyncedCount);
Assert.assertEquals("DONE", syncNoteDefault);
Assert.assertTrue(tableExists("customer", "order_sync_log"));
Assert.assertTrue(columnExists("finance", "finance_orders", "sync_note"));
}
}