@Test public void testHasWorkingDaysDifferent() { List<Integer> workingDays = Arrays.asList( DateTimeConstants.MONDAY, DateTimeConstants.TUESDAY, DateTimeConstants.WEDNESDAY, DateTimeConstants.THURSDAY, DateTimeConstants.FRIDAY); List<Integer> workingDaysToCompare = Arrays.asList( DateTimeConstants.MONDAY, DateTimeConstants.TUESDAY, DateTimeConstants.WEDNESDAY, DateTimeConstants.THURSDAY, DateTimeConstants.SUNDAY); WorkingTime workingTime = new WorkingTime(); workingTime.setWorkingDays(workingDays, DayLength.FULL); boolean returnValue = workingTime.hasWorkingDays(workingDaysToCompare); Assert.assertFalse("Working days are identical", returnValue); }
@Test public void testDefaultValues() { WorkingTime workingTime = new WorkingTime(); Assert.assertEquals("Wrong day length for monday", DayLength.ZERO, workingTime.getMonday()); Assert.assertEquals("Wrong day length for tuesday", DayLength.ZERO, workingTime.getTuesday()); Assert.assertEquals( "Wrong day length for wednesday", DayLength.ZERO, workingTime.getWednesday()); Assert.assertEquals("Wrong day length for thursday", DayLength.ZERO, workingTime.getThursday()); Assert.assertEquals("Wrong day length for friday", DayLength.ZERO, workingTime.getFriday()); Assert.assertEquals("Wrong day length for saturday", DayLength.ZERO, workingTime.getSaturday()); Assert.assertEquals("Wrong day length for sunday", DayLength.ZERO, workingTime.getSunday()); Assert.assertFalse( "There should be no federal state override", workingTime.getFederalStateOverride().isPresent()); }
public static void main(String[] args) throws Exception { // The path to the documents directory. String dataDir = "src/programmersguide/workingwithcalendars/definingweekdays/data/"; // Create a project instance Project prj = new Project(); // Define Calendar Calendar cal = prj.getCalendars().add("Calendar1"); // Add working days monday through thursday with default timings cal.getWeekDays().add(WeekDay.createDefaultWorkingDay(DayType.Monday)); cal.getWeekDays().add(WeekDay.createDefaultWorkingDay(DayType.Tuesday)); cal.getWeekDays().add(WeekDay.createDefaultWorkingDay(DayType.Wednesday)); cal.getWeekDays().add(WeekDay.createDefaultWorkingDay(DayType.Thursday)); cal.getWeekDays().add(new WeekDay(DayType.Saturday)); cal.getWeekDays().add(new WeekDay(DayType.Sunday)); // Set friday as short working day WeekDay myWeekDay = new WeekDay(DayType.Friday); // Sets working time. Only time part of DateTime is important WorkingTime wt1 = new WorkingTime(); java.util.Calendar calTime = java.util.Calendar.getInstance(); calTime.set(1, 1, 1, 9, 0, 0); Date date = calTime.getTime(); wt1.setFromTime(date); calTime.set(1, 1, 1, 12, 0, 0); date = calTime.getTime(); wt1.setToTime(date); WorkingTime wt2 = new WorkingTime(); calTime.set(1, 1, 1, 13, 0, 0); date = calTime.getTime(); wt2.setFromTime(date); calTime.set(1, 1, 1, 16, 0, 0); date = calTime.getTime(); wt2.setToTime(date); myWeekDay.getWorkingTimes().add(wt1); myWeekDay.getWorkingTimes().add(wt2); myWeekDay.setDayWorking(true); cal.getWeekDays().add(myWeekDay); // Save the Project prj.save("Project.Xml", SaveFileFormat.XML); // Display result of conversion. System.out.println("Process completed Successfully"); }