javad87 commented on PR #14605:
URL: https://github.com/apache/kafka/pull/14605#issuecomment-2706297226
@s7pandey Will this mock added to test-utils in comming monthes?
I tried to find a workaround until a mock for FixedKeyProcessor is added to
test-utils. However, I need to create a new FixedKeyRecord, which does not have
a public constructor and is package-private. Additionally, it does not extend
the Record class, so I couldn't mock it directly.
Do you have any ideas on how to handle this? By the way, I also have a state
store (stateful punctuator) in processValues. Here's what I tried:
```
public static class MockFixedKeyProcessorContext<KForward, VForward> extends
MockProcessorContext<KForward, VForward> implements
FixedKeyProcessorContext<KForward, VForward> {
public MockFixedKeyProcessorContext(KafkaStreamsApplicationConfig
config) {super(config);}
@Override
public <K extends KForward, V extends VForward> void
forward(FixedKeyRecord<K, V> record) {
super.forward(new Record<>(record.key(), record.value(),
record.timestamp(), record.headers()));}
@Override
public <K extends KForward, V extends VForward> void
forward(FixedKeyRecord<K, V> record, String childName) {
super.forward(new Record<>(record.key(), record.value(),
record.timestamp(), record.headers()), childName);}
}
this.context = new MockFixedKeyProcessorContext<>(properties);
this.myStateStore.init(((MockProcessorContext)
this.context).getStateStoreContext(), myStateStore);
((MockProcessorContext)this.context).addStateStore(myStateStore);
//Package-private constructor. Users must not construct this class directly,
but only modify records they were handed by the framework.
new FixedKeyRecord<>("key", NotificationData.newBuilder().build(), ts, new
RecordHeaders());
((MockProcessorContext) this.context).forwarded();
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]