Blame view

src/test/resources/README 3.2 KB
bernard authored
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
Files named displayedDaysFor*CalculationTestData hold data for testing if UISchedule caluclates dates that javascript
widget will need for initial date range.
Here is the format:
a,b,c,d,e,f,g,h,i,i,j,k
where
a - day of week from which week starts (1-sunday,2-monday,etc.)
b - show weekends (1-true,0-false)
c - initial date year
d - initial date month
e - initial date day
f - expected start year
g - expected start month
h - expected start day
i - expected end year
j - expected end month
k - expected end day

If anything in algorithm changes and test data will become invalid, they can be easily recreated by putting following
bernard authored
19
code into UISchedule.getScheduleData method
bernard authored
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43

        Calendar calendar = Calendar.getInstance();
        calendar.setTime(startDate);
//        calendar.add(Calendar.DATE, 3); //for generating data for week view
//        calendar.add(Calendar.DATE, 9); //for generating data for month view
                                          //for generating data for day view no incrementing is required
        setDate(calendar.getTime());
        final Date firstDisplayedDay = getFirstDisplayedDay(this);
        Calendar firstDayCalendar = Calendar.getInstance();
        firstDayCalendar.setTime(firstDisplayedDay);
        Calendar startDateCalendar = Calendar.getInstance();
        startDateCalendar.setTime(startDate);
        Calendar endDateCalendar = Calendar.getInstance();
        endDateCalendar.setTime(endDate);
        Calendar lastDayCalendar = Calendar.getInstance();
        lastDayCalendar.setTime(getLastDisplayedDate(this));
        System.out.println("" + getFirstDay() + "," + (isShowWeekends(this) ? 1 : 0) +
                "," + calendar.get(Calendar.YEAR) + "," + calendar.get(Calendar.MONTH) + "," + calendar.get(Calendar.DATE)
                + "," + startDateCalendar.get(Calendar.YEAR) + "," + startDateCalendar.get(Calendar.MONTH) + "," + startDateCalendar.get(Calendar.DATE)
                + "," + endDateCalendar.get(Calendar.YEAR) + "," + endDateCalendar.get(Calendar.MONTH) + "," + endDateCalendar.get(Calendar.DATE)
//                + "," + firstDayCalendar.get(Calendar.YEAR) + "," + firstDayCalendar.get(Calendar.MONTH) + "," + firstDayCalendar.get(Calendar.DATE)
//                + "," + lastDayCalendar.get(Calendar.YEAR) + "," + lastDayCalendar.get(Calendar.MONTH) + "," + lastDayCalendar.get(Calendar.DATE)
        );
bernard authored
44 45 46 47 48 49 50 51 52 53 54 55 56 57
If you do not want to click several thousand times to navigate through dates in schedule widget just add this to your page (index.xhtml in demo fits great):
		<input type="button" value="Lunch auto navigation" onclick="lunchAutoNavigation()"/>
        <script>
            function lunchAutoNavigation() {
                var fc = jQuery('#sf\\:schedule:first');
                fc.fullCalendar('next');
                if(fc.fullCalendar('getDate').getFullYear() &lt; 2020)
                    setTimeout("lunchAutoNavigation()",250);
            }
        </script>
Test data should cover combinations of firstDay (1-7), showWeekends(true/false) and :
	- 20 years for month view
	- 5 years for week view
For day view it is unnecesary to include combinations of firstDay, and date range should cover 2 years only.
bernard authored
58
Just remember to avoid blank lines, especially at the end of file.