- Timestamp:
- Jul 23, 2025, 10:16:55 AM (2 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
timeline/src/test/java/geniusweb/progress/ProgressTimeTest.java
r52 r54 11 11 import java.util.List; 12 12 13 import org.eclipse.jdt.annotation.NonNull; 13 14 import org.junit.Test; 15 import org.junit.internal.runners.JUnit4ClassRunner; 16 import org.junit.runner.RunWith; 14 17 15 18 import com.fasterxml.jackson.core.JsonParseException; … … 20 23 import tudelft.utilities.junit.GeneralTests; 21 24 25 @RunWith(JUnit4ClassRunner.class) 22 26 public class ProgressTimeTest extends GeneralTests<Progress> { 23 27 // we set T0 quite high because Python has trouble handling small datetime 24 28 private static final long T0 = 100000l; 25 private static final Date TIMEZERO = new Date(T0);29 private static final @NonNull Date TIMEZERO = new Date(T0); 26 30 private final static long TESTTIME = 10; // milliseconds! 27 private final ProgressTime progress1 = new ProgressTime(TESTTIME, TIMEZERO); 28 private final ProgressTime progress1a = new ProgressTime(TESTTIME, 31 private final @NonNull ProgressTime progress1 = new ProgressTime(TESTTIME, 29 32 TIMEZERO); 30 private final ProgressTime progress2 = new ProgressTime(200l, TIMEZERO); 33 private final @NonNull ProgressTime progress1a = new ProgressTime(TESTTIME, 34 TIMEZERO); 35 private final @NonNull ProgressTime progress2 = new ProgressTime(200l, 36 TIMEZERO); 31 37 32 private final ObjectMapper jackson = new ObjectMapper();33 private final String progressstring = "{\"ProgressTime\":{\"duration\":10,\"start\":100000}}";38 private final static ObjectMapper jackson = new ObjectMapper(); 39 private final @NonNull String progressstring = "{\"ProgressTime\":{\"duration\":10,\"start\":100000}}"; 34 40 35 41 private final long start = 1234; 36 private final ProgressTime pr = new ProgressTime(TESTTIME, new Date(start)); 42 private final @NonNull ProgressTime pr = new ProgressTime(TESTTIME, 43 new Date(start)); 37 44 38 45 @Override 39 46 public List<List<Progress>> getGeneralTestData() { 40 List<List<Progress>> list = new LinkedList<>();41 list.add(Arrays.asList(progress1, progress1a));42 list.add(Arrays.asList(progress2));43 return list;47 List<List<Progress>> alist = new LinkedList<>(); 48 alist.add(Arrays.asList(progress1, progress1a)); 49 alist.add(Arrays.asList(progress2)); 50 return alist; 44 51 } 45 52 … … 57 64 @Test 58 65 public void testAdvancingTime() throws InterruptedException { 59 for (long n = 0; n <= TESTTIME; n ++) {66 for (long n = 0; n <= TESTTIME; n += 1) { 60 67 assertEquals((Double) ((double) n / TESTTIME), 61 68 progress1.get(T0 + n)); … … 65 72 @Test 66 73 public void testAdvanceWhenDeadlineReached() throws InterruptedException { 67 ProgressTime progress = new ProgressTime(TESTTIME, TIMEZERO); 74 final @NonNull ProgressTime progress = new ProgressTime(TESTTIME, 75 TIMEZERO); 68 76 assertEquals((Double) 1d, progress1.get(T0 + TESTTIME)); 69 77 } … … 71 79 @Test 72 80 public void testSerialize() throws JsonProcessingException { 73 String actual = jackson.writeValueAsString(progress1);74 System.out.println(actual);81 final @NonNull String actual = jackson.writeValueAsString(progress1); 82 //System.out.println(actual); 75 83 assertEquals(progressstring, actual); 76 84 … … 80 88 public void testDeserialize() 81 89 throws JsonParseException, JsonMappingException, IOException { 82 ProgressTime newprog = jackson.readValue(progressstring,90 final @NonNull ProgressTime newprog = jackson.readValue(progressstring, 83 91 ProgressTime.class); 84 // we can't directly compare with progress since that's a hacked 85 // object... 92 // we can't directly compare with progress : that's a hacked object. 86 93 assertEquals(TESTTIME, newprog.getDuration().intValue()); 87 94 assertEquals(T0, newprog.getStart().getTime());
Note:
See TracChangeset
for help on using the changeset viewer.