Skip to content

Commit

Permalink
Use ZonedDateTime for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
rogargon committed May 9, 2024
1 parent feb00e7 commit 4a3559a
Showing 1 changed file with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@
import org.json.JSONObject;
import org.junit.Assert;
import org.springframework.beans.factory.annotation.Autowired;

import java.time.LocalDate;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;

import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.patch;
Expand Down Expand Up @@ -89,10 +86,9 @@ public void thenAdminShouldVerifyTheCertificateValidityAssociatedWithAShelterWit
JSONObject jsonObject = new JSONObject(stepDefs.result.andReturn().getResponse().getContentAsString());

String shelterCertificateUri = jsonObject.getString("uri");
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSSSSXXX");
LocalDate shelterCertificateExpirationDate = LocalDate.parse(jsonObject.getString("expirationDate"), formatter);
ZonedDateTime shelterCertificateExpirationDate = ZonedDateTime.parse(jsonObject.getString("expirationDate"));

boolean isShelterCertificateValid = shelterCertificateExpirationDate.isAfter(LocalDate.now());
boolean isShelterCertificateValid = shelterCertificateExpirationDate.isAfter(ZonedDateTime.now());
if (!isShelterCertificateValid) {
System.out.println("The Shelter Certificate IS not valid!" + stepDefs.result);
Assert.fail("The Shelter Certificate IS not valid!");
Expand Down

0 comments on commit 4a3559a

Please sign in to comment.