本文整理了Java中org.fest.assertions.ListAssert.hasSize()
方法的一些代码示例,展示了ListAssert.hasSize()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ListAssert.hasSize()
方法的具体详情如下:
包路径:org.fest.assertions.ListAssert
类名称:ListAssert
方法名:hasSize
暂无
代码示例来源:origin: debezium/debezium
@Test
public void fpTypes() throws Exception {
Testing.debug("Inserted");
final SourceRecords records = consumeRecordsByTopic(EXPECTED_RECORD_COUNT);
List<SourceRecord> testTableRecords = records.recordsForTopic("server1.dbo.type_fp");
assertThat(testTableRecords).hasSize(1);
// insert
VerifyRecord.isValidRead(testTableRecords.get(0));
Struct after = (Struct) ((Struct)testTableRecords.get(0).value()).get("after");
assertRecord(after, EXPECTED_FP);
}
代码示例来源:origin: debezium/debezium
Assertions.assertThat(content.get(fieldName)).as(fieldName + " is present in the actual content").isNull();
return;
Assertions.assertThat(actualValue).as(fieldName + " is not present in the actual content").isNotNull();
Assertions.assertThat(value).as("Incorrect value type for " + fieldName).isInstanceOf(List.class);
final List<?> actualValueList = (List<?>)actualValue;
final List<?> valueList = (List<?>)value;
Assertions.assertThat(actualValueList).as("List size don't match for " + fieldName).hasSize(valueList.size());
if (!valueList.isEmpty() && valueList.iterator().next() instanceof Struct) {
for (int i = 0; i < valueList.size(); i++) {
代码示例来源:origin: debezium/debezium
@Test
public void dateTimeTypes() throws Exception {
Testing.debug("Inserted");
final SourceRecords records = consumeRecordsByTopic(EXPECTED_RECORD_COUNT);
List<SourceRecord> testTableRecords = records.recordsForTopic("server1.dbo.type_time");
assertThat(testTableRecords).hasSize(1);
// insert
VerifyRecord.isValidRead(testTableRecords.get(0));
Struct after = (Struct) ((Struct)testTableRecords.get(0).value()).get("after");
assertRecord(after, EXPECTED_DATE_TIME);
}
代码示例来源:origin: debezium/debezium
SourceRecord executeSimpleUpdateOperation(String updateDocument) throws InterruptedException {
primary().execute("insert", createInsertItemDefault(1));
SourceRecords records = consumeRecordsByTopic(1);
assertThat(records.recordsForTopic(this.topicName())).hasSize(1);
primary().execute("update", createUpdateOneItem(1, updateDocument));
return getUpdateRecord();
}
代码示例来源:origin: debezium/debezium
@Test
public void intTypes() throws Exception {
Testing.debug("Inserted");
final SourceRecords records = consumeRecordsByTopic(EXPECTED_RECORD_COUNT);
List<SourceRecord> testTableRecords = records.recordsForTopic("server1.dbo.type_int");
assertThat(testTableRecords).hasSize(1);
// insert
VerifyRecord.isValidRead(testTableRecords.get(0));
Struct after = (Struct) ((Struct)testTableRecords.get(0).value()).get("after");
assertRecord(after, EXPECTED_INT);
}
代码示例来源:origin: debezium/debezium
Assertions.assertThat(records.recordsForTopic("server1.dbo.MyTableOne")).hasSize(1);
SourceRecord record = records.recordsForTopic("server1.dbo.MyTableOne").get(0);
assertSchemaMatchesStruct(
.build()
);
Assertions.assertThat(((Struct)((Struct)record.value()).get("after")).getInt32("Id")).isEqualTo(1);
Assertions.assertThat(records.recordsForTopic("server1.dbo.MyTableOne")).hasSize(1);
record = records.recordsForTopic("server1.dbo.MyTableOne").get(0);
assertSchemaMatchesStruct(
connection.execute("INSERT INTO MyTableTwo VALUES(3, 'b')");
records = consumeRecordsByTopic(1);
Assertions.assertThat(records.recordsForTopic("server1.dbo.MyTableTwo")).hasSize(1);
record = records.recordsForTopic("server1.dbo.MyTableTwo").get(0);
assertSchemaMatchesStruct(
代码示例来源:origin: debezium/debezium
@Test
public void otherTypes() throws Exception {
Testing.debug("Inserted");
final SourceRecords records = consumeRecordsByTopic(EXPECTED_RECORD_COUNT);
List<SourceRecord> testTableRecords = records.recordsForTopic("server1.dbo.type_xml");
assertThat(testTableRecords).hasSize(1);
// insert
VerifyRecord.isValidRead(testTableRecords.get(0));
Struct after = (Struct) ((Struct)testTableRecords.get(0).value()).get("after");
assertRecord(after, EXPECTED_XML);
}
代码示例来源:origin: camunda/camunda-bpm-platform
private void verifyTenantIdListParameterResponse(Response response) {
String content = response.asString();
List<String> historicDetails = from(content).getList("");
assertThat(historicDetails).hasSize(4);
String returnedTenantId1 = from(content).getString("[0].tenantId");
String returnedTenantId2 = from(content).getString("[1].tenantId");
String returnedTenantId3 = from(content).getString("[2].tenantId");
String returnedTenantId4 = from(content).getString("[3].tenantId");
assertThat(returnedTenantId1).isEqualTo(MockProvider.EXAMPLE_TENANT_ID);
assertThat(returnedTenantId2).isEqualTo(MockProvider.EXAMPLE_TENANT_ID);
assertThat(returnedTenantId3).isEqualTo(MockProvider.ANOTHER_EXAMPLE_TENANT_ID);
assertThat(returnedTenantId4).isEqualTo(MockProvider.ANOTHER_EXAMPLE_TENANT_ID);
}
代码示例来源:origin: debezium/debezium
@Test
public void stringTypes() throws Exception {
Testing.debug("Inserted");
final SourceRecords records = consumeRecordsByTopic(EXPECTED_RECORD_COUNT);
List<SourceRecord> testTableRecords = records.recordsForTopic("server1.dbo.type_string");
assertThat(testTableRecords).hasSize(1);
// insert
VerifyRecord.isValidRead(testTableRecords.get(0));
Struct after = (Struct) ((Struct)testTableRecords.get(0).value()).get("after");
assertRecord(after, EXPECTED_STRING);
}
代码示例来源:origin: debezium/debezium
@Test
@FixFor("DBZ-910")
public void shouldParseConstraintCheck() {
parser = new MysqlDdlParserWithSimpleTestListener(listener, true);
final String ddl =
"CREATE TABLE t1 (c1 INTEGER NOT NULL,c2 VARCHAR(22),CHECK (c2 IN ('A', 'B', 'C')));"
+ "CREATE TABLE t2 (c1 INTEGER NOT NULL,c2 VARCHAR(22),CONSTRAINT c1 CHECK (c2 IN ('A', 'B', 'C')));"
+ "CREATE TABLE t3 (c1 INTEGER NOT NULL,c2 VARCHAR(22),CONSTRAINT CHECK (c2 IN ('A', 'B', 'C')));"
+ "ALTER TABLE t1 ADD CONSTRAINT CHECK (c1 IN (1, 2, 3, 4));"
+ "ALTER TABLE t1 ADD CONSTRAINT c2 CHECK (c1 IN (1, 2, 3, 4))"
+ "ALTER TABLE t1 ADD CHECK (c1 IN (1, 2, 3, 4))";
parser.parse(ddl, tables);
assertThat(tables.size()).isEqualTo(3);
assertThat(tables.forTable(null, null, "t1").columns()).hasSize(2);
assertThat(tables.forTable(null, null, "t2").columns()).hasSize(2);
assertThat(tables.forTable(null, null, "t3").columns()).hasSize(2);
}
代码示例来源:origin: debezium/debezium
@Test
public void parseTableWithPageChecksum() {
String ddl =
"CREATE TABLE t (id INT NOT NULL, PRIMARY KEY (`id`)) PAGE_CHECKSUM=1;" +
"ALTER TABLE t PAGE_CHECKSUM=0;";
parser.parse(ddl, tables);
assertThat(tables.size()).isEqualTo(1);
Table t = tables.forTable(new TableId(null, null, "t"));
assertThat(t).isNotNull();
assertThat(t.retrieveColumnNames()).containsExactly("id");
assertThat(t.primaryKeyColumnNames()).hasSize(1);
assertColumn(t, "id", "INT", Types.INTEGER, -1, -1, false, false, false);
}
代码示例来源:origin: debezium/debezium
@Test
@FixFor("DBZ-429")
public void parseTableWithNegativeDefault() {
String ddl =
"CREATE TABLE t (id INT NOT NULL, myvalue INT DEFAULT -10, PRIMARY KEY (`id`));";
parser.parse(ddl, tables);
assertThat(tables.size()).isEqualTo(1);
Table t = tables.forTable(new TableId(null, null, "t"));
assertThat(t).isNotNull();
assertThat(t.retrieveColumnNames()).containsExactly("id", "myvalue");
assertThat(t.primaryKeyColumnNames()).hasSize(1);
assertColumn(t, "myvalue", "INT", Types.INTEGER, -1, -1, true, false, false);
}
代码示例来源:origin: debezium/debezium
@Test
@FixFor("DBZ-1059")
public void shouldParseAlterTableRename() {
final String ddl = "USE db;"
+ "CREATE TABLE db.t1 (ID INTEGER PRIMARY KEY);"
+ "ALTER TABLE `t1` RENAME TO `t2`;"
+ "ALTER TABLE `db`.`t2` RENAME TO `db`.`t3`;";
parser = new MysqlDdlParserWithSimpleTestListener(listener, true);
parser.parse(ddl, tables);
assertThat(tables.size()).isEqualTo(1);
final Table table = tables.forTable(new TableId(null, "db", "t3"));
assertThat(table).isNotNull();
assertThat(table.columns()).hasSize(1);
}
代码示例来源:origin: debezium/debezium
@Test
public void shouldUseOverriddenSelectStatementDuringSnapshotting() throws Exception {
before(Configuration.create()
.with(PostgresConnectorConfig.SNAPSHOT_SELECT_STATEMENT_OVERRIDES_BY_TABLE, "over.t1")
.with(PostgresConnectorConfig.SNAPSHOT_SELECT_STATEMENT_OVERRIDES_BY_TABLE.name() + ".over.t1", "SELECT * FROM over.t1 WHERE pk > 100")
.build());
snapshotProducer = new RecordsSnapshotProducer(context, new SourceInfo(TestHelper.TEST_SERVER, TestHelper.TEST_DATABASE), false);
final int expectedRecordsCount = 3 + 6;
TestHelper.execute(STATEMENTS);
TestConsumer consumer = testConsumer(expectedRecordsCount, "over");
snapshotProducer.start(consumer, e -> {});
consumer.await(TestHelper.waitTimeForRecords(), TimeUnit.SECONDS);
final Map<String, List<SourceRecord>> recordsByTopic = recordsByTopic(expectedRecordsCount, consumer);
Assertions.assertThat(recordsByTopic.get("test_server.over.t1")).hasSize(3);
Assertions.assertThat(recordsByTopic.get("test_server.over.t2")).hasSize(6);
}
代码示例来源:origin: debezium/debezium
@Test
@FixFor("DBZ-780")
public void shouldRenameColumnWithoutDefinition() {
parser = new MysqlDdlParserWithSimpleTestListener(listener, TableFilter.fromPredicate(x -> !x.table().contains("ignored")));
final String ddl = "CREATE TABLE foo (id int primary key, old INT);" + System.lineSeparator()
+ "ALTER TABLE foo RENAME COLUMN old to new ";
parser.parse(ddl, tables);
assertThat(((MysqlDdlParserWithSimpleTestListener)parser).getParsingExceptionsFromWalker()).isEmpty();
assertThat(tables.size()).isEqualTo(1);
final Table t1 = tables.forTable(null, null, "foo");
assertThat(t1.columns()).hasSize(2);
final Column c1 = t1.columns().get(0);
final Column c2 = t1.columns().get(1);
assertThat(c1.name()).isEqualTo("id");
assertThat(c1.typeName()).isEqualTo("INT");
assertThat(c2.name()).isEqualTo("new");
assertThat(c2.typeName()).isEqualTo("INT");
}
代码示例来源:origin: debezium/debezium
@Test
public void shouldUseFiltersForAlterTable() {
parser = new MysqlDdlParserWithSimpleTestListener(listener, TableFilter.fromPredicate(x -> !x.table().contains("ignored")));
final String ddl = "CREATE TABLE ok (id int primary key, val smallint);" + System.lineSeparator()
+ "ALTER TABLE ignored ADD COLUMN(x tinyint)" + System.lineSeparator()
+ "ALTER TABLE ok ADD COLUMN(y tinyint)";
parser.parse(ddl, tables);
assertThat(((MysqlDdlParserWithSimpleTestListener)parser).getParsingExceptionsFromWalker()).isEmpty();
assertThat(tables.size()).isEqualTo(1);
final Table t1 = tables.forTable(null, null, "ok");
assertThat(t1.columns()).hasSize(3);
final Column c1 = t1.columns().get(0);
final Column c2 = t1.columns().get(1);
final Column c3 = t1.columns().get(2);
assertThat(c1.name()).isEqualTo("id");
assertThat(c1.typeName()).isEqualTo("INT");
assertThat(c2.name()).isEqualTo("val");
assertThat(c2.typeName()).isEqualTo("SMALLINT");
assertThat(c3.name()).isEqualTo("y");
assertThat(c3.typeName()).isEqualTo("TINYINT");
}
代码示例来源:origin: debezium/debezium
@Test
public void shouldUseMultipleOverriddenSelectStatementsDuringSnapshotting() throws Exception {
before(Configuration.create()
.with(PostgresConnectorConfig.SNAPSHOT_SELECT_STATEMENT_OVERRIDES_BY_TABLE, "over.t1,over.t2")
.with(PostgresConnectorConfig.SNAPSHOT_SELECT_STATEMENT_OVERRIDES_BY_TABLE.name() + ".over.t1", "SELECT * FROM over.t1 WHERE pk > 101")
.with(PostgresConnectorConfig.SNAPSHOT_SELECT_STATEMENT_OVERRIDES_BY_TABLE.name() + ".over.t2", "SELECT * FROM over.t2 WHERE pk > 100")
.build());
snapshotProducer = new RecordsSnapshotProducer(context, new SourceInfo(TestHelper.TEST_SERVER, TestHelper.TEST_DATABASE), false);
final int expectedRecordsCount = 2 + 3;
TestHelper.execute(STATEMENTS);
TestConsumer consumer = testConsumer(expectedRecordsCount, "over");
snapshotProducer.start(consumer, e -> {});
consumer.await(TestHelper.waitTimeForRecords(), TimeUnit.SECONDS);
final Map<String, List<SourceRecord>> recordsByTopic = recordsByTopic(expectedRecordsCount, consumer);
Assertions.assertThat(recordsByTopic.get("test_server.over.t1")).hasSize(2);
Assertions.assertThat(recordsByTopic.get("test_server.over.t2")).hasSize(3);
}
代码示例来源:origin: debezium/debezium
@Test
public void removeTable() throws Exception {
final int RECORDS_PER_TABLE = 5;
Assertions.assertThat(records.recordsForTopic("server1.dbo.tablea")).hasSize(RECORDS_PER_TABLE);
Assertions.assertThat(records.recordsForTopic("server1.dbo.tableb")).hasSize(RECORDS_PER_TABLE);
Assertions.assertThat(records.recordsForTopic("server1.dbo.tablea")).hasSize(RECORDS_PER_TABLE);
Assertions.assertThat(records.recordsForTopic("server1.dbo.tableb")).isNullOrEmpty();
代码示例来源:origin: debezium/debezium
@Test
public void testHeartbeatMessageTopicReplacementTopic(){
final ByLogicalTableRouter<SourceRecord> router = new ByLogicalTableRouter<>();
assertThat(transformed1).isNotNull();
assertThat(transformed1.topic()).isEqualTo(replacedTopic);
assertThat(transformed1.keySchema().name()).isEqualTo(replacedTopic + ".Key");
assertThat(transformed1.keySchema().fields()).hasSize(2);
assertThat(transformed1.keySchema().fields().get(0).name()).isEqualTo(keyFieldName);
assertThat(transformed1.keySchema().fields().get(1).name()).isEqualTo(keyOriginalKeyTopic);
assertThat(transformed2.keySchema().name()).isEqualTo(replacedTopic + ".Key");
assertThat(transformed2.keySchema().fields()).hasSize(2);
assertThat(transformed2.keySchema().fields().get(0).name()).isEqualTo(keyFieldName);
assertThat(transformed2.keySchema().fields().get(1).name()).isEqualTo(keyOriginalKeyTopic);
代码示例来源:origin: debezium/debezium
@Test
@FixFor("DBZ-612")
public void shouldGenerateRecordForUpdateEventWithUnset() throws InterruptedException {
RecordsForCollection records = recordMakers.forCollection(collectionId);
records.recordEvent(event, 1002);
assertThat(produced.size()).isEqualTo(1);
SourceRecord record = produced.get(0);
assertThat(value.schema()).isSameAs(transformed.valueSchema());
assertThat(value.get("name")).isEqualTo("Sally");
assertThat(value.get("phone")).isEqualTo(null);
assertThat(value.schema().field("phone").schema()).isEqualTo(SchemaBuilder.OPTIONAL_STRING_SCHEMA);
assertThat(value.schema().fields()).hasSize(3);
内容来源于网络,如有侵权,请联系作者删除!