Search in sources :

Example 11 with SubstitutionSchedule

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

the class LegionBoardDemoTest method demoTest.

@Test
public void demoTest() throws IOException, JSONException {
    SubstitutionSchedule schedule = new SubstitutionSchedule();
    parser.parseLegionBoard(schedule, changes, courses, teachers);
    assertEquals(3, schedule.getDays().size());
    SubstitutionScheduleDay firstDay = schedule.getDays().get(0);
    assertEquals(new LocalDate(2016, 9, 2), firstDay.getDate());
    assertEquals(2, firstDay.getSubstitutions().size());
}
Also used : SubstitutionSchedule(me.vertretungsplan.objects.SubstitutionSchedule) SubstitutionScheduleDay(me.vertretungsplan.objects.SubstitutionScheduleDay) LocalDate(org.joda.time.LocalDate) Test(org.junit.Test)

Example 12 with SubstitutionSchedule

use of me.vertretungsplan.objects.SubstitutionSchedule 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 13 with SubstitutionSchedule

use of me.vertretungsplan.objects.SubstitutionSchedule 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 14 with SubstitutionSchedule

use of me.vertretungsplan.objects.SubstitutionSchedule 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 15 with SubstitutionSchedule

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

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