Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Add PersistableSlidingWindow UT for multiple writes #515

Merged
merged 2 commits into from
Nov 16, 2020
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,20 @@ public void testDifferentTimeUnits() throws Exception {
Assert.assertEquals(1, slidingWindow.size());
}


/**
* Tests that a PSW can call write() multiple times and still have its data read
*/
@Test
public void testMultipleWrites() throws IOException {
PersistableSlidingWindow slidingWindow = new PersistableSlidingWindow(1, TimeUnit.SECONDS, persistFile);
long curTimestamp = Instant.now().toEpochMilli();
slidingWindow.next(new SlidingWindowData(curTimestamp, 10));
slidingWindow.write();
slidingWindow.next(new SlidingWindowData(curTimestamp, 10));
slidingWindow.write();
PersistableSlidingWindow slidingWindow2 = new PersistableSlidingWindow(1, TimeUnit.SECONDS, persistFile);
Assert.assertEquals(20, slidingWindow2.readSum(), 0.0);
}

@AfterClass
public static void tearDown() {
Expand Down