Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix bug in simple date format in http sink json payload #32

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ lombok {
}

group 'com.gotocompany'
version '0.9.6'
version '0.9.7'

def projName = "firehose"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ private JSONObject convertProtoBuffTimeStampToDateTime(JSONObject jsonObject, St

Date date;
try {
date = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss").parse(timestampObject);
date = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").parse(timestampObject);
} catch (java.text.ParseException e) {
throw new RuntimeException(String.format("Not able to parse date, %s", timestampObject));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,24 @@ public void shouldProperlySerializeEsbMessage() throws DeserializerException {
+ "\\\"s2Id\\\":\\\"3344472187078705152\\\"}\"}");
}

@Test
public void shouldProperlyHandleMiddayCycle() throws DeserializerException {
MessageToJson messageToJson = new MessageToJson(protoParser, false, true);

String logMessageWithMidday = "CgYI9/7PoQYSBgiz/8+hBhgNIICAgIDA9/y0LigCMAM\u003d";
String logKeyWithMidday = "CgYI9/7PoQYSBgiz/8+hBhgNIICAgIDA9/y0LigC";
Message message = new Message(Base64.getDecoder().decode(logKeyWithMidday.getBytes()),
Base64.getDecoder().decode(logMessageWithMidday.getBytes()), "sample-topic", 0, 100);
String actualOutput = messageToJson.serialize(message);
assertEquals(actualOutput, "{\"logMessage\":\"{\\\"uniqueDrivers\\\":\\\"3\\\","
+ "\\\"windowStartTime\\\":\\\"Apr 10, 2023 12:22:15 PM\\\","
+ "\\\"windowEndTime\\\":\\\"Apr 10, 2023 12:23:15 PM\\\",\\\"s2IdLevel\\\":13,\\\"vehicleType\\\":\\\"BIKE\\\","
+ "\\\"s2Id\\\":\\\"3344472187078705152\\\"}\",\"topic\":\"sample-topic\",\"logKey\":\"{"
+ "\\\"windowStartTime\\\":\\\"Apr 10, 2023 12:22:15 PM\\\","
+ "\\\"windowEndTime\\\":\\\"Apr 10, 2023 12:23:15 PM\\\",\\\"s2IdLevel\\\":13,\\\"vehicleType\\\":\\\"BIKE\\\","
+ "\\\"s2Id\\\":\\\"3344472187078705152\\\"}\"}");
}

@Test
public void shouldSerializeWhenKeyIsMissing() throws DeserializerException {
MessageToJson messageToJson = new MessageToJson(protoParser, false, true);
Expand Down
Loading