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: improve error msg in EventingTestKit #1949

Merged
merged 1 commit into from
Jan 8, 2024

Conversation

efgpinto
Copy link
Member

@efgpinto efgpinto commented Jan 8, 2024

Close #1874

And some clean-up.

Comment on lines -104 to -125
private def expectOneTyped_internal[T <: GeneratedMessage](msg: JEventingTestKit.Message[ByteString])(implicit
t: ClassTag[T]): Message[T] = {
val msg = delegate.expectOneTyped(t.runtimeClass.asInstanceOf[Class[T]], timeout.toJava)
val md = MetadataConverters.toScala(msg.getMetadata)
val decodedMsg = codec.decodeMessage(ScalaPbAny(typeUrlFor(md), msg.getPayload))

val concreteType = MessageImpl.expectType(decodedMsg)
Message(concreteType, md)
}

private def typeUrlFor(metadata: Metadata): String = {
metadata
.get("ce-type")
.getOrElse {
val contentType = metadata.get("Content-Type")
contentType match {
case Some("text/plain; charset=utf-8") => "type.kalix.io/string"
case Some("application/octet-stream") => "type.kalix.io/bytes"
case unknown =>
log.warn(s"Could not extract typeUrl from $unknown")
""
}
}
Copy link
Member Author

@efgpinto efgpinto Jan 8, 2024

Choose a reason for hiding this comment

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

I'm not sure why we had this logic duplicated in the scala sdk.. it was myself who added it actually, but I think it's just an oversight. Delegating it upstream to the java implementation should work just as fine.

Copy link
Contributor

@aludwiko aludwiko left a comment

Choose a reason for hiding this comment

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

LGTM

@efgpinto efgpinto merged commit 3217c17 into main Jan 8, 2024
68 checks passed
@efgpinto efgpinto deleted the friendlier-eventing-testkit branch January 8, 2024 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve feedback for missing msg on Eventing testkit
2 participants