Search in sources :

Example 26 with SubstitutionSchedule

use of me.vertretungsplan.objects.SubstitutionSchedule in project substitution-schedule-parser by vertretungsplanme.

the class IndiwareDemoTest method testHTMLEmbeddedContentSelector.

@Test
public void testHTMLEmbeddedContentSelector() throws JSONException, IOException {
    String html = readResource("/indiware/indiware_embedded.html");
    SubstitutionScheduleData scheduleData = new SubstitutionScheduleData();
    final JSONObject data = new JSONObject();
    data.put("embeddedContentSelector", ".items-leading .dd-article > table > tbody > tr > td");
    scheduleData.setData(data);
    IndiwareParser parser = new IndiwareParser(scheduleData, null);
    SubstitutionSchedule schedule = new SubstitutionSchedule();
    parser.parseIndiwarePage(schedule, html);
    assertEquals(2, schedule.getDays().size());
    assertEquals(new LocalDate(2017, 3, 10), schedule.getDays().get(0).getDate());
    assertEquals(new LocalDate(2017, 3, 13), schedule.getDays().get(1).getDate());
}
Also used : SubstitutionScheduleData(me.vertretungsplan.objects.SubstitutionScheduleData) JSONObject(org.json.JSONObject) SubstitutionSchedule(me.vertretungsplan.objects.SubstitutionSchedule) LocalDate(org.joda.time.LocalDate) Test(org.junit.Test)

Example 27 with SubstitutionSchedule

use of me.vertretungsplan.objects.SubstitutionSchedule in project substitution-schedule-parser by vertretungsplanme.

the class IndiwareDemoTest method testHTMLSplit.

@Test
public void testHTMLSplit() throws JSONException, IOException {
    String html = readResource("/indiware/indiware_split.html");
    SubstitutionSchedule schedule = new SubstitutionSchedule();
    parser.parseIndiwarePage(schedule, html);
    assertEquals(2, schedule.getDays().size());
    assertEquals(new LocalDate(2017, 3, 10), schedule.getDays().get(0).getDate());
    assertEquals(new LocalDate(2017, 3, 13), schedule.getDays().get(1).getDate());
}
Also used : SubstitutionSchedule(me.vertretungsplan.objects.SubstitutionSchedule) LocalDate(org.joda.time.LocalDate) Test(org.junit.Test)

Example 28 with SubstitutionSchedule

use of me.vertretungsplan.objects.SubstitutionSchedule in project substitution-schedule-parser by vertretungsplanme.

the class UntisInfoDemoTest method demoTest.

@Test
public void demoTest() throws IOException, JSONException, CredentialInvalidException {
    SubstitutionSchedule schedule = SubstitutionSchedule.fromData(scheduleData);
    parser.parseSubstitutionDays(schedule, "29.06.2017 12:10", doc, null, new ArrayList<String>());
    assertEquals(2, schedule.getDays().size());
    if (schedule.getDays().get(0).getSubstitutions().size() == 31) {
        assertEquals(24, schedule.getDays().get(1).getSubstitutions().size());
    } else {
        assertEquals(31, schedule.getDays().get(1).getSubstitutions().size());
        assertEquals(24, schedule.getDays().get(0).getSubstitutions().size());
    }
}
Also used : SubstitutionSchedule(me.vertretungsplan.objects.SubstitutionSchedule) Test(org.junit.Test)

Example 29 with SubstitutionSchedule

use of me.vertretungsplan.objects.SubstitutionSchedule in project substitution-schedule-parser by vertretungsplanme.

the class DaVinciDemoTest method singleTest5.

@Test
public void singleTest5() throws IOException, JSONException {
    SubstitutionSchedule schedule = new SubstitutionSchedule();
    DaVinciParser.parsePage(Jsoup.parse(htmlSingleDaVinci5), schedule, parser.colorProvider);
    assertEquals(3, schedule.getDays().size());
    assertEquals(new LocalDateTime(2017, 1, 17, 7, 32), schedule.getLastChange());
    SubstitutionScheduleDay day = schedule.getDays().get(0);
    assertEquals(new LocalDate(2017, 1, 17), day.getDate());
    assertEquals(2, day.getSubstitutions().size());
    assertEquals(0, day.getMessages().size());
    checkSubstitutions(day);
}
Also used : LocalDateTime(org.joda.time.LocalDateTime) SubstitutionSchedule(me.vertretungsplan.objects.SubstitutionSchedule) SubstitutionScheduleDay(me.vertretungsplan.objects.SubstitutionScheduleDay) LocalDate(org.joda.time.LocalDate) Test(org.junit.Test)

Example 30 with SubstitutionSchedule

use of me.vertretungsplan.objects.SubstitutionSchedule in project substitution-schedule-parser by vertretungsplanme.

the class DaVinciDemoTest method singleTest6.

@Test
public void singleTest6() throws IOException, JSONException {
    SubstitutionSchedule schedule = new SubstitutionSchedule();
    DaVinciParser.parsePage(Jsoup.parse(htmlSingle), schedule, parser.colorProvider);
    SubstitutionScheduleDay day = schedule.getDays().get(0);
    assertEquals(new LocalDate(2016, 9, 5), day.getDate());
    assertEquals(new LocalDateTime(2016, 9, 2, 13, 32), day.getLastChange());
    assertEquals(23, day.getSubstitutions().size());
    assertEquals(0, day.getMessages().size());
    checkSubstitutions(day);
}
Also used : LocalDateTime(org.joda.time.LocalDateTime) SubstitutionSchedule(me.vertretungsplan.objects.SubstitutionSchedule) SubstitutionScheduleDay(me.vertretungsplan.objects.SubstitutionScheduleDay) LocalDate(org.joda.time.LocalDate) Test(org.junit.Test)

Aggregations

SubstitutionSchedule (me.vertretungsplan.objects.SubstitutionSchedule)31 Document (org.jsoup.nodes.Document)15 SubstitutionScheduleDay (me.vertretungsplan.objects.SubstitutionScheduleDay)14 LocalDate (org.joda.time.LocalDate)14 Test (org.junit.Test)13 ArrayList (java.util.ArrayList)9 LocalDateTime (org.joda.time.LocalDateTime)9 Substitution (me.vertretungsplan.objects.Substitution)8 IOException (java.io.IOException)6 JSONArray (org.json.JSONArray)6 JSONObject (org.json.JSONObject)6 Element (org.jsoup.nodes.Element)6 HttpResponseException (org.apache.http.client.HttpResponseException)4 NameValuePair (org.apache.http.NameValuePair)3 BasicNameValuePair (org.apache.http.message.BasicNameValuePair)3 NotNull (org.jetbrains.annotations.NotNull)3 Elements (org.jsoup.select.Elements)3 Matcher (java.util.regex.Matcher)2 Pattern (java.util.regex.Pattern)2 CredentialInvalidException (me.vertretungsplan.exception.CredentialInvalidException)2