Java tutorial
/* * Splat Companion - Stage rotation schedule viewer for Splatoon(tm) * Copyright (C) 2015 Baptiste Candellier * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package fr.outadev.splatcompanion; import android.app.Application; import android.test.ApplicationTestCase; import org.json.JSONException; import java.util.List; import fr.outadev.splatcompanion.model.Schedule; /** * <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a> */ public class ApplicationTest extends ApplicationTestCase<Application> { public ApplicationTest() { super(Application.class); } public void testParseNormalSchedule() throws JSONException { String rawJson = "{\"updateTime\":1440151275135,\"schedule\":[{\"startTime\":1440151200000,\"endTime\":1440165600000,\"regular\":{\"maps\":[{\"nameJP\":\"?\",\"nameEN\":\"Bluefin Depot\"},{\"nameJP\":\"?\",\"nameEN\":\"Flounder Heights\"}]},\"ranked\":{\"maps\":[{\"nameJP\":\"\",\"nameEN\":\"Camp Triggerfish\"},{\"nameJP\":\"?\",\"nameEN\":\"Flounder Heights\"}],\"rulesJP\":\"?\",\"rulesEN\":\"Tower Control\"}},{\"startTime\":1440165600000,\"endTime\":1440180000000,\"regular\":{\"maps\":[{\"nameJP\":\"\",\"nameEN\":\"Urchin Underpass\"},{\"nameJP\":\"?\",\"nameEN\":\"Flounder Heights\"}]},\"ranked\":{\"maps\":[{\"nameJP\":\"?\",\"nameEN\":\"Moray Towers\"},{\"nameJP\":\"?\",\"nameEN\":\"Flounder Heights\"}],\"rulesJP\":\"?\",\"rulesEN\":\"Rainmaker\"}},{\"startTime\":1440180000000,\"endTime\":1440194400000,\"regular\":{\"maps\":[{\"nameJP\":\"?\",\"nameEN\":\"Walleye Warehouse\"},{\"nameJP\":\"?\",\"nameEN\":\"Flounder Heights\"}]},\"ranked\":{\"maps\":[{\"nameJP\":\"?\",\"nameEN\":\"Port Mackerel\"},{\"nameJP\":\"?\",\"nameEN\":\"Flounder Heights\"}],\"rulesJP\":\"?\",\"rulesEN\":\"Splat Zones\"}}]}"; List<Schedule> schedules = StageRotationUpdater.parseSchedules(rawJson); assertNotNull(schedules); assertEquals(3, schedules.size()); } public void testParseEmptySchedule() throws JSONException { String rawJson = "{\"updateTime\":1440242244200,\"schedule\":[]}"; List<Schedule> schedules = StageRotationUpdater.parseSchedules(rawJson); assertNotNull(schedules); assertEquals(0, schedules.size()); } }