Skip to content

Commit

Permalink
minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
felipecsl committed Jun 11, 2024
1 parent 98d9474 commit 339bc6f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
8 changes: 4 additions & 4 deletions src/main/java/cloud/eppo/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import org.slf4j.LoggerFactory;

public final class Utils {
private static final SimpleDateFormat isoUtcDateFormat = buildUtcIsoDateFormat();
private static final SimpleDateFormat UTC_ISO_DATE_FORMAT = buildUtcIsoDateFormat();
private static final Logger log = LoggerFactory.getLogger(Utils.class);

public static String getMD5Hex(String input) {
Expand All @@ -40,7 +40,7 @@ public static Date parseUtcISODateElement(JsonNode isoDateStringElement) {
String isoDateString = isoDateStringElement.asText();
Date result = null;
try {
result = isoUtcDateFormat.parse(isoDateString);
result = UTC_ISO_DATE_FORMAT.parse(isoDateString);
} catch (ParseException e) {
// We expect to fail parsing if the date is base 64 encoded
// Thus we'll leave the result null for now and try again with the decoded value
Expand All @@ -50,7 +50,7 @@ public static Date parseUtcISODateElement(JsonNode isoDateStringElement) {
// Date may be encoded
String decodedIsoDateString = base64Decode(isoDateString);
try {
result = isoUtcDateFormat.parse(decodedIsoDateString);
result = UTC_ISO_DATE_FORMAT.parse(decodedIsoDateString);
} catch (ParseException e) {
log.warn("Date \"{}\" not in ISO date format", isoDateString);
}
Expand All @@ -60,7 +60,7 @@ public static Date parseUtcISODateElement(JsonNode isoDateStringElement) {
}

public static String getISODate(Date date) {
return isoUtcDateFormat.format(date);
return UTC_ISO_DATE_FORMAT.format(date);
}

public static String base64Decode(String input) {
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/cloud/eppo/ufc/dto/adapters/EppoModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
import cloud.eppo.ufc.dto.EppoValue;
import cloud.eppo.ufc.dto.FlagConfigResponse;
import com.fasterxml.jackson.databind.module.SimpleModule;
import java.util.Date;

public class EppoModule {
public static SimpleModule eppoModule() {
SimpleModule module = new SimpleModule();
module.addDeserializer(FlagConfigResponse.class, new FlagConfigResponseDeserializer());
module.addDeserializer(EppoValue.class, new EppoValueDeserializer());
module.addSerializer(EppoValue.class, new EppoValueSerializer());
module.addSerializer(Date.class, new DateSerializer());
return module;
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
package cloud.eppo.rac.deserializer;

import static com.google.common.truth.Truth.assertThat;

import cloud.eppo.rac.dto.*;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.io.FileUtils;
import org.junit.jupiter.api.Test;

import java.io.File;
import java.util.Arrays;
import java.util.List;

import static com.google.common.truth.Truth.assertThat;
import org.apache.commons.io.FileUtils;
import org.junit.jupiter.api.Test;

public class RacDeserializationTest {
private final ObjectMapper objectMapper =
Expand Down

0 comments on commit 339bc6f

Please sign in to comment.