Project

General

Profile

Revision d846e295

IDd846e295450ab6a0df7a64552f7789a48ca22a93
Parent 6d7ea74e
Child 16f88eb2

Added by Andreas Müller about 1 year ago

ref #9071 add additional ExtendedTimePeriodFormatter test

View differences:

cdmlib-model/src/test/java/eu/etaxonomy/cdm/format/common/ExtendedTimePeriodFormatterTest.java
25 25

  
26 26
    private ExtendedTimePeriodFormatter formatter;
27 27

  
28
    private String endash = TimePeriod.SEP;
29

  
28 30
    @Before
29 31
    public void setUp() throws Exception {
30 32
        formatter = ExtendedTimePeriodFormatter.NewDefaultInstance();
......
44 46
        Integer endDay2 = 20;
45 47
        Integer endMonth2 = 11;
46 48
        Integer endYear2 = 1800;
49

  
47 50
        ExtendedTimePeriod tp1 = ExtendedTimePeriod.NewExtendedYearInstance(startYear,endYear,startYear2,endYear2);
48 51

  
49
        String endash = TimePeriod.SEP;
50 52
        assertNotNull(tp1);
51 53
        Assert.assertEquals("(1787"+endash+")1788"+endash+"1799("+endash+"1800)", formatter.format(tp1));
52 54
        tp1.setStartDay(startDay);
......
59 61
        tp1.setExtremeEndMonth(endMonth2);
60 62
        Assert.assertEquals("(24 May 1787"+endash+")25 Jun 1788"+endash+"21 Dec 1799("+endash+"20 Nov 1800)", formatter.format(tp1)); //date formatting may change in future
61 63

  
64
        tp1 = ExtendedTimePeriod.NewExtendedMonthInstance(startMonth, endMonth, startMonth2, endMonth2);
65

  
66
        assertNotNull(tp1);
67
        Assert.assertEquals("(May"+endash+")Jun"+endash+"Dec("+endash+"Nov)", formatter.format(tp1));
68
        tp1.setStartDay(startDay);
69
        tp1.setStartMonth(startMonth);
70
        tp1.setEndDay(endDay);
71
        tp1.setEndMonth(endMonth);
72
        tp1.setExtremeStartDay(startDay2);
73
        tp1.setExtremeStartMonth(startMonth2);
74
        tp1.setExtremeEndDay(endDay2);
75
        tp1.setExtremeEndMonth(endMonth2);
76
        Assert.assertEquals("(24 May"+endash+")25 Jun"+endash+"21 Dec("+endash+"20 Nov)", formatter.format(tp1)); //date formatting may change in future
77

  
78

  
62 79
        tp1.setFreeText("My extended period");
63 80
        Assert.assertEquals("My extended period", formatter.format(tp1));
64 81

  

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)