Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link

Prasanna Raman

Ranch Hand
+ Follow
since Sep 05, 2010
Cows and Likes
Cows
Total received
1
In last 30 days
0
Total given
0
Likes
Total received
6
Received in last 30 days
0
Total given
17
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Prasanna Raman

Ron, thank you so much!

I was able to do this:

new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);

and it's now ignoring UNKNOWN fields.
2 months ago
Here's the stack trace:




Upon some investigation, I think I understand it a little more now. So if I were creating my own model, I could use this -



So, is the question now about how to tell the openAPI config to ignore unknown fields? Is there a way to do this?

This is from the gradle file:

2 months ago
I am not sure I understand exactly how the deserializing task is configured, but I think it's using openAPI (org.openapitools.codegen.languages.SpringCodegen)?

This is the code snippet if that helps:



I am not sure exactly how this all works, but hopefully this is enough information to get some inputs on how to solve the problem.

Please let me know if there's anything else I can provide.
2 months ago
Thank you for your response, Les! Can you elaborate about what's best practice and how this case can be handled?
2 months ago
Hello All,

I just inherited a project where we use openAPI spec, so it currently rejects any extra fields in the payload that's not part of the Swagger spec, so our code throws an exception to the caller when that happens.

We have a problem now because it's an external team that works on Swagger/payload, and they sometimes add fields to the payload without giving us an updated Swagger. It looks like they share this payload with other clients too, so if there's a requirement by another client to have a field added, they add it to the payload, just causing our code to break. If they update the Swagger and the payload at the same time, we won't have a problem, but sometimes Swagger comes later.

The external team that shares the Swagger spec is arguing that it's not best practice to have this strict check, and that we should be able to ignore ANY extra fields in the payload even if it's not in Swagger.

I just want to understand what's best practice here, and if there's a way to blindly ignore ANY extra fields without knowing what might get added in the future.

Thank you very much!
2 months ago
Hello All,

I've set expiration rule through Java code for my S3 objects, but the objects are not expiring from S3.

When I do HEAD-object, I am able to see "Expiration" and the correct rule against the object, but nothing seems to happen even though at least 2 UTC midnights have passed since I set up the rule.

On the other hand, I tried creating a rule manually using the UI in S3. That seems to have removed the object correctly. Both rules had exactly similar prefixes.

When I upload the file, I see that my Java code executes and creates the rule simultaneously, setting up the prefix correctly. I am not sure why removal doesn't happen as expected.

Any help would be greatly appreciated. I can share more details if necessary.

Thank you.
7 months ago
Correct, there is no difference, but I'm just trying to program for any country thay may have different formats! And see how I can make it work.
2 years ago
Ok, and what if the formatting also differs by the type - mobile or landline? USA may be the same, but assuming it's different.
2 years ago

Campbell Ritchie wrote:If you go back to an earlier suggestion that you have a prefix (area code, dialling code, etc.) and number stored as separate fields, can you separate a String into its constituent parts in the constructor?
What about a factory method requiring a non‑null locale as a parameter, returning subclasses of PhoneNumber? Then make all your constructors private.



Can you please elaborate on this? I do have a prefix and a phone number field for my PhoneNumber class, in addition to the PhoneNumberType field. I don't understand the parts about the constructor and the factory method
2 years ago

Campbell Ritchie wrote:There are several ways you can store a formatter object.

  • You can put it into a map as the “V”, but I shall leave it to you to work out what to use as the “K”.
  • You can have subclasses as I suggested here, with formatters being private static fields of each class.
  • If you are using Locales, you might be able to put formatting information into a resource bundle (not sure).
  • You can have it associated with the type enum. But I remain to be convinced that you need a type enum in the first place; do you have an intersection of the range of phone numbers anywhere so there is a landline and a mobile with the same number in the same country? Would you need an additional (?prefix) number to disambiguate them?
  • Ouch! How are you going to describe that in the documentation? Look at that awkward code with two dots in. Why doesn't the toString() method return the phone number correctly formatted? Also a plainToString() method which returns my phone number in the blank formatrather than correctly formatted like this?If you go back to an earlier suggestion that you have a prefix (area code, dialling code, etc.) and number stored as separate fields, can you separate a String into its constituent parts in the constructor?
    What about a factory method requiring a non‑null locale as a parameter, returning subclasses of PhoneNumber? Then make all your constructors private.

    I you are confining yourself to one country only, then a lot of this current post doesn't apply.



    I have the enum not because there is overlap, but because I want the user to be able to select the phone number type when storing, and when viewing. If including the type as part of the phone number is not the ideal way to do this, then please tell me how else this can be done. I probably have bad design here.

    As for storing in map, I do have that map in the PhoneFormatProvider class, and also the inheritance hierarchy for the formatters (based on locale) as suggested by you earlier; but what I don't know is how I can also include the type within the formatter. Should I have USMobileFormatter, USLandlineFormatter etc.?

    Unfortunately, I don't understand what you're trying to say with the toString() methods Can you please elaborate?
    2 years ago
    Now for the getFormatter(Locale locale, PhoneType type) method, how do I implement this if I need to provide formatters based on both locale and type?

    Even in the detault formatter, I will need to do conditional based on landline vs mobile! If a new locale gets added, then I need to get the correct formatter for the locale, and then somehow get the correct formatter for the type for the locale! I am probably confusing myself here, but it keeps getting complicated and I am not sure how to solve this.

    Upon thinking about this further, is this where I could do something like this?



    But even this doesn't solve the problem of how I write the logic to format based on locale and also type Unless I have a formatter for each subtype - as USMobileFormatter, USLandLineFormatter etc..
    2 years ago
    Is this better?

    2 years ago
    I've made some progress, not sure if this is ideal. Please review.







    Is this reasonable? Now, where and how do I implement that Map you were talking about?
    2 years ago
    Thank you, Junilu. I am struggling with how to implement the factory class. How should I proceed from here?



    I know I need to use the 2 parameters passed to getInstance in the factory class somehow, but not sure how I can create the instances.


    2 years ago

    Campbell Ritchie wrote:Yes, you can declare abstract methods in an enum, but you need to override them first(!) There is an example about arithmetic in the Java® Language Specification (=JLS), which I suggest you emulate. You can add things like country code to each of your enum constants, too. I recommend you read the whole JLS chapter about enums.



    Thank you, just looked at the arithmetic eval function in the link you provided. So, actually putting the format() method inside the enum is good design here? That's where I am getting confused!

    I have a PhoneFormat class which returns a PhoneFormat object from a factory method but not sure yet how to implement that method.
    2 years ago