Skip to content
This repository has been archived by the owner on Feb 7, 2025. It is now read-only.

Commit

Permalink
672: Get the time received out of the database when it is set to null
Browse files Browse the repository at this point in the history
  • Loading branch information
halprin committed Jan 9, 2024
1 parent eb1bf9e commit 5c961fa
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,18 @@ public synchronized PartnerMetadata fetchMetadata(String receivedSubmissionId)
return null;
}

Instant timeReceived = null;
Timestamp timestamp = result.getTimestamp("time_received");
if (timestamp != null) {
timeReceived = timestamp.toInstant();
}

return new PartnerMetadata(
result.getString("received_message_id"),
result.getString("sent_message_id"),
result.getString("sender"),
result.getString("receiver"),
result.getTimestamp("time_received").toInstant(),
timeReceived,
result.getString("hash_of_order"));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,4 +192,22 @@ class PostgresDaoTest extends Specification {
then:
actual == expected
}

def "fetchMetadata successfully sets the received timestamp to null"() {
given:
mockDriver.getConnection(_ as String, _ as Properties) >> mockConn
mockConn.prepareStatement(_ as String) >> mockPreparedStatement
mockPreparedStatement.executeQuery() >> mockResultSet
mockResultSet.next() >> true
mockResultSet.getTimestamp("time_received") >> null

TestApplicationContext.register(SqlDriverManager, mockDriver)
TestApplicationContext.injectRegisteredImplementations()

when:
def actual = PostgresDao.getInstance().fetchMetadata("mock_lookup")

then:
actual.timeReceived() == null
}
}

0 comments on commit 5c961fa

Please sign in to comment.