public static <T> Matcher<T> are(Matcher<T> matcher)
{
    Description description = new StringDescription();
    matcher.describeTo(description);
    return describedAs(String.format("are %s", description.toString()), is(matcher));
} public static Function<DateTime, Matcher<RecurrenceRule>> instances(Matcher<DateTime> dtMatchers)
{
    return dateTime -> InstancesMatcher.instances(dateTime, dtMatchers);
} public static Function<DateTime, Matcher<RecurrenceRule>> results(int n)
{
    return dateTime -> ResultsMatcher.results(dateTime, n);
} public static Function<DateTime, Matcher<RecurrenceRule>> startingWith(String... dates)
{
    return startingWith(new Seq<>(dates));
} public static Matcher<RecurrenceRule> validRule(DateTime start, Iterable<Function<DateTime, Matcher<RecurrenceRule>>> matcherFunctions)
{
    return new AllOf<>(new Joined<>(new Seq<>(increasing(start)), new Mapped<>(f -> f.value(start), matcherFunctions)));
} public static Function<DateTime, Matcher<RecurrenceRule>> walking()
{
    return WalkingStartMatcher::walking;
} public static Matcher<DateTime> before(String dateTime)
{
    return before(DateTime.parse(dateTime));
} public static Matcher<DateTime> onDayOfMonth(Matcher<Integer> dayMatcher)
{
    return new DayOfMonthMatcher(dayMatcher);
} public static Matcher<DateTime> inMonth(Matcher<Integer> monthMatcher)
{
    return new MonthMatcher(monthMatcher);
} public static Matcher<DateTime> onWeekDay(Matcher<Weekday> weekdayMatcher)
{
    return new WeekDayMatcher(weekdayMatcher);
} public static Matcher<DateTime> inYear(Matcher<Integer> yearMatcher)
{
    return new YearMatcher(yearMatcher);
}
import org.dmfs.rfc5545.DateTime;
import org.dmfs.rfc5545.Weekday;
import org.junit.Test;
import static org.dmfs.jems.hamcrest.matchers.SingleMatcher.hasValue;
import static org.dmfs.rfc5545.Weekday.MO;
import static org.dmfs.rfc5545.Weekday.TH;
import static org.dmfs.rfc5545.Weekday.TU;
import static org.dmfs.rfc5545.Weekday.WE;
import static org.dmfs.rfc5545.hamcrest.RecurrenceRuleMatcher.are;
import static org.dmfs.rfc5545.hamcrest.RecurrenceRuleMatcher.instances;
import static org.dmfs.rfc5545.hamcrest.RecurrenceRuleMatcher.results;
import static org.dmfs.rfc5545.hamcrest.RecurrenceRuleMatcher.startingWith;
import static org.dmfs.rfc5545.hamcrest.RecurrenceRuleMatcher.validRule;
import static org.dmfs.rfc5545.hamcrest.RecurrenceRuleMatcher.walking;
import static org.dmfs.rfc5545.hamcrest.datetime.BeforeMatcher.before;
import static org.dmfs.rfc5545.hamcrest.datetime.DayOfMonthMatcher.onDayOfMonth;
import static org.dmfs.rfc5545.hamcrest.datetime.MonthMatcher.inMonth;
import static org.dmfs.rfc5545.hamcrest.datetime.WeekDayMatcher.onWeekDay;
import static org.dmfs.rfc5545.hamcrest.datetime.YearMatcher.inYear;
import static org.hamcrest.Matchers.hasToString;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
/*
 * Copyright 2018 Marten Gajda <marten@dmfs.org>
 *
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.dmfs.rfc5545.recur;




/**
 * @author Marten Gajda
 */
public final class RecurrenceRuleTest
{
    @Test
    public void test() throws InvalidRecurrenceRuleException
    {
        assertThat(new RecurrenceRule("FREQ=WEEKLY;COUNT=1000"),
                is(validRule(DateTime.parse("20180101"),
                        walking(),
                        instances(are(onWeekDay(MO))),