Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Sep 17 22:52
    edma2 added as member
  • Sep 17 22:52
    edma2 removed as member
  • Sep 17 22:51
    edma2 added as member
  • Sep 17 22:51
    edma2 removed as member
  • Jun 13 2020 03:21

    finaglehelper on develop

    finatra: Support for injecting … (compare)

  • Jun 12 2020 22:21

    finaglehelper on develop

    finatra-thrift: Reduce complexi… (compare)

  • Jun 12 2020 02:44

    finaglehelper on develop

    finatra-thrift: Use correct dat… (compare)

  • Jun 11 2020 07:32

    finaglehelper on develop

    finatra-thrift: CommonThriftLog… (compare)

  • Jun 10 2020 19:31

    finaglehelper on develop

    finagle, finatra, ts: Keep `inc… (compare)

  • Jun 10 2020 19:05
    ihasfrozen commented #522
  • Jun 09 2020 00:46

    finaglehelper on develop

    finatra: Add comments for optim… (compare)

  • Jun 08 2020 18:23

    finaglehelper on develop

    finatra-doc: Add missing import… (compare)

  • Jun 05 2020 03:18

    finaglehelper on develop

    inject-core: Remove finagle-cor… (compare)

  • Jun 04 2020 22:33

    finaglehelper on develop

    finatra: Use permanent links fo… (compare)

  • May 29 2020 21:31
    cacoco closed #511
  • May 29 2020 21:31
    cacoco commented #511
  • May 29 2020 21:31
    cacoco closed #524
  • May 29 2020 21:31
    cacoco commented #524
  • May 28 2020 22:31

    finaglehelper on develop

    util|scrooge|finagle|twitter-se… (compare)

  • May 28 2020 00:41

    finaglehelper on develop

    finatra: Update testing docs P… (compare)

Js
@jsfaure
Ok, thank you @cacoco , so, there is a hope that this PR will be accepted in the end. In the meantime, I had to find a workaround to provide the strict behavior by overriding the DefaultMessageBodyReader but this is clearly sub optimal. For the context, this is very useful to be strict, our API consumers often waste time figuring out that they misspell a field for example.
Christopher Coco
@cacoco
@jsfaure yeah, I get the reasoning and agree. Ideally we can patch this to be correct.
Deenar Toraskar
@deenar
Hi Guys, I was trying to figure out how to customise serialisation of case classes. I have a java.time.LocalDate field and seem to unable to customise it. Tried @JsonFormat and dont really want to go back to joda
The latter you’d use with @JsonSerialize(using = LocalDateSerializer.class)
(or manually register it to the mapper, depends on your intended usage)
Deenar Toraskar
@deenar
so for option1 I will have to extend ``class CustomModule extends ScalaObjectMapperModule and then use it in my server override def jacksonModule = new CustomModule
Option 2 would just be an annotation on my case class
thanks will try this out (i knew about option 1, but thought java.util.Date s would be supported out of the box.)
Christopher Coco
@cacoco
LocalDate is newer
java.util.Date is supported
Christopher Coco
@cacoco
FWIW, when we remove the Joda support, we’ll likely add Jackson’s support for Java 8 date/time constructs to the base configuration of the Finatra mapper.
Deenar Toraskar
@deenar
Thanks, just using @JsonSerialize(using = LocalDateSerializer.class), does not work, i think I still need to register the new serializers in ScalaObjectMapperModule objectMapper.registerModule(new JavaTimeModule())
Christopher Coco
@cacoco
@JsonSerialize should work, curious what you’re running into. We don’t have any special thing in the way for serialization (we have a custom deserializer) other than we add some default serializers for you.
Deenar Toraskar
@deenar
@cacoco many thanks, it did work, i was annotating the wrong class
Deenar Toraskar
@deenar
another question, I cannot get JsonIgnore to work or JsonIgnoreProperties, do you expect this to work out of the box
or will i need a custom serializer
Deenar Toraskar
@deenar
It turns out you need to annotate the member as a property first, in the jackson version finatra is using @JsonIgnoreProperties(Array("b"))
case class Message(a: String, @JsonProperty("b") b: String)
Later Jackson versions apparently dont need this
Thank you for your help @cacoco
Christopher Coco
@cacoco
Ok glad you got it figured out, @deenar
Deenar Toraskar
@deenar
@cacoco Hi Chris, I was wondering how does one go about serialing Option[LocalDateTime] or Option[LocalDate]?
Christopher Coco
@cacoco
@deenar we include the DefaultScalaModule which should allow for serializing Options which should then proxy to the right serializer for LocalDate LocalDateTime if you have one
The Scala Module supports serialization and limited deserialization of Scala Case Classes, Sequences, Maps, Tuples, Options, and Enumerations.
Deenar Toraskar
@deenar
@cacoco thanks I have a couple of other question 1) i would like to return HTML via moustache if Accept header contained text/html or JSON otherwise, what is the idiomatic way of doing this
is there an Oauth2 filter implementation available somewhere?
Christopher Coco
@cacoco
@deenar we don’t have an OAuth2 Filter anywhere though I believe there is a finagle-oauth2 project here: https://github.com/finagle/finagle-oauth2 which should work. For your first question, if you want to content-negotiation like this you have several choices. Most simply is to switch on the accept header — we have a utility that may help here: https://github.com/twitter/finatra/blob/develop/http/src/main/scala/com/twitter/finatra/http/request/RequestUtils.scala#L31
Deenar Toraskar
@deenar
Thank you
Deenar Toraskar
@deenar
Hi All, I wanted to write some test on Finatra Request parsing and Response writing for some of the application classes we have, but am stuck. I saw com.twitter.finatra.http.tests.marshalling.MessageBodyManagerTest, but it only seems to test overwritten read and write behaviour not the default one.
Christopher Coco
@cacoco
@deenar not sure what you mean.
Do you have example of what you’re trying to do or what you’re running into?
Deenar Toraskar
@deenar
''' test("Test PaymentRuleTest writer ") {
val testCase = ParseRules.getSampleTestCase()
val writerResponse = defaultMessageBodyWriter.write(testCase.inputMessage)
writerResponse.contentType should equal(MediaType.JsonUtf8)
mapper.parsePaymentRuleTest should equal(testCase)
}'''
something along the lines of given a case class wanted to assert it's JSON encoding on the way out is as expected and a given JSON request is mapped correctly on the way in
Christopher Coco
@cacoco
@deenar its not intended that you need to interact with the message body manager at all to test this
you would issue a request to the server and expect the returned JSON is as expected
Deenar Toraskar
@deenar
so I should just use FeatureTests
for what you’re describing: "something along the lines of given a case class wanted to assert it's JSON encoding on the way out is as expected and a given JSON request is mapped correctly on the way in”, yes a FeatureTest
I mean you are free to test the message body writer directly…if you really want to but you’re just testing our machinery and not your logic (and you should assume we test our machinery)
Deenar Toraskar
@deenar
I do have FeatureTests, but was wondering if there was a way just to check the serialisation and deserialisation of individual case classe
Christopher Coco
@cacoco
meaning what exactly
test what mechanism
testing serialization an deserialization of a case class is effectively writing tests of the framework which is again, great, but ultimately useless for testing anything related to your logic.
ok