Search in sources :

Example 11 with Substitution

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

the class SVPlanDemoTest method demoTest3.

@Test
public void demoTest3() throws IOException, JSONException {
    List<Document> docs = new ArrayList<>();
    docs.add(Jsoup.parse(html3));
    SubstitutionSchedule schedule = parser.parseSVPlanSchedule(docs);
    assertEquals(new LocalDateTime(2017, 5, 2, 7, 19), schedule.getLastChange());
    assertEquals(1, schedule.getDays().size());
    SubstitutionScheduleDay day = schedule.getDays().get(0);
    assertEquals(new LocalDate(2017, 5, 2), day.getDate());
    assertEquals(32, day.getSubstitutions().size());
    assertEquals(0, day.getMessages().size());
    for (Substitution subst : day.getSubstitutions()) {
        if (!subst.getSubject().equals("Profi"))
            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) ArrayList(java.util.ArrayList) SubstitutionScheduleDay(me.vertretungsplan.objects.SubstitutionScheduleDay) Document(org.jsoup.nodes.Document) LocalDate(org.joda.time.LocalDate) Test(org.junit.Test)

Example 12 with Substitution

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

the class SVPlanDemoTest method demoTest1.

@Test
public void demoTest1() throws IOException, JSONException {
    List<Document> docs = new ArrayList<>();
    docs.add(Jsoup.parse(html1));
    SubstitutionSchedule schedule = parser.parseSVPlanSchedule(docs);
    assertEquals(new LocalDateTime(2016, 9, 2, 11, 10), schedule.getLastChange());
    assertEquals(5, schedule.getDays().size());
    SubstitutionScheduleDay day = schedule.getDays().get(0);
    assertEquals(new LocalDate(2016, 9, 2), day.getDate());
    assertEquals(14, day.getSubstitutions().size());
    assertEquals(1, day.getMessages().size());
    assertEquals("Ordnungsdienst:9BR<br>", day.getMessages().get(0));
    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) ArrayList(java.util.ArrayList) SubstitutionScheduleDay(me.vertretungsplan.objects.SubstitutionScheduleDay) Document(org.jsoup.nodes.Document) LocalDate(org.joda.time.LocalDate) Test(org.junit.Test)

Example 13 with Substitution

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

the class SVPlanDemoTest method demoTest2.

@Test
public void demoTest2() throws IOException, JSONException {
    List<Document> docs = new ArrayList<>();
    docs.add(Jsoup.parse(html2));
    SubstitutionSchedule schedule = parser.parseSVPlanSchedule(docs);
    assertEquals(new LocalDateTime(2016, 11, 6, 19, 36, 18), schedule.getLastChange());
    assertEquals(1, schedule.getDays().size());
    SubstitutionScheduleDay day = schedule.getDays().get(0);
    assertEquals(new LocalDate(2016, 11, 7), day.getDate());
    assertEquals(19, day.getSubstitutions().size());
    assertEquals(1, day.getMessages().size());
    assertEquals("Sprechtag Frau Fildebrandt (Klasse 9).", day.getMessages().get(0));
    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) ArrayList(java.util.ArrayList) SubstitutionScheduleDay(me.vertretungsplan.objects.SubstitutionScheduleDay) Document(org.jsoup.nodes.Document) LocalDate(org.joda.time.LocalDate) Test(org.junit.Test)

Example 14 with Substitution

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

the class SVPlanDemoTest method demoTest4.

@Test
public void demoTest4() throws IOException, JSONException {
    List<Document> docs = new ArrayList<>();
    docs.add(Jsoup.parse(html4));
    SubstitutionSchedule schedule = parser.parseSVPlanSchedule(docs);
    for (Substitution subst : schedule.getDays().get(0).getSubstitutions()) {
        assertTrue(subst.getClasses().size() == 1);
    }
    SubstitutionSchedule schedule2 = parserWithoutRepeat.parseSVPlanSchedule(docs);
    for (Substitution subst : schedule2.getDays().get(0).getSubstitutions()) {
        if (subst.getSubject().equals("Netzw")) {
            assertTrue(subst.getClasses().size() == 0);
        } else {
            assertTrue(subst.getClasses().size() == 1);
        }
    }
}
Also used : Substitution(me.vertretungsplan.objects.Substitution) SubstitutionSchedule(me.vertretungsplan.objects.SubstitutionSchedule) ArrayList(java.util.ArrayList) Document(org.jsoup.nodes.Document) Test(org.junit.Test)

Example 15 with Substitution

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

the class UntisCommonParserTest method testHandleRoomBothSpan.

@Test
public void testHandleRoomBothSpan() throws Exception {
    Substitution subst = new Substitution();
    Element cell = Jsoup.parse("<table><td><span style=\"color: #010101\"><s>248</s>?236</span></td></table>").select("td").first();
    UntisCommonParser.handleRoom(subst, cell);
    assertEquals("248", subst.getPreviousRoom());
    assertEquals("236", subst.getRoom());
}
Also used : Substitution(me.vertretungsplan.objects.Substitution) Element(org.jsoup.nodes.Element) Test(org.junit.Test)

Aggregations

Substitution (me.vertretungsplan.objects.Substitution)35 Test (org.junit.Test)15 SubstitutionScheduleDay (me.vertretungsplan.objects.SubstitutionScheduleDay)14 Element (org.jsoup.nodes.Element)11 LocalDate (org.joda.time.LocalDate)9 SubstitutionSchedule (me.vertretungsplan.objects.SubstitutionSchedule)8 LocalDateTime (org.joda.time.LocalDateTime)7 Elements (org.jsoup.select.Elements)5 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 Document (org.jsoup.nodes.Document)4 Matcher (java.util.regex.Matcher)3 Pattern (java.util.regex.Pattern)2 JSONArray (org.json.JSONArray)2 JSONObject (org.json.JSONObject)2 HashSet (java.util.HashSet)1 SubstitutionDiff (me.vertretungsplan.objects.diff.SubstitutionDiff)1 NotNull (org.jetbrains.annotations.NotNull)1