Refine search
@Test public void maxHandlesSameUnit() { Duration hundredMillis = Duration.ofMillis(100); Duration thousandMillis = Duration.ofMillis(1000); assertThat(Temporals.max(hundredMillis, thousandMillis)).isEqualTo(thousandMillis); }
protected void assertPair( Iterator<Map.Entry<Path, Value>> iterator, String path, Object value ) { Map.Entry<Path,Value> entry = iterator.next(); assertThat((Object)entry.getKey()).isEqualTo(Path.parse(path)); assertThat(entry.getValue()).isEqualTo(Value.create(value)); }
@Test public void shouldReturnLocalDateInstanceWhenConvertingLocalDateTimeToLocalDate() { LocalDateTime now = LocalDateTime.now(); assertThat(Conversions.toLocalDate(now)).isEqualTo(now.toLocalDate()); }
public EventAssert ofType( EventType expected) { assertThat(actual.type()).isEqualTo(expected); return this; }
@Test public void shouldReturnLocalDateTimeInstanceWhenConvertingLocalDateToLocalDateTime() { LocalDate now = LocalDate.now(); assertThat(Conversions.toLocalDateTime(now)).isEqualTo(LocalDateTime.of(now, LocalTime.MIDNIGHT)); }
/** * Verify that the given {@link SourceRecord} has a valid non-null integer key that matches the expected integer value. * * @param record the source record; may not be null * @param pkField the single field defining the primary key of the struct; may not be null * @param pk the expected integer value of the primary key in the struct */ public static void hasValidKey(SourceRecord record, String pkField, int pk) { Struct key = (Struct) record.key(); assertThat(key.get(pkField)).isEqualTo(pk); }
@Test public void shouldHaveTableId() { assertThat(table.id()).isEqualTo(id); }
public SourceRecordAssert valueAfterFieldIsEqualTo(Struct expectedValue) { Struct value = (Struct) record.value(); Struct afterValue = (Struct) value.get("after"); Assertions.assertThat(afterValue).isEqualTo(expectedValue); return this; }
@Test public void shouldReturnLocalDateTimeInstanceWhenConvertingLocalTimeToLocalDateTime() { LocalTime now = LocalTime.now(); assertThat(Conversions.toLocalDateTime(now)).isEqualTo(LocalDateTime.of(Conversions.EPOCH, now)); }
public EventAssert tableIs(TableId expected) { assertThat(tableEvent().tableId()).isEqualTo(expected); return this; }
@Test public void testDate() { Assertions.assertThat(DateTimeFormat.get().date("2016-11-04")).isEqualTo(LocalDate.of(2016, 11, 4)); Assertions.assertThat(DateTimeFormat.get().date("2016-11-04 BC")).isEqualTo(LocalDate.of(-2015, 11, 4)); }
protected void assertRows(WriteRowsEventData eventData, int numRowsInEvent, Serializable... expectedValuesInRows) { assertThat(eventData.getRows().size()).isEqualTo(numRowsInEvent); int valuePosition = 0; for (Serializable[] row : eventData.getRows()) { for (Serializable value : row) { assertThat(value).isEqualTo(expectedValuesInRows[valuePosition++]); } } }
@Test public void shouldReturnLocalDateInstanceWhenConvertingLongToLocalDate() { LocalDate now = LocalDate.now(); long epochDay = now.toEpochDay(); assertThat(Conversions.toLocalDate(epochDay)).isEqualTo(now); }
protected void roundTrip(Document doc, IntConsumer sizeAccumulator) { byte[] bytes = SERDES.serialize("topicA", doc); if (sizeAccumulator != null) sizeAccumulator.accept(bytes.length); Document reconstituted = SERDES.deserialize("topicA", bytes); assertThat((Object) reconstituted).isEqualTo(doc); }
@Test public void shouldReturnLocalTimeInstanceWhenConvertingLocalDateTimeToLocalTime() { LocalDateTime now = LocalDateTime.now(); assertThat(Conversions.toLocalTime(now)).isEqualTo(now.toLocalTime()); }
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()); } }
@Test public void maxHandlesDifferentUnits() { Duration sixtyOneMinutes = Duration.ofMinutes(61); Duration oneHour = Duration.ofHours(1); assertThat(Temporals.max(sixtyOneMinutes, oneHour)).isEqualTo(sixtyOneMinutes); }
private void assertHeartBeatRecordInserted() { assertFalse("records not generated", consumer.isEmpty()); SourceRecord heartbeat = consumer.remove(); assertEquals("__debezium-heartbeat." + TestHelper.TEST_SERVER, heartbeat.topic()); Struct key = (Struct) heartbeat.key(); assertThat(key.get("serverName")).isEqualTo(TestHelper.TEST_SERVER); }
@Test public void shouldSetServerConfigProperty() throws Exception { Properties config = new Properties(); config.put("foo", "bar"); KafkaCluster kafkaCluster = new KafkaCluster().withKafkaConfiguration(config).addBrokers(1); Field kafkaServersField = KafkaCluster.class.getDeclaredField("kafkaServers"); kafkaServersField.setAccessible(true); ConcurrentMap<Integer, KafkaServer> kafkaServers = (ConcurrentMap<Integer, KafkaServer>) kafkaServersField.get(kafkaCluster); Properties serverConfig = kafkaServers.values().iterator().next().config(); assertThat(serverConfig.get("foo")).isEqualTo("bar"); }
private void assertSchema(Struct valueA, Schema expected) { Assertions.assertThat(valueA.schema().field("after").schema().field("cola").schema()).isEqualTo(expected); Assertions.assertThat(valueA.schema().field("after").schema().field("colb").schema()).isEqualTo(expected); Assertions.assertThat(valueA.schema().field("after").schema().field("colc").schema()).isEqualTo(expected); Assertions.assertThat(valueA.schema().field("after").schema().field("cold").schema()).isEqualTo(expected); } }