package com.alexstyl.specialdates.events.namedays.calendar.resource;

import com.alexstyl.specialdates.date.AnnualEvent;
import com.alexstyl.specialdates.events.namedays.NameCelebrations;
import com.alexstyl.specialdates.events.namedays.NamedayBundle;
import com.alexstyl.specialdates.events.namedays.NamedayLocale;

import org.json.JSONException;
import org.junit.Before;
import org.junit.Test;

import static com.alexstyl.specialdates.date.Date.AUGUST;
import static org.fest.assertions.api.Assertions.assertThat;

public class NamedayJSONParserTest {

    private NamedayJSON namedayJSON;

    @Before
    public void setUp() throws JSONException {
        JavaJSONResourceLoader resourceLoader = new JavaJSONResourceLoader();
        NamedayJSONResourceProvider resourceProvider = new NamedayJSONResourceProvider(resourceLoader);
        namedayJSON = resourceProvider.getNamedayJSONFor(NamedayLocale.gr);

    }

    @Test
    public void returningBundleHasNames() {
        NamedayBundle namedayBundle = NamedayJSONParser.getNamedaysFrom(namedayJSON);
        assertThat(namedayBundle.getNames()).isNotEmpty();
    }

    @Test
    public void alexandrosNamedayIsReturnedCorrectly() {
        NamedayBundle namedayBundle = NamedayJSONParser.getNamedaysFrom(namedayJSON);
        NameCelebrations dates = namedayBundle.getDatesFor("Αλέξανδρος");
        assertThat(dates.getDate(0)).isEqualTo(new AnnualEvent(30, AUGUST));
    }
}

@@ -440,22 +440,17 @@
 te.Date.
-AUGUST
+*
 ;%0Aimport
@@ -1421,11 +1421,613 @@
 );%0A    %7D
+%0A%0A    @Test%0A    public void davidNamedayIsReturnedCorrectly() %7B%0A        NamedayBundle namedayBundle = NamedayJSONParser.getNamedaysFrom(namedayJSON);%0A        NameCelebrations dates = namedayBundle.getDatesFor(%22%CE%94%CE%B1%CE%B2%CE%AF%CE%B4%22);%0A        assertThat(dates.getDate(0)).isEqualTo(new AnnualEvent(26, JUNE));%0A    %7D%0A%0A    @Test%0A    public void magdoulaNamedayIsReturnedCorrectly() %7B%0A        NamedayBundle namedayBundle = NamedayJSONParser.getNamedaysFrom(namedayJSON);%0A        NameCelebrations dates = namedayBundle.getDatesFor(%22%CE%91%CE%BC%CE%B1%CE%BB%CE%AF%CE%B1%22);%0A        assertThat(dates.getDate(0)).isEqualTo(new AnnualEvent(10, JULY));%0A    %7D
 %0A%7D%0A

Add more tests for NamedayJSONParser