Search in sources :

Example 16 with Substitution

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

the class UntisCommonParserTest method testHandleRoomSingle.

@Test
public void testHandleRoomSingle() throws Exception {
    Substitution subst = new Substitution();
    Element cell = Jsoup.parse("<table><td>224</td></table>").select("td").first();
    UntisCommonParser.handleRoom(subst, cell);
    assertEquals(null, subst.getPreviousRoom());
    assertEquals("224", subst.getRoom());
}
Also used : Substitution(me.vertretungsplan.objects.Substitution) Element(org.jsoup.nodes.Element) Test(org.junit.Test)

Example 17 with Substitution

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

the class UntisCommonParserTest method testHandleRoomSinglePrevious.

@Test
public void testHandleRoomSinglePrevious() throws Exception {
    Substitution subst = new Substitution();
    Element cell = Jsoup.parse("<table><td><s>264</s></td></table>").select("td").first();
    UntisCommonParser.handleRoom(subst, cell);
    assertEquals("264", subst.getPreviousRoom());
    assertEquals(null, subst.getRoom());
}
Also used : Substitution(me.vertretungsplan.objects.Substitution) Element(org.jsoup.nodes.Element) Test(org.junit.Test)

Example 18 with Substitution

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

the class SubstitutionTextUtilsTest method testSubstitutionDiffText.

@Theory
public void testSubstitutionDiffText(@Strings(values = { "", "Fach" }) String subject1, @Strings(values = { "", "vorheriges Fach" }) String previousSubject1, @Strings(values = { "", "Lehrer" }) String teacher1, @Strings(values = { "", "vorheriger Lehrer" }) String previousTeacher1, @Strings(values = { "", "Raum" }) String room1, @Strings(values = { "", "vorheriger Raum" }) String previousRoom1, @Strings(values = { "", "Beschreibung" }) String desc1, @Strings(values = { "", "Fach", "Fach2" }) String subject2, @Strings(values = { "", "vorheriges Fach", "vorheriges Fach2" }) String previousSubject2, @Strings(values = { "", "Lehrer", "Lehrer2" }) String teacher2, @Strings(values = { "", "vorheriger Lehrer", "vorheriger Lehrer2" }) String previousTeacher2, @Strings(values = { "", "Raum", "Raum2" }) String room2, @Strings(values = { "", "vorheriger Raum", "vorheriger Raum2" }) String previousRoom2, @Strings(values = { "", "Beschreibung", "Beschreibung2" }) String desc2) throws Exception {
    assumeTrue(bothOrNoneEmpty(subject1, subject2));
    assumeTrue(bothOrNoneEmpty(previousSubject1, previousSubject2));
    assumeTrue(bothOrNoneEmpty(teacher1, teacher2));
    assumeTrue(bothOrNoneEmpty(previousTeacher1, previousTeacher2));
    assumeTrue(bothOrNoneEmpty(room1, room2));
    assumeTrue(bothOrNoneEmpty(previousRoom1, previousRoom2));
    assumeTrue(bothOrNoneEmpty(desc1, desc2));
    assumeTrue(complexity(subject1, subject2, previousSubject1, previousSubject2, teacher1, teacher2, previousTeacher1, previousTeacher2, room1, room2, previousRoom1, previousRoom2, desc1, desc2) <= SubstitutionDiff.MAX_COMPLEXITY);
    Substitution subst1 = new Substitution();
    subst1.setSubject(subject1);
    subst1.setPreviousSubject(previousSubject1);
    subst1.setTeacher(teacher1);
    subst1.setPreviousTeacher(previousTeacher1);
    subst1.setRoom(room1);
    subst1.setPreviousRoom(previousRoom1);
    subst1.setDesc(desc1);
    Substitution subst2 = new Substitution();
    subst2.setSubject(subject2);
    subst2.setPreviousSubject(previousSubject2);
    subst2.setTeacher(teacher2);
    subst2.setPreviousTeacher(previousTeacher2);
    subst2.setRoom(room2);
    subst2.setPreviousRoom(previousRoom2);
    subst2.setDesc(desc2);
    SubstitutionDiff diff = new SubstitutionDiff();
    diff.setOldSubstitution(subst1);
    diff.setNewSubstitution(subst2);
    String text = SubstitutionTextUtils.getText(diff);
/*if (hasData(subject) || hasData(previousSubject) || hasData(teacher) || hasData(previousTeacher) ||
                hasData(room) || hasData(previousRoom) || hasData(desc)) {
            assertNotEquals(text, "");
        }*/
// System.out.println(text);
}
Also used : Substitution(me.vertretungsplan.objects.Substitution) SubstitutionDiff(me.vertretungsplan.objects.diff.SubstitutionDiff)

Example 19 with Substitution

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

the class SubstitutionTextUtilsTest method testSubstitutionText.

@Theory
public void testSubstitutionText(@Strings(values = { "", "Fach" }) String subject, @Strings(values = { "", "vorheriges Fach" }) String previousSubject, @Strings(values = { "", "Lehrer" }) String teacher, @Strings(values = { "", "vorheriger Lehrer" }) String previousTeacher, @Strings(values = { "", "Raum" }) String room, @Strings(values = { "", "vorheriger Raum" }) String previousRoom, @Strings(values = { "", "Beschreibung" }) String desc) throws Exception {
    Substitution subst = new Substitution();
    subst.setSubject(subject);
    subst.setPreviousSubject(previousSubject);
    subst.setTeacher(teacher);
    subst.setPreviousTeacher(previousTeacher);
    subst.setRoom(room);
    subst.setPreviousRoom(previousRoom);
    subst.setDesc(desc);
    String text = SubstitutionTextUtils.getText(subst);
    if (hasData(subject) || hasData(previousSubject) || hasData(teacher) || hasData(previousTeacher) || hasData(room) || hasData(previousRoom) || hasData(desc)) {
        assertNotEquals(text, "");
    }
// System.out.println(text);
}
Also used : Substitution(me.vertretungsplan.objects.Substitution)

Example 20 with Substitution

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

the class SubstitutionTextUtilsTest2 method testGetTeachers3.

@Test
public void testGetTeachers3() {
    Substitution s = new Substitution();
    s.setTeacher(null);
    s.setPreviousTeacher("A");
    assertEquals("A", SubstitutionTextUtils.getTeachers(s));
}
Also used : Substitution(me.vertretungsplan.objects.Substitution) 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