Search in sources :

Example 16 with SubstitutionScheduleDay

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

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

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

the class DiffTest method testDiffSame.

@Test
public void testDiffSame() {
    Substitution s1 = new Substitution();
    s1.setClasses(new HashSet<>(Arrays.asList(new String[] { "07B" })));
    s1.setLesson("6");
    s1.setType("Enfall");
    s1.setSubject("Entfall");
    s1.setPreviousSubject("SPA");
    s1.setTeachers(new HashSet<>(Arrays.asList(new String[] { "KW", "ER" })));
    s1.setPreviousTeachers(new HashSet<String>());
    s1.setColor("#F44336");
    s1.setDesc("fällt aus");
    Substitution s2 = new Substitution();
    s2.setClasses(new HashSet<>(Arrays.asList(new String[] { "07B" })));
    s2.setLesson("6");
    s2.setType("Enfall");
    s2.setSubject("Entfall");
    s2.setPreviousSubject("SPA");
    s2.setTeachers(new HashSet<>(Arrays.asList(new String[] { "KW", "ER" })));
    s2.setPreviousTeachers(new HashSet<String>());
    s2.setColor("#F44336");
    s2.setDesc("fällt aus");
    assertTrue(s1.equals(s2));
    SubstitutionScheduleDay d1 = new SubstitutionScheduleDay();
    d1.addSubstitution(s1);
    SubstitutionScheduleDay d2 = new SubstitutionScheduleDay();
    d2.addSubstitution(s2);
    SubstitutionScheduleDayDiff dayDiff = SubstitutionScheduleDayDiff.compare(d1, d2);
    assertTrue(!dayDiff.isNotEmpty());
}
Also used : Substitution(me.vertretungsplan.objects.Substitution) SubstitutionScheduleDay(me.vertretungsplan.objects.SubstitutionScheduleDay) Test(org.junit.Test)

Example 19 with SubstitutionScheduleDay

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

the class CSVDemoTest method demoTest.

@Test
public void demoTest() throws IOException, JSONException {
    SubstitutionSchedule schedule = parser.parseCSV(csv);
    assertEquals(2, schedule.getDays().size());
    SubstitutionScheduleDay day = schedule.getDays().get(0);
    assertEquals(new LocalDate(2016, 9, 5), day.getDate());
    assertEquals(new LocalDateTime(2016, 9, 2, 8, 16), day.getLastChange());
    assertEquals(1, day.getSubstitutions().size());
    assertEquals(0, day.getMessages().size());
    Substitution subst = day.getSubstitutions().iterator().next();
    assertEquals(1, subst.getClasses().size());
    assertEquals("05A", subst.getClasses().iterator().next());
    assertEquals("6", subst.getLesson());
    assertEquals("!Ma", subst.getSubject());
    assertEquals("!DROE", subst.getTeacher());
    assertEquals("!B203", subst.getRoom());
    assertEquals("für Mu REN", subst.getDesc());
    assertEquals("Vertretung", 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)

Example 20 with SubstitutionScheduleDay

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

the class SubstitutionScheduleDiff method filterDaysTeacher.

private void filterDaysTeacher(String teacher, Set<String> excludedSubjects, List<SubstitutionScheduleDay> days) {
    for (int i = 0; i < days.size(); i++) {
        SubstitutionScheduleDay day = days.get(i);
        SubstitutionScheduleDay filteredDay = day.clone();
        filteredDay.setSubstitutions(day.getSubstitutionsByTeacherAndExcludedSubject(teacher, excludedSubjects));
        days.set(i, filteredDay);
    }
}
Also used : SubstitutionScheduleDay(me.vertretungsplan.objects.SubstitutionScheduleDay)

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