use of net.fortuna.ical4j.validate.ValidationException in project fineract by apache.
the class CalendarUtils method getICalRecur.
public static Recur getICalRecur(final String recurringRule) {
// Construct RRule
try {
final RRule rrule = new RRule(recurringRule);
rrule.validate();
final Recur recur = rrule.getRecur();
return recur;
} catch (final ParseException e) {
// TODO Auto-generated catch block
LOG.error("Problem occurred in getICalRecur function", e);
} catch (final ValidationException e) {
// TODO Auto-generated catch block
LOG.error("Problem occurred in getICalRecur function", e);
}
return null;
}
use of net.fortuna.ical4j.validate.ValidationException in project ical4j by ical4j.
the class AbstractPropertyTest method assertValidationError.
/**
* @param property
*/
protected void assertValidationError(final Property property) {
try {
ValidationResult result = property.validate();
assertTrue(result.hasErrors());
} catch (ValidationException ve) {
LOG.debug("Exception caught", ve);
return;
}
}
use of net.fortuna.ical4j.validate.ValidationException in project ical4j by ical4j.
the class ComponentTest method suite.
/**
* @return
*/
@SuppressWarnings("serial")
public static TestSuite suite() throws ValidationException, ParseException, IOException, URISyntaxException, ParserException {
TestSuite suite = new TestSuite();
Component component = new Component("test") {
@Override
public ValidationResult validate(boolean recurse) throws ValidationException {
return null;
}
};
suite.addTest(new ComponentTest("testCalculateRecurrenceSet", component, new Period(new DateTime(), java.time.Duration.ofDays(1)), new PeriodList()));
component = new Component("test") {
@Override
public ValidationResult validate(boolean recurse) throws ValidationException {
return null;
}
};
// 10am-12pm for 7 days..
component.getProperties().add(new DtStart("20080601T100000Z"));
component.getProperties().add(new DtEnd("20080601T120000Z"));
Recur recur = new Recur.Builder().frequency(Recur.Frequency.DAILY).count(7).build();
component.getProperties().add(new RRule(recur));
PeriodList expectedPeriods = new PeriodList();
expectedPeriods.add(new Period("20080601T100000Z/PT2H"));
expectedPeriods.add(new Period("20080602T100000Z/PT2H"));
expectedPeriods.add(new Period("20080603T100000Z/PT2H"));
expectedPeriods.add(new Period("20080604T100000Z/PT2H"));
expectedPeriods.add(new Period("20080605T100000Z/PT2H"));
expectedPeriods.add(new Period("20080606T100000Z/PT2H"));
expectedPeriods.add(new Period("20080607T100000Z/PT2H"));
suite.addTest(new ComponentTest("testCalculateRecurrenceSet", component, new Period(new DateTime("20080601T000000Z"), java.time.Duration.ofDays(7)), expectedPeriods));
component = new Component("test") {
@Override
public ValidationResult validate(boolean recurse) throws ValidationException {
return null;
}
};
// weekly for 5 instances using DATE format and due date.
component.getProperties().add(new DtStart(new Date("20080601")));
component.getProperties().add(new Due(new Date("20080602")));
recur = new Recur.Builder().frequency(Recur.Frequency.WEEKLY).count(5).build();
component.getProperties().add(new RRule(recur));
expectedPeriods = new PeriodList();
expectedPeriods.add(new Period("20080601T000000Z/P1D"));
expectedPeriods.add(new Period("20080608T000000Z/P1D"));
expectedPeriods.add(new Period("20080615T000000Z/P1D"));
expectedPeriods.add(new Period("20080622T000000Z/P1D"));
expectedPeriods.add(new Period("20080629T000000Z/P1D"));
suite.addTest(new ComponentTest("testCalculateRecurrenceSet", component, new Period(new DateTime("20080601T000000Z"), java.time.Period.ofWeeks(6)), expectedPeriods));
return suite;
}
use of net.fortuna.ical4j.validate.ValidationException in project ical4j by ical4j.
the class CalendarBuilderTest method testBuildInvalid.
/**
* @throws IOException
* @throws ParserException
*/
public void testBuildInvalid() throws IOException {
try {
Calendar calendar = new CalendarBuilder().build(fin);
ValidationResult result = calendar.validate();
assertTrue(result.hasErrors());
// fail("Should throw ParserException or ValidationException");
} catch (ValidationException | ParserException e) {
log.trace("Caught exception: [" + filename + "," + e.getMessage() + "]");
}
}
use of net.fortuna.ical4j.validate.ValidationException in project ical4j by ical4j.
the class VTimeZoneValidator method validate.
@Override
public ValidationResult validate(VTimeZone target) throws ValidationException {
ValidationResult result = ComponentValidator.VTIMEZONE.validate(target);
/*
* ; one of 'standardc' or 'daylightc' MUST occur ..; and each MAY occur more than once. standardc / daylightc /
*/
if (target.getObservances().getComponent(Observance.STANDARD) == null && target.getObservances().getComponent(Observance.DAYLIGHT) == null) {
throw new ValidationException("Sub-components [" + Observance.STANDARD + "," + Observance.DAYLIGHT + "] must be specified at least once");
}
target.getObservances().forEach(ComponentValidator.OBSERVANCE_ITIP::validate);
return result;
}
Aggregations