<commit_before>package org.dhis2.mobile.utils.date.expiryday;

import org.joda.time.DateTimeConstants;
import org.joda.time.Days;
import org.joda.time.LocalDate;
import org.junit.Test;

import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertTrue;

public class BiWeeklyExpiryDateValidatorTest {
    private static final String PATTERN = "yyyy'iW'ww";

    @Test
    public void testCanNotEditPreviousPeriodEndsSameTodayMinusDifferenceExpiryDays() {
        LocalDate periodDate = new LocalDate();
        periodDate = periodDate.minusWeeks(2).withDayOfWeek(DateTimeConstants.MONDAY);
        int expiryDays = Days.daysBetween(periodDate.plusDays(13), new LocalDate()).getDays();
        BiWeeklyExpiryDayValidator weeklyExpiryDayValidator = new BiWeeklyExpiryDayValidator(expiryDays,
                periodDate.toString(PATTERN));
        assertFalse(weeklyExpiryDayValidator.canEdit());
    }

    @Test
    public void testCanEditPreviousPeriodEndsSameTodayMinusExpiryDaysPlusOne() {
        LocalDate periodDate = new LocalDate();
        periodDate = periodDate.minusWeeks(2).withDayOfWeek(DateTimeConstants.MONDAY);
        int expiryDays = Days.daysBetween(periodDate.plusDays(13), new LocalDate()).getDays() + 1;
        BiWeeklyExpiryDayValidator weeklyExpiryDayValidator = new BiWeeklyExpiryDayValidator(expiryDays,
                periodDate.toString(PATTERN));
        assertTrue(weeklyExpiryDayValidator.canEdit());
    }

    @Test
    public void testCanNotEditPreviousPeriodEndsSameTodayMinusDifferenceMinusOneExpiryDays() {
        LocalDate periodDate = new LocalDate();
        periodDate = periodDate.minusWeeks(2).withDayOfWeek(DateTimeConstants.MONDAY);
        int expiryDays = Days.daysBetween(periodDate.plusDays(13), new LocalDate()).getDays() - 1;<commit_msg>fix test pattern<commit_after>package org.dhis2.mobile.utils.date.expiryday;

import org.joda.time.DateTimeConstants;
import org.joda.time.Days;
import org.joda.time.LocalDate;
import org.junit.Test;

import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertTrue;

public class BiWeeklyExpiryDateValidatorTest {
    private static final String PATTERN = "yyyy'BiW'ww";

    @Test
    public void testCanNotEditPreviousPeriodEndsSameTodayMinusDifferenceExpiryDays() {
        LocalDate periodDate = new LocalDate();
        periodDate = periodDate.minusWeeks(2).withDayOfWeek(DateTimeConstants.MONDAY);
        int expiryDays = Days.daysBetween(periodDate.plusDays(13), new LocalDate()).getDays();
        BiWeeklyExpiryDayValidator weeklyExpiryDayValidator = new BiWeeklyExpiryDayValidator(expiryDays,
                periodDate.toString(PATTERN));
        assertFalse(weeklyExpiryDayValidator.canEdit());
    }

    @Test
    public void testCanEditPreviousPeriodEndsSameTodayMinusExpiryDaysPlusOne() {
        LocalDate periodDate = new LocalDate();
        periodDate = periodDate.minusWeeks(2).withDayOfWeek(DateTimeConstants.MONDAY);
        int expiryDays = Days.daysBetween(periodDate.plusDays(13), new LocalDate()).getDays() + 1;
        BiWeeklyExpiryDayValidator weeklyExpiryDayValidator = new BiWeeklyExpiryDayValidator(expiryDays,
                periodDate.toString(PATTERN));
        assertTrue(weeklyExpiryDayValidator.canEdit());
    }

    @Test
    public void testCanNotEditPreviousPeriodEndsSameTodayMinusDifferenceMinusOneExpiryDays() {
        LocalDate periodDate = new LocalDate();
        periodDate = periodDate.minusWeeks(2).withDayOfWeek(DateTimeConstants.MONDAY);
        int expiryDays = Days.daysBetween(periodDate.plusDays(13), new LocalDate()).getDays() - 1;
{'fraction_non_alphanumeric': 0.08986301369863013, 'fraction_numerical': 0.006575342465753425, 'mean_word_length': 4.574045801526718, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7327288', 'n_tokens_mistral': 1137, 'n_tokens_neox': 1057, 'n_words': 169}