From 02fd6d47562ea687e2790c18b41416772b68d00b Mon Sep 17 00:00:00 2001 From: sarahcaseybot Date: Wed, 28 Feb 2024 14:21:58 -0500 Subject: [PATCH] Add a check so newly saved createCostTransitions get recognized and saved to the database (#2335) * Add a check so newly saved createCostTransitions get recognized and saved to the database * Fix equals check * Rename equals method * Add comment explaining need for createBillingCostTransitionEqualCheck --- .../java/google/registry/model/tld/Tld.java | 14 ++++++++++- .../tools/ConfigureTldCommandTest.java | 24 +++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/google/registry/model/tld/Tld.java b/core/src/main/java/google/registry/model/tld/Tld.java index c18a28755..e85c6d930 100644 --- a/core/src/main/java/google/registry/model/tld/Tld.java +++ b/core/src/main/java/google/registry/model/tld/Tld.java @@ -138,7 +138,10 @@ public class Tld extends ImmutableObject implements Buildable, UnsafeSerializabl try { String thisYaml = mapper.writeValueAsString(this); String otherYaml = mapper.writeValueAsString(tldToCompare); - return thisYaml.equals(otherYaml); + // Since Jackson uses getters and not field values to construct the YAML representation, an + // explicit check of the createBillingCostTransitions is necessary since this field is + // auto-populated in the getter when the field is set to null. + return thisYaml.equals(otherYaml) && createBillingCostTransitionsEqual(tldToCompare); } catch (JsonProcessingException e) { throw new RuntimeException(e); } @@ -692,6 +695,15 @@ public class Tld extends ImmutableObject implements Buildable, UnsafeSerializabl .toValueMap(); } + public boolean createBillingCostTransitionsEqual(Tld newTld) { + if (createBillingCostTransitions == null) { + return false; + } + return createBillingCostTransitions + .toValueMap() + .equals(newTld.getCreateBillingCostTransitions()); + } + /** * Returns the add-on cost of a domain restore (the flat tld-wide fee charged in addition to one * year of renewal for that name). diff --git a/core/src/test/java/google/registry/tools/ConfigureTldCommandTest.java b/core/src/test/java/google/registry/tools/ConfigureTldCommandTest.java index ab5a2644e..58ab13c27 100644 --- a/core/src/test/java/google/registry/tools/ConfigureTldCommandTest.java +++ b/core/src/test/java/google/registry/tools/ConfigureTldCommandTest.java @@ -140,6 +140,8 @@ public class ConfigureTldCommandTest extends CommandTestCase