-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
89f08d1
commit 8d5510d
Showing
3 changed files
with
242 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
parser/src/test/java/me/vertretungsplan/parser/ESchoolDemoTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* substitution-schedule-parser - Java library for parsing schools' substitution schedules | ||
* Copyright (c) 2016 Johan v. Forstner | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. | ||
* If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
package me.vertretungsplan.parser; | ||
|
||
import me.vertretungsplan.objects.Substitution; | ||
import me.vertretungsplan.objects.SubstitutionSchedule; | ||
import me.vertretungsplan.objects.SubstitutionScheduleData; | ||
import me.vertretungsplan.objects.SubstitutionScheduleDay; | ||
import org.joda.time.LocalDate; | ||
import org.joda.time.LocalDateTime; | ||
import org.json.JSONException; | ||
import org.json.JSONObject; | ||
import org.jsoup.Jsoup; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import java.io.IOException; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
public class ESchoolDemoTest extends BaseDemoTest { | ||
private String html; | ||
|
||
private ESchoolParser parser; | ||
|
||
@Before | ||
public void setUp() throws JSONException { | ||
html = readResource("/eschool/eschool.html"); | ||
SubstitutionScheduleData scheduleData = new SubstitutionScheduleData(); | ||
scheduleData.setData(new JSONObject()); | ||
parser = new ESchoolParser(scheduleData, null); | ||
} | ||
|
||
@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()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | ||
<html> | ||
|
||
<head> | ||
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> | ||
<link rel="stylesheet" type="text/css" href="./site/styles.css"> | ||
<title>eSchool Web</title> | ||
</head> | ||
|
||
<body bgcolor="#003366"> | ||
<div id="Background"> | ||
<img src="./site/images/bg.png" class="BackgroundStretch" alt=""/> | ||
</div> | ||
<div id="ContainerCenter"> | ||
<div id="Header"> | ||
</div> | ||
<div id="ContentContainer"> | ||
<div id="MenuL"> | ||
<table border="0" width="100%"> | ||
<tr> | ||
<td align="center"><b><font color="#808080">Vertretungsplan</font></b></td> | ||
</tr> | ||
<tr> | ||
<td><a href="?wp=678a65dca3d2261791675cf57fee5678&go=vplan&content=T"><img | ||
src="./site/images/vplan_mini.png" align="absmiddle"> Heute</a></td> | ||
</tr> | ||
<tr> | ||
<td><a href="?wp=678a65dca3d2261791675cf57fee5678&go=vplan&content=x1"><img | ||
src="./site/images/vplan_mini.png" align="absmiddle"> Nächster Tag</a></td> | ||
</tr> | ||
<tr> | ||
<td><a href="?wp=678a65dca3d2261791675cf57fee5678&go=vplan&content=x2"><img | ||
src="./site/images/vplan_mini.png" align="absmiddle"> Heute + 1 Tag</a></td> | ||
</tr> | ||
<tr> | ||
<td><a href="?wp=678a65dca3d2261791675cf57fee5678&go=vplan&content=x3"><img | ||
src="./site/images/vplan_mini.png" align="absmiddle"> Heute + 2 Tage</a></td> | ||
</tr> | ||
<tr> | ||
<td><a href="?wp=678a65dca3d2261791675cf57fee5678&go=vplan&content=x5"><img | ||
src="./site/images/vplan_mini.png" align="absmiddle"> Heute + 4 Tage</a></td> | ||
</tr> | ||
<tr> | ||
<td><a href="?wp=678a65dca3d2261791675cf57fee5678&go=vplan&content=x7"><img | ||
src="./site/images/vplan_mini.png" align="absmiddle"> Heute + 6 Tage</a></td> | ||
</tr> | ||
<tr> | ||
<td><a href="?wp=678a65dca3d2261791675cf57fee5678&go=vplan&content=x14"><img | ||
src="./site/images/vplan_mini.png" align="absmiddle"> Heute + 13 Tage</a></td> | ||
</tr> | ||
</table> | ||
</div><!-- MenuL --> | ||
<div id="MinHeight"> | ||
</div><!-- MinHeight --> | ||
<div id="Content"> | ||
<table border="0" width="100%" height="55"> | ||
<tr> | ||
<td width="48"><img src="./site/images/vplan.gif"></td> | ||
<td> | ||
<b><font size="5">Vertretungsplan für 05.09.2016 bis 22.09.2016</font></b><br/>Letzte | ||
Aktualisierung: 04.09.2016 - 14:53, Vertretungsplanmodus: Davinci 6 HTML | ||
</td> | ||
</tr> | ||
</table> | ||
<br> | ||
<form name="vplanmenu" id="vplanmenu" method="GET" | ||
action="?wp=678a65dca3d2261791675cf57fee5678&content=x14"> | ||
<input type="hidden" name="wp" value="678a65dca3d2261791675cf57fee5678"> | ||
<input type="hidden" name="go" value="vplan"> | ||
<input type="hidden" name="content" value="x14"> | ||
<table border="1" width="100%" bgcolor="#D1E7FC" bordercolor="#92C5F8" cellspacing="0" height="25"> | ||
<tr> | ||
<td align="left" valign="baseline"> | ||
<img src="./site/images/sortieren.png" align="absmiddle"><font size="2"> Sortieren | ||
nach:</a> | ||
<select size="1" name="sortby" align="middle" onchange="document.vplanmenu.submit();"> | ||
<option value="K">Klassen</option> | ||
<option value="L">Lehrer</option> | ||
<option value="S" selected>Stunden</option> | ||
</select> | ||
</td> | ||
</tr> | ||
</table> | ||
</form> | ||
<br> | ||
<hr> | ||
<center><b>Montag, den 05.09.2016</b></center> | ||
<hr> | ||
<table id="DATA" border="1" width="100%"> | ||
<th colspan="10" align="left"><br> | ||
1. Stunde - Montag, den 05.09. | ||
</th> | ||
<tr> | ||
<td bgcolor="#BBDDFF" align="center"><b>KLASSE(N)</b></td> | ||
<td bgcolor="#BBDDFF" align="center"><b>LEHRER</b></td> | ||
<td bgcolor="#BBDDFF" align="center"><b>FACH</b></td> | ||
<td bgcolor="#BBDDFF" align="center"><b>RAUM</b></td> | ||
<td bgcolor="#BBDDFF" align="center"><b>INFO</b></td> | ||
</tr> | ||
<tr> | ||
<td>05e</td> | ||
<td nowrap>KIR <img src="./site/images/to.png" align="absmiddle"> SEI</td> | ||
<td nowrap>EN</td> | ||
<td nowrap>163_M</td> | ||
<td nowrap></td> | ||
</tr> | ||
<tr> | ||
<td>11</td> | ||
<td nowrap>IPS</td> | ||
<td nowrap>sek1</td> | ||
<td nowrap>EKS2_217_S</td> | ||
<td nowrap>Klasse frei</td> | ||
</tr> | ||
<tr> | ||
<td>13</td> | ||
<td nowrap>WEN</td> | ||
<td nowrap>BI2</td> | ||
<td nowrap>BIS2_305_M</td> | ||
<td nowrap>Klasse frei</td> | ||
</tr> | ||
<th colspan="10" align="left"><br> | ||
2. Stunde - Montag, den 05.09. | ||
</th> | ||
<tr> | ||
<td bgcolor="#BBDDFF" align="center"><b>KLASSE(N)</b></td> | ||
<td bgcolor="#BBDDFF" align="center"><b>LEHRER</b></td> | ||
<td bgcolor="#BBDDFF" align="center"><b>FACH</b></td> | ||
<td bgcolor="#BBDDFF" align="center"><b>RAUM</b></td> | ||
<td bgcolor="#BBDDFF" align="center"><b>INFO</b></td> | ||
</tr> | ||
<tr> | ||
<td>05e</td> | ||
<td nowrap>KIR <img src="./site/images/to.png" align="absmiddle"> SEI</td> | ||
<td nowrap>EN</td> | ||
<td nowrap>163_M</td> | ||
<td nowrap></td> | ||
</tr> | ||
<tr> | ||
<td>13</td> | ||
<td nowrap>WEN</td> | ||
<td nowrap>BI2</td> | ||
<td nowrap>BIS2_305_M</td> | ||
<td nowrap>Klasse frei</td> | ||
</tr> | ||
<tr> | ||
<td>13</td> | ||
<td nowrap>IPS</td> | ||
<td nowrap>EK1</td> | ||
<td nowrap>EKS2_217_S</td> | ||
<td nowrap>Klasse frei</td> | ||
</tr> | ||
</table> | ||
<br> | ||
<br> | ||
|
||
</div><!-- Content --> | ||
<div id="clear"></div> | ||
</div><!-- ContentContainer --> | ||
<div id="Footer"> | ||
</div><!-- Footer --> | ||
<div id="FooterTopackt"> | ||
© 2010 - 2016 Topackt IT Solutions GmbH - Tom Dörr | ||
</div><!-- FooterTopackt --> | ||
<div id="clear"></div> | ||
</body> | ||
|
||
</html> |