Search in sources :

Example 6 with NamedayBundle

use of com.alexstyl.specialdates.events.namedays.NamedayBundle in project Memento-Calendar by alexstyl.

the class NamedayJSONParserTest method davidNamedayIsReturnedCorrectly.

@Test
public void davidNamedayIsReturnedCorrectly() {
    NamedayBundle namedayBundle = NamedayJSONParser.getNamedaysFrom(namedayJSON);
    NameCelebrations dates = namedayBundle.getDatesFor("Δαβίδ");
    assertThatContainsDate(dates, Date.Companion.on(26, JUNE));
}
Also used : NameCelebrations(com.alexstyl.specialdates.events.namedays.NameCelebrations) NamedayBundle(com.alexstyl.specialdates.events.namedays.NamedayBundle) Test(org.junit.Test)

Example 7 with NamedayBundle

use of com.alexstyl.specialdates.events.namedays.NamedayBundle in project Memento-Calendar by alexstyl.

the class GreeklishParserTest method davidNamedayIsReturnedCorrectly.

@Test
public void davidNamedayIsReturnedCorrectly() {
    NamedayBundle namedayBundle = NamedayJSONParser.getNamedaysFromJSONasSounds(namedayJSON);
    NameCelebrations dates = namedayBundle.getDatesFor("Δαβίδ");
    NameCelebrations datesGreeklish = namedayBundle.getDatesFor("David");
    assertThatContainsSamedate(dates, datesGreeklish);
}
Also used : NameCelebrations(com.alexstyl.specialdates.events.namedays.NameCelebrations) NamedayBundle(com.alexstyl.specialdates.events.namedays.NamedayBundle) Test(org.junit.Test)

Example 8 with NamedayBundle

use of com.alexstyl.specialdates.events.namedays.NamedayBundle in project Memento-Calendar by alexstyl.

the class NamedayCalendarProvider method loadNamedayCalendarForLocale.

public NamedayCalendar loadNamedayCalendarForLocale(NamedayLocale locale, int year) {
    if (hasRequestedSameCalendar(locale, year)) {
        return cachedCalendar;
    }
    NamedayJSON namedayJSON = getNamedayJSONFor(locale);
    SpecialNamedays specialCaseHandler = getSpecialnamedaysHandler(locale, namedayJSON);
    NamedayBundle namedaysBundle = getNamedayBundle(locale, namedayJSON);
    NamedayCalendar namedayCalendar = new NamedayCalendar(locale, namedaysBundle, specialCaseHandler, year);
    cacheCalendar(namedayCalendar);
    return namedayCalendar;
}
Also used : NamedayCalendar(com.alexstyl.specialdates.events.namedays.calendar.NamedayCalendar) NamedayBundle(com.alexstyl.specialdates.events.namedays.NamedayBundle)

Example 9 with NamedayBundle

use of com.alexstyl.specialdates.events.namedays.NamedayBundle in project Memento-Calendar by alexstyl.

the class NamedayJSONParser method createBundleWith.

private static NamedayBundle createBundleWith(NamedayJSON locale, Node namesToDate) {
    NamedaysList dateToNames = new NamedaysList();
    JSONArray data = locale.getData();
    int size = data.length();
    for (int i = 0; i < size; i++) {
        try {
            JSONObject nameday;
            nameday = (JSONObject) data.get(i);
            String dateString = nameday.getString("date");
            Date theDate = getNamedaysFrom(dateString);
            JSONArray variations = nameday.getJSONArray("names");
            int numberOfVariations = variations.length();
            for (int varCount = 0; varCount < numberOfVariations; varCount++) {
                String variation = variations.getString(varCount);
                namesToDate.addDate(variation, theDate);
                dateToNames.addNameday(theDate, variation);
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }
    return new NamedayBundle(namesToDate, dateToNames);
}
Also used : NamedaysList(com.alexstyl.specialdates.events.namedays.NamedaysList) JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray) JSONException(org.json.JSONException) NamedayBundle(com.alexstyl.specialdates.events.namedays.NamedayBundle) Date(com.alexstyl.specialdates.date.Date)

Example 10 with NamedayBundle

use of com.alexstyl.specialdates.events.namedays.NamedayBundle in project Memento-Calendar by alexstyl.

the class GreeklishParserTest method magdoulaNamedayIsReturnedCorrectly.

@Test
public void magdoulaNamedayIsReturnedCorrectly() {
    NamedayBundle namedayBundle = NamedayJSONParser.getNamedaysFromJSONasSounds(namedayJSON);
    NameCelebrations dates = namedayBundle.getDatesFor("Αμαλία");
    NameCelebrations datesGreeklish = namedayBundle.getDatesFor("Amalia");
    assertThatContainsSamedate(dates, datesGreeklish);
}
Also used : NameCelebrations(com.alexstyl.specialdates.events.namedays.NameCelebrations) NamedayBundle(com.alexstyl.specialdates.events.namedays.NamedayBundle) Test(org.junit.Test)

Aggregations

NamedayBundle (com.alexstyl.specialdates.events.namedays.NamedayBundle)11 Test (org.junit.Test)7 NameCelebrations (com.alexstyl.specialdates.events.namedays.NameCelebrations)6 NamedaysList (com.alexstyl.specialdates.events.namedays.NamedaysList)3 Date (com.alexstyl.specialdates.date.Date)2 EasternNameday (com.alexstyl.specialdates.events.namedays.calendar.EasternNameday)1 NamedayCalendar (com.alexstyl.specialdates.events.namedays.calendar.NamedayCalendar)1 JSONArray (org.json.JSONArray)1 JSONException (org.json.JSONException)1 JSONObject (org.json.JSONObject)1