UntisInfoParser extends UntisCommonParser { @NotNull static String getScheduleUrl(String week, int number, JSONObject data) throws JSONException { String paddedNumber = String.format("%05d", number); String baseUrl = data.optString(PARAM_SCHEDULE_BASEURL, data.getString(PARAM_BASEURL) + "/"); String letter = getLetter(data); String url; if (data.optBoolean(PARAM_W_AFTER_NUMBER, data.optBoolean("w_after_number", false))) { url = baseUrl + week + "/" + letter + "/" + letter + paddedNumber + ".htm"; } else { url = baseUrl + letter + "/" + week + "/" + letter + paddedNumber + ".htm"; } return url; } UntisInfoParser(SubstitutionScheduleData scheduleData, CookieProvider cookieProvider); @Override SubstitutionSchedule getSubstitutionSchedule(); @Override List<String> getAllClasses(); @Override List<String> getAllTeachers(); static final String PARAM_BASEURL; static final String PARAM_CLASS_SELECT_REGEX; static final String PARAM_REMOVE_NON_MATCHING_CLASSES; static final String PARAM_W_AFTER_NUMBER; }
@Test public void testGetScheduleUrl() throws Exception { final JSONObject data = new JSONObject(); data.put(UntisInfoParser.PARAM_BASEURL, "http: assertEquals("http: data.put(UntisInfoParser.PARAM_W_AFTER_NUMBER, true); assertEquals("http: }