Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Proto ByteString in EventingTestKit.IncomingMessages.publish #97

Merged
merged 1 commit into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,39 @@ interface IncomingMessages {
/**
* Simulate the publishing of a raw message.
*
* @param message raw bytestring to be published
* @param message raw protobuf bytestring to be published
*
* @deprecated Use publish with byte array parameter
*/
@Deprecated
void publish(ByteString message);

/**
* Simulate the publishing of a raw message.
*
* @param message raw bytestring to be published
* @param message raw protobuf bytestring to be published
* @param metadata associated with the message
*
* @deprecated Use publish with byte array parameter
*/
@Deprecated
void publish(ByteString message, Metadata metadata);

/**
* Simulate the publishing of a raw message.
*
* @param message raw byte array to be published
*/
void publish(byte[] message);

/**
* Simulate the publishing of a raw message.
*
* @param message raw byte array to be published
* @param metadata associated with the message
*/
void publish(byte[] message, Metadata metadata);

/**
* Simulate the publishing of a message.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,14 @@ private[testkit] class IncomingMessagesImpl(val sourcesHolder: ActorRef, val ser
Await.result(addSource, 5.seconds)
}

override def publish(message: Array[Byte]): Unit =
publish(message, SdkMetadata.EMPTY)

override def publish(message: Array[Byte], metadata: SdkMetadata): Unit = {
val addSource = sourcesHolder.ask(SourcesHolder.Publish(ByteString.copyFrom(message), metadata))(5.seconds)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

internals of the testkit is still using proto, not changing that

Await.result(addSource, 5.seconds)
}

override def publish(message: TestKitMessage[_]): Unit = message.getPayload match {
case javaPb: GeneratedMessageV3 => publish(javaPb.toByteString, message.getMetadata)
case scalaPb: GeneratedMessage => publish(scalaPb.toByteString, message.getMetadata)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import scala.collection.mutable.ArrayBuffer

object SourcesHolder {

case class AddSource(runningSourceProbe: RunningSourceProbe)
case class Publish(message: ByteString, metadata: SdkMetadata)
final case class AddSource(runningSourceProbe: RunningSourceProbe)
final case class Publish(message: ByteString, metadata: SdkMetadata)
}

class SourcesHolder extends Actor {
Expand Down
Loading