protected void assertNoTablesExistForDatabase(String dbName) { assertThat(mysql.tableIds().stream().filter(id->id.catalog().equals(dbName)).count()).isEqualTo(0); } protected void assertTablesExistForDatabase(String dbName) {
protected void assertTablesExistForDatabase(String dbName) { assertThat(mysql.tableIds().stream().filter(id->id.catalog().equals(dbName)).count()).isGreaterThan(0); }
assertThat(persistedOffsetSource.binlogFilename()).isEqualTo(positionAfterInserts.binlogFilename()); assertThat(persistedOffsetSource.binlogPosition()).isGreaterThan(positionBeforeInserts.binlogPosition()); assertThat(persistedOffsetSource.binlogPosition()).isLessThan(positionAfterInserts.binlogPosition()); } else { assertThat(persistedOffsetSource.eventsToSkipUponRestart()).isEqualTo(0);
/** * Test method for {@link ThreadUtils#sleep(long)}. */ @Test public void testSleep() { StopWatch watch = new StopWatch(); watch.start(); ThreadUtils.sleep(1000); watch.stop(); assertThat(watch.getTime()).isGreaterThanOrEqualTo(1000); assertThat(watch.getTime()).isLessThan(3000); }
public DateAssert isEqualTo(Date expected, int toleranceInSeconds) { Assertions.assertThat(actual).overridingErrorMessage("actual is null").isNotNull(); long right = DateUtils.addSeconds(actual, toleranceInSeconds).getTime(); long left = DateUtils.addSeconds(actual, -toleranceInSeconds).getTime(); Assertions.assertThat(actual.getTime()).overridingErrorMessage("actual date not in expected range : ("+left+","+right+")") .isGreaterThan(left).isLessThan(right); return this; }
/** * Wait for a maximum amount of time until the first record is available. * * @param timeout the maximum amount of time to wait; must not be negative * @param unit the time unit for {@code timeout} * @return {@code true} if records are available, or {@code false} if the timeout occurred and no records are available */ protected boolean waitForAvailableRecords(long timeout, TimeUnit unit) { assertThat(timeout).isGreaterThanOrEqualTo(0); long now = System.currentTimeMillis(); long stop = now + unit.toMillis(timeout); while (System.currentTimeMillis() < stop) { if (!consumedLines.isEmpty()) break; } return consumedLines.isEmpty() ? false : true; }
assertThat(persistedOffsetSource.binlogFilename()).isEqualTo(positionAfterInserts.binlogFilename()); assertThat(persistedOffsetSource.binlogPosition()).isGreaterThan(positionBeforeInserts.binlogPosition()); assertThat(persistedOffsetSource.binlogPosition()).isLessThan(positionAfterInserts.binlogPosition()); } else { assertThat(persistedOffsetSource.eventsToSkipUponRestart()).isEqualTo(0);
/** * Wait for a maximum amount of time until the first record is available. * * @param timeout the maximum amount of time to wait; must not be negative * @param unit the time unit for {@code timeout} * @return {@code true} if records are available, or {@code false} if the timeout occurred and no records are available */ protected boolean waitForAvailableRecords(long timeout, TimeUnit unit) { assertThat(timeout).isGreaterThanOrEqualTo(0); long now = System.currentTimeMillis(); long stop = now + unit.toMillis(timeout); while (System.currentTimeMillis() < stop) { if (!consumedLines.isEmpty()) break; } return consumedLines.isEmpty() ? false : true; }
protected void assertTablesExistForDatabase(String dbName) { assertThat(mysql.tableIds().stream().filter(id->id.catalog().equals(dbName)).count()).isGreaterThan(0); }
protected void handleTransactionCommit(long positionOfEvent, int eventSize) { source.setEventPosition(positionOfEvent, eventSize); source.commitTransaction(); eventNumberInTxn = 0; inTxn = false; // Verify the offset ... Map<String, ?> offset = source.offset(); // The offset position should be the position of the next event long position = (Long) offset.get(SourceInfo.BINLOG_POSITION_OFFSET_KEY); assertThat(position).isEqualTo(positionOfEvent + eventSize); Long rowsToSkip = (Long) offset.get(SourceInfo.BINLOG_ROW_IN_EVENT_OFFSET_KEY); if (rowsToSkip == null) rowsToSkip = 0L; assertThat(rowsToSkip).isEqualTo(0); assertThat(offset.get(SourceInfo.EVENTS_TO_SKIP_OFFSET_KEY)).isNull(); if (source.gtidSet() != null) { assertThat(offset.get(SourceInfo.GTID_SET_KEY)).isEqualTo(source.gtidSet()); } }
/** * Utility method to validate that two given {@link SourceRecord} values are identical. * @param actual actual value stored on the source record * @param expected expected value stored on the source record */ public static void assertSameValue(Object actual, Object expected) { if(expected instanceof Double || expected instanceof Float || expected instanceof BigDecimal) { // Value should be within 1% double expectedNumericValue = ((Number)expected).doubleValue(); double actualNumericValue = ((Number)actual).doubleValue(); assertThat(actualNumericValue).isEqualTo(expectedNumericValue, Delta.delta(0.01d*expectedNumericValue)); } else if (expected instanceof Integer || expected instanceof Long || expected instanceof Short) { long expectedNumericValue = ((Number)expected).longValue(); long actualNumericValue = ((Number)actual).longValue(); assertThat(actualNumericValue).isEqualTo(expectedNumericValue); } else if (expected instanceof Boolean) { boolean expectedValue = (Boolean) expected; boolean actualValue = (Boolean) actual; assertThat(actualValue).isEqualTo(expectedValue); } else { assertThat(actual).isEqualTo(expected); } }
assertThat(products.numberOfCreates()).isEqualTo(9); assertThat(products.numberOfUpdates()).isEqualTo(0); assertThat(products.numberOfDeletes()).isEqualTo(0); assertThat(products.numberOfReads()).isEqualTo(0); assertThat(products.numberOfTombstones()).isEqualTo(0); assertThat(products.numberOfKeySchemaChanges()).isEqualTo(1); assertThat(products.numberOfValueSchemaChanges()).isEqualTo(1); assertThat(products_on_hand.numberOfCreates()).isEqualTo(9); assertThat(products_on_hand.numberOfUpdates()).isEqualTo(0); assertThat(products_on_hand.numberOfDeletes()).isEqualTo(0); assertThat(products_on_hand.numberOfReads()).isEqualTo(0); assertThat(products_on_hand.numberOfTombstones()).isEqualTo(0); assertThat(products_on_hand.numberOfKeySchemaChanges()).isEqualTo(1); assertThat(products_on_hand.numberOfValueSchemaChanges()).isEqualTo(1); assertThat(customers.numberOfCreates()).isEqualTo(4); assertThat(customers.numberOfUpdates()).isEqualTo(0); assertThat(customers.numberOfDeletes()).isEqualTo(0); assertThat(customers.numberOfReads()).isEqualTo(0); assertThat(customers.numberOfTombstones()).isEqualTo(0); assertThat(customers.numberOfKeySchemaChanges()).isEqualTo(1); assertThat(customers.numberOfValueSchemaChanges()).isEqualTo(1); assertThat(orders.numberOfCreates()).isEqualTo(5); assertThat(orders.numberOfUpdates()).isEqualTo(0); assertThat(orders.numberOfDeletes()).isEqualTo(0); assertThat(orders.numberOfReads()).isEqualTo(0); assertThat(orders.numberOfTombstones()).isEqualTo(0);
assertThat(products.numberOfCreates()).isEqualTo(9); assertThat(products.numberOfUpdates()).isEqualTo(0); assertThat(products.numberOfDeletes()).isEqualTo(0); assertThat(products.numberOfReads()).isEqualTo(0); assertThat(products.numberOfTombstones()).isEqualTo(0); assertThat(products.numberOfKeySchemaChanges()).isEqualTo(1); assertThat(products.numberOfValueSchemaChanges()).isEqualTo(1); assertThat(products_on_hand.numberOfCreates()).isEqualTo(9); assertThat(products_on_hand.numberOfUpdates()).isEqualTo(0); assertThat(products_on_hand.numberOfDeletes()).isEqualTo(0); assertThat(products_on_hand.numberOfReads()).isEqualTo(0); assertThat(products_on_hand.numberOfTombstones()).isEqualTo(0); assertThat(products_on_hand.numberOfKeySchemaChanges()).isEqualTo(1); assertThat(products_on_hand.numberOfValueSchemaChanges()).isEqualTo(1); assertThat(customers.numberOfCreates()).isEqualTo(4); assertThat(customers.numberOfUpdates()).isEqualTo(0); assertThat(customers.numberOfDeletes()).isEqualTo(0); assertThat(customers.numberOfReads()).isEqualTo(0); assertThat(customers.numberOfTombstones()).isEqualTo(0); assertThat(customers.numberOfKeySchemaChanges()).isEqualTo(1); assertThat(customers.numberOfValueSchemaChanges()).isEqualTo(1); assertThat(orders.numberOfCreates()).isEqualTo(5); assertThat(orders.numberOfUpdates()).isEqualTo(0); assertThat(orders.numberOfDeletes()).isEqualTo(0); assertThat(orders.numberOfReads()).isEqualTo(0); assertThat(orders.numberOfTombstones()).isEqualTo(0);
private void assertBigintUnsignedLong(Struct value) { Struct after = value.getStruct(Envelope.FieldName.AFTER); Integer i = after.getInt32("id"); assertThat(i).isNotNull(); //Validate the schema first, we are expecting int-64 since we have forced Long mode for BIGINT UNSIGNED assertThat(after.schema().field("c1").schema()).isEqualTo(Schema.INT64_SCHEMA); assertThat(after.schema().field("c2").schema()).isEqualTo(Schema.INT64_SCHEMA); //Validate the schema first, we are expecting int-64 since we are dealing with signed-bigint. //So Signed BIGINT would be an INT64 type assertThat(after.schema().field("c3").schema()).isEqualTo(Schema.INT64_SCHEMA); //Validate candidates values, note the loss in precision which is expected since BIGINT UNSIGNED cannot always be represented by //a long datatype. switch (i) { case 1: assertThat(after.getInt64("c1")).isEqualTo(-1L); assertThat(after.getInt64("c2")).isEqualTo(-1L); assertThat(after.getInt64("c3")).isEqualTo(9223372036854775807L); break; case 2: assertThat(after.getInt64("c1")).isEqualTo(-4000000000000000001L); assertThat(after.getInt64("c2")).isEqualTo(-4000000000000000001L); assertThat(after.getInt64("c3")).isEqualTo(-1223372036854775807L); break; case 3: assertThat(after.getInt64("c1")).isEqualTo(0L); assertThat(after.getInt64("c2")).isEqualTo(0L); assertThat(after.getInt64("c3")).isEqualTo(-9223372036854775808L); } }