/*
 * substitution-schedule-parser - Java library for parsing schools' substitution schedules
 * Copyright (c) 2017 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.exception.CredentialInvalidException;
import me.vertretungsplan.objects.SubstitutionSchedule;
import me.vertretungsplan.objects.SubstitutionScheduleData;
import org.json.JSONException;
import org.json.JSONObject;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.junit.Before;
import org.junit.Test;

import java.io.IOException;
import java.util.ArrayList;

import static org.junit.Assert.assertEquals;

public class UntisInfoDemoTest extends BaseDemoTest {
    private Document doc;
    private UntisInfoParser parser;
    private SubstitutionScheduleData scheduleData;

    @Before
    public void setUp() throws JSONException {
        doc = Jsoup.parse(readResource("/untis-info/schedule1.html"));
        scheduleData = new SubstitutionScheduleData();
        scheduleData.setData(new JSONObject("{\"classesSeparated\": true }"));
        scheduleData.setType(SubstitutionSchedule.Type.STUDENT);
        parser = new UntisInfoParser(scheduleData, null);
    }

    @Test
    public void demoTest() throws IOException, JSONException, CredentialInvalidException {
        SubstitutionSchedule schedule = SubstitutionSchedule.fromData(scheduleData);
        parser.parseSubstitutionDays(schedule, "29.06.2017 12:10", doc, null, new ArrayList<String>());
        assertEquals(2, schedule.getDays().size());
        assertEquals(31, schedule.getDays().get(0).getSubstitutions().size());
        assertEquals(24, schedule.getDays().get(1).getSubstitutions().size());
    }
}

@@ -1715,32 +1715,209 @@
 Days().size());%0A
+        if (schedule.getDays().get(0).getSubstitutions().size() == 31) %7B%0A            assertEquals(24, schedule.getDays().get(1).getSubstitutions().size());%0A        %7D else %7B%0A    
         assertEq
@@ -1940,33 +1940,33 @@
 e.getDays().get(
-0
+1
 ).getSubstitutio
@@ -1971,32 +1971,36 @@
 ions().size());%0A
+    
         assertEq
@@ -2023,33 +2023,33 @@
 e.getDays().get(
-1
+0
 ).getSubstitutio
@@ -2058,20 +2058,30 @@
 ().size());%0A
+        %7D%0A
     %7D%0A%7D%0A

Fix UntisInfoDemoTest