/* * The MIT License (MIT) * * Copyright (c) 2014 México Abierto * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * * For more information visit https://github.com/mxabierto/avisos. */ package mx.org.cedn.avisosconagua.mongo; import com.mongodb.BasicDBObject; import com.mongodb.util.JSON; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; /** * * @author serch */ @RunWith(JUnit4.class) public class TestStatistics { BasicDBObject aviso; @Before public void prepare(){ aviso = (BasicDBObject)JSON.parse("{\n" + " \"init\" : {\n" + " \"issueLocalTime\" : \"18:00 hrs (00:00 GMT)\",\n" + " \"eventDistance\" : \"A 225 km al norte de Cancún\",\n" + " \"eventWindSpeedSust\" : \"55\",\n" + " \"eventCLat\" : \"15.7\",\n" + " \"eventCLon\" : \"101.3\",\n" + " \"eventWindSpeedMax\" : \"75\",\n" + " \"eventCurrentPath\" : \"Noroeste (320) a 6 km/h\",\n" + " },\n" + " \"capInfo\" : {\n" + " \"eventCategory\" : \"TT\",\n" + " \"issueNumber\" : \"5\",\n" + " \"issueDate\" : \"16/05/2014\",\n" + " }\n" + "}\n" + ""); } @Test public void statistics(){ mx.org.cedn.avisosconagua.mongo.Statistics stat = new mx.org.cedn.avisosconagua.mongo.Statistics(aviso); System.out.println("res: "+stat.toString()); Assert.assertEquals("{\"aviso\":\"5\",\"fecha\":\"16 may / 18:00\",\"latitud\":\"15.7\"," + "\"longitud\":\"101.3\",\"distancia\":\"A 225 km al norte de Cancún\"," + "\"viento\":\"55 / 75\",\"categoria\":\"TT\",\"avance\":\"Noroeste (320) a 6 km/h\"}",stat.toString()); } }