Search in sources :

Example 31 with SubstitutionScheduleDay

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

the class IndiwareMobileDemoTest method demoTest.

@Test
public void demoTest() throws IOException, JSONException {
    Document doc = Jsoup.parse(readResource("/indiware-mobile/indiware-mobile.xml"), "", Parser.xmlParser());
    SubstitutionScheduleData scheduleData = new SubstitutionScheduleData();
    scheduleData.setType(SubstitutionSchedule.Type.STUDENT);
    SubstitutionScheduleDay day = IndiwareMobileParser.parseDay(doc, new ColorProvider(), scheduleData);
    assertEquals(new LocalDate(2017, 6, 21), day.getDate());
    assertEquals(new LocalDateTime(2017, 6, 20, 10, 28), day.getLastChange());
    assertEquals(192, day.getSubstitutions().size());
}
Also used : LocalDateTime(org.joda.time.LocalDateTime) SubstitutionScheduleData(me.vertretungsplan.objects.SubstitutionScheduleData) SubstitutionScheduleDay(me.vertretungsplan.objects.SubstitutionScheduleDay) Document(org.jsoup.nodes.Document) LocalDate(org.joda.time.LocalDate) Test(org.junit.Test)

Example 32 with SubstitutionScheduleDay

use of me.vertretungsplan.objects.SubstitutionScheduleDay 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 33 with SubstitutionScheduleDay

use of me.vertretungsplan.objects.SubstitutionScheduleDay 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)

Example 34 with SubstitutionScheduleDay

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

the class ESchoolDemoTest method demoTest.

@Test
public void demoTest() throws IOException, JSONException {
    SubstitutionSchedule schedule = parser.parseESchoolSchedule(Jsoup.parse(html));
    assertEquals(new LocalDateTime(2016, 9, 4, 14, 53), schedule.getLastChange());
    assertEquals(1, schedule.getDays().size());
    SubstitutionScheduleDay day = schedule.getDays().get(0);
    assertEquals(new LocalDate(2016, 9, 5), day.getDate());
    assertEquals(6, day.getSubstitutions().size());
    assertEquals(0, day.getMessages().size());
    for (Substitution subst : day.getSubstitutions()) {
        assertTrue(subst.getClasses().size() == 1);
        assertNotEmpty(subst.getLesson());
        assertNullOrNotEmpty(subst.getPreviousSubject());
        assertNotEmpty(subst.getSubject());
        assertNullOrNotEmpty(subst.getRoom());
        assertNullOrNotEmpty(subst.getTeacher());
        assertNullOrNotEmpty(subst.getPreviousTeacher());
        assertNullOrNotEmpty(subst.getDesc());
        assertNotEmpty(subst.getType());
    }
}
Also used : LocalDateTime(org.joda.time.LocalDateTime) Substitution(me.vertretungsplan.objects.Substitution) SubstitutionSchedule(me.vertretungsplan.objects.SubstitutionSchedule) SubstitutionScheduleDay(me.vertretungsplan.objects.SubstitutionScheduleDay) LocalDate(org.joda.time.LocalDate) Test(org.junit.Test)

Aggregations

SubstitutionScheduleDay (me.vertretungsplan.objects.SubstitutionScheduleDay)34 LocalDate (org.joda.time.LocalDate)15 Substitution (me.vertretungsplan.objects.Substitution)14 SubstitutionSchedule (me.vertretungsplan.objects.SubstitutionSchedule)14 Test (org.junit.Test)14 LocalDateTime (org.joda.time.LocalDateTime)12 Element (org.jsoup.nodes.Element)10 Matcher (java.util.regex.Matcher)6 Document (org.jsoup.nodes.Document)6 Elements (org.jsoup.select.Elements)6 Pattern (java.util.regex.Pattern)5 ArrayList (java.util.ArrayList)4 IOException (java.io.IOException)3 NotNull (org.jetbrains.annotations.NotNull)3 JSONObject (org.json.JSONObject)3 JSONArray (org.json.JSONArray)2 HashSet (java.util.HashSet)1 AdditionalInfo (me.vertretungsplan.objects.AdditionalInfo)1 SubstitutionScheduleData (me.vertretungsplan.objects.SubstitutionScheduleData)1 TextNode (org.jsoup.nodes.TextNode)1