Search in sources :

Example 1 with DdlResult

use of com.alibaba.otter.canal.parse.inbound.mysql.ddl.DdlResult in project canal by alibaba.

the class SimpleDdlParserTest method testIndex.

@Test
public void testIndex() {
    String queryString = "CREATE UNIQUE INDEX index_1 ON retl_mark(id,x)";
    DdlResult result = SimpleDdlParser.parse(queryString, "retl");
    Assert.assertNotNull(result);
    Assert.assertEquals("retl", result.getSchemaName());
    Assert.assertEquals("retl_mark", result.getTableName());
    queryString = "create index idx_qca_cid_mcid on q_contract_account (contract_id,main_contract_id)";
    result = SimpleDdlParser.parse(queryString, "retl");
    Assert.assertNotNull(result);
    Assert.assertEquals("retl", result.getSchemaName());
    Assert.assertEquals("q_contract_account", result.getTableName());
    queryString = "DROP INDEX index_str ON retl_mark";
    result = SimpleDdlParser.parse(queryString, "retl");
    Assert.assertNotNull(result);
    Assert.assertEquals("retl", result.getSchemaName());
    Assert.assertEquals("retl_mark", result.getTableName());
    // test index name contains 'on' -- version
    queryString = "create index schema_new_index_version_s_idx on q_contract_account (contract_id,main_contract_id)";
    result = SimpleDdlParser.parse(queryString, "retl");
    Assert.assertNotNull(result);
    Assert.assertEquals("retl", result.getSchemaName());
    Assert.assertEquals("q_contract_account", result.getTableName());
    queryString = "drop index schema_new_index_version_s_idx on q_contract_account";
    result = SimpleDdlParser.parse(queryString, "retl");
    Assert.assertNotNull(result);
    Assert.assertEquals("retl", result.getSchemaName());
    Assert.assertEquals("q_contract_account", result.getTableName());
}
Also used : DdlResult(com.alibaba.otter.canal.parse.inbound.mysql.ddl.DdlResult) Test(org.junit.Test)

Example 2 with DdlResult

use of com.alibaba.otter.canal.parse.inbound.mysql.ddl.DdlResult in project canal by alibaba.

the class DdlResultTest method setTableNameInputNotNullOutputVoid.

// Test written by Diffblue Cover.
@Test
public void setTableNameInputNotNullOutputVoid() {
    // Arrange
    final DdlResult objectUnderTest = new DdlResult();
    final String tableName = "3";
    // Act
    objectUnderTest.setTableName(tableName);
    // Assert side effects
    Assert.assertEquals("3", objectUnderTest.getTableName());
}
Also used : DdlResult(com.alibaba.otter.canal.parse.inbound.mysql.ddl.DdlResult) Test(org.junit.Test)

Example 3 with DdlResult

use of com.alibaba.otter.canal.parse.inbound.mysql.ddl.DdlResult in project canal by alibaba.

the class DdlResultTest method setOriTableNameInputNotNullOutputVoid.

// Test written by Diffblue Cover.
@Test
public void setOriTableNameInputNotNullOutputVoid() {
    // Arrange
    final DdlResult objectUnderTest = new DdlResult();
    final String oriTableName = "3";
    // Act
    objectUnderTest.setOriTableName(oriTableName);
    // Assert side effects
    Assert.assertEquals("3", objectUnderTest.getOriTableName());
}
Also used : DdlResult(com.alibaba.otter.canal.parse.inbound.mysql.ddl.DdlResult) Test(org.junit.Test)

Example 4 with DdlResult

use of com.alibaba.otter.canal.parse.inbound.mysql.ddl.DdlResult in project canal by alibaba.

the class DdlResultTest method toStringOutputNotNull2.

// Test written by Diffblue Cover.
@Test
public void toStringOutputNotNull2() throws InvocationTargetException {
    // Arrange
    final DdlResult objectUnderTest = new DdlResult();
    objectUnderTest.setSchemaName(null);
    objectUnderTest.setType(null);
    objectUnderTest.setOriSchemaName(null);
    objectUnderTest.setTableName(",");
    final DdlResult ddlResult = new DdlResult();
    objectUnderTest.setRenameTableResult(ddlResult);
    objectUnderTest.setOriTableName("2");
    // Act
    final String actual = objectUnderTest.toString();
    // Assert result
    Assert.assertEquals("DdlResult [schemaName=null , tableName=, , oriSchemaName=null , oriTableName=2 , type=null ];DdlResult [schemaName=null , tableName=null , oriSchemaName=null , oriTableName=null , type=null ];", actual);
}
Also used : DdlResult(com.alibaba.otter.canal.parse.inbound.mysql.ddl.DdlResult) Test(org.junit.Test)

Example 5 with DdlResult

use of com.alibaba.otter.canal.parse.inbound.mysql.ddl.DdlResult in project canal by alibaba.

the class DdlResultTest method constructorInputNotNullNotNullOutputVoid.

// Test written by Diffblue Cover.
@Test
public void constructorInputNotNullNotNullOutputVoid() {
    // Arrange
    final String schemaName = ",";
    final String tableName = "BAZ";
    // Act, creating object to test constructor
    final DdlResult objectUnderTest = new DdlResult(schemaName, tableName);
    // Assert side effects
    Assert.assertEquals(",", objectUnderTest.getSchemaName());
    Assert.assertEquals("BAZ", objectUnderTest.getTableName());
}
Also used : DdlResult(com.alibaba.otter.canal.parse.inbound.mysql.ddl.DdlResult) Test(org.junit.Test)

Aggregations

DdlResult (com.alibaba.otter.canal.parse.inbound.mysql.ddl.DdlResult)33 Test (org.junit.Test)29 CanalParseException (com.alibaba.otter.canal.parse.exception.CanalParseException)3 ByteString (com.google.protobuf.ByteString)3 EventType (com.alibaba.otter.canal.protocol.CanalEntry.EventType)2 MetaHistoryDO (com.alibaba.otter.canal.parse.inbound.mysql.tsdb.dao.MetaHistoryDO)1 Header (com.alibaba.otter.canal.protocol.CanalEntry.Header)1 RowChange (com.alibaba.otter.canal.protocol.CanalEntry.RowChange)1 TransactionBegin (com.alibaba.otter.canal.protocol.CanalEntry.TransactionBegin)1 TransactionEnd (com.alibaba.otter.canal.protocol.CanalEntry.TransactionEnd)1 EntryPosition (com.alibaba.otter.canal.protocol.position.EntryPosition)1 LogHeader (com.taobao.tddl.dbsync.binlog.event.LogHeader)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 HashMap (java.util.HashMap)1 List (java.util.List)1