Ignore:
Timestamp:
Jul 23, 2025, 10:16:55 AM (2 months ago)
Author:
ruud
Message:

Modifications for automatic java to python conversion. Overloaded methods now have different names.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • timeline/src/test/java/geniusweb/progress/ProgressTimeTest.java

    r52 r54  
    1111import java.util.List;
    1212
     13import org.eclipse.jdt.annotation.NonNull;
    1314import org.junit.Test;
     15import org.junit.internal.runners.JUnit4ClassRunner;
     16import org.junit.runner.RunWith;
    1417
    1518import com.fasterxml.jackson.core.JsonParseException;
     
    2023import tudelft.utilities.junit.GeneralTests;
    2124
     25@RunWith(JUnit4ClassRunner.class)
    2226public class ProgressTimeTest extends GeneralTests<Progress> {
    2327        // we set T0 quite high because Python has trouble handling small datetime
    2428        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);
    2630        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,
    2932                        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);
    3137
    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}}";
    3440
    3541        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));
    3744
    3845        @Override
    3946        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;
    4451        }
    4552
     
    5764        @Test
    5865        public void testAdvancingTime() throws InterruptedException {
    59                 for (long n = 0; n <= TESTTIME; n++) {
     66                for (long n = 0; n <= TESTTIME; n += 1) {
    6067                        assertEquals((Double) ((double) n / TESTTIME),
    6168                                        progress1.get(T0 + n));
     
    6572        @Test
    6673        public void testAdvanceWhenDeadlineReached() throws InterruptedException {
    67                 ProgressTime progress = new ProgressTime(TESTTIME, TIMEZERO);
     74                final @NonNull ProgressTime progress = new ProgressTime(TESTTIME,
     75                                TIMEZERO);
    6876                assertEquals((Double) 1d, progress1.get(T0 + TESTTIME));
    6977        }
     
    7179        @Test
    7280        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);
    7583                assertEquals(progressstring, actual);
    7684
     
    8088        public void testDeserialize()
    8189                        throws JsonParseException, JsonMappingException, IOException {
    82                 ProgressTime newprog = jackson.readValue(progressstring,
     90                final @NonNull ProgressTime newprog = jackson.readValue(progressstring,
    8391                                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.
    8693                assertEquals(TESTTIME, newprog.getDuration().intValue());
    8794                assertEquals(T0, newprog.getStart().getTime());
Note: See TracChangeset for help on using the changeset viewer.