-
Notifications
You must be signed in to change notification settings - Fork 39
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
Conversation
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") | ||
"" | ||
} | ||
} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Close #1874
And some clean-up.