Skip to content

Commit

Permalink
Fix unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
courtneyeh committed Apr 12, 2024
1 parent e82a751 commit ae09a43
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
import java.nio.file.Files;
import java.nio.file.NoSuchFileException;
import java.nio.file.Path;
import java.sql.Date;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Optional;
import org.apache.tuweni.bytes.Bytes;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -162,14 +165,20 @@ void formatTimestamp_shouldFormatDate() {
final DebugDataDumper manager = new DebugDataDumper(Path.of("."), true);
final String formattedTimestamp =
manager.formatOptionalTimestamp(Optional.of(timeProvider.getTimeInMillis()));
assertThat(formattedTimestamp).isEqualTo("1970-01-01T12_46_40.00");

final DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH_mm_ss.SS");
final Date date = new Date(timeProvider.getTimeInMillis().longValue());
assertThat(formattedTimestamp).isEqualTo(df.format(date));
}

@Test
void generateTimestamp_shouldGenerateTimestamp() {
final DebugDataDumper manager = new DebugDataDumper(Path.of("."), true);
final String formattedTimestamp = manager.generateTimestamp(timeProvider);
assertThat(formattedTimestamp).isEqualTo("1970-01-01T12_46_40.00");

final DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH_mm_ss.SS");
final Date date = new Date(timeProvider.getTimeInMillis().longValue());
assertThat(formattedTimestamp).isEqualTo(df.format(date));
}

private void checkBytesSavedToFile(final Path path, final Bytes expectedBytes) {
Expand Down

0 comments on commit ae09a43

Please sign in to comment.