You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`TopologyTestDriver` supports punctuations, too. Event-time punctuations are triggered automatically based on the processed records' timestamps. Wall-clock-time punctuations can also be triggered by advancing the test driver's wall-clock-time (the driver mocks wall-clock-time internally to give users control over it).
78
78
@@ -98,134 +98,134 @@ The following example demonstrates how to use the test driver and helper classes
// you can reset forwards to clear the captured data. This may be helpful in constructing longer scenarios.
267
267
context.resetForwards();
268
268
269
-
assertEquals(context.forwarded().size(), 0);
269
+
assertEquals(0, context.forwarded().size());
270
270
271
271
If your processor forwards to specific child processors, you can query the context for captured data by child name:
272
272
@@ -296,28 +296,29 @@ Once these are set, the context will continue returning the same values, until y
296
296
297
297
In case your punctuator is stateful, the mock context allows you to register state stores. You're encouraged to use a simple in-memory store of the appropriate type (KeyValue, Windowed, or Session), since the mock context does _not_ manage changelogs, state directories, etc.
298
298
299
-
300
-
final KeyValueStore<String, Integer> store =
301
-
Stores.keyValueStoreBuilder(
302
-
Stores.inMemoryKeyValueStore("myStore"),
303
-
Serdes.String(),
304
-
Serdes.Integer()
305
-
)
299
+
final KeyValueStore<String, Integer> store = Stores
300
+
.keyValueStoreBuilder(
301
+
Stores.inMemoryKeyValueStore("myStore"),
302
+
Serdes.String(),
303
+
Serdes.Integer())
306
304
.withLoggingDisabled() // Changelog is not supported by MockProcessorContext.
307
305
.build();
308
-
store.init(context, store);
309
-
context.register(store, /*deprecated parameter*/ false, /*parameter unused in mock*/ null);
Processors can schedule punctuators to handle periodic tasks. The mock context does _not_ automatically execute punctuators, but it does capture them to allow you to unit test them as well:
314
314
315
315
316
316
final MockProcessorContext.CapturedPunctuator capturedPunctuator = context.scheduledPunctuators().get(0);
317
-
final long interval = capturedPunctuator.getIntervalMs();
317
+
final Duration interval = capturedPunctuator.getInterval();
318
318
final PunctuationType type = capturedPunctuator.getType();
319
319
final boolean cancelled = capturedPunctuator.cancelled();
320
320
final Punctuator punctuator = capturedPunctuator.getPunctuator();
321
+
321
322
punctuator.punctuate(/*timestamp*/ 0L);
322
323
323
324
If you need to write tests involving automatic firing of scheduled punctuators, we recommend creating a simple topology with your processor and using the [`TopologyTestDriver`](testing.html#testing-topologytestdriver).
0 commit comments