/* * 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.util; import java.util.HashMap; import static org.hamcrest.core.IsCollectionContaining.hasItems; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import org.junit.Test; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; /** * * @author serch */ @RunWith(JUnit4.class) public class TestUtils { @Test public void getDiaText(){ //dd 'de' MMMMM 'del' yyyy assertEquals("20 de abril del 2014", mx.org.cedn.avisosconagua.util.Utils.getDiaText("20/04/2014")); } @Test public void getISODate(){ //YYYY-MM-dd'T'HH:mm:ss'-06:00' assertEquals("2014-04-20T18:30:00-05:00", mx.org.cedn.avisosconagua.util.Utils.getISODate("20/04/2014 18:30")); assertEquals("2014-01-20T18:30:00-06:00", mx.org.cedn.avisosconagua.util.Utils.getISODate("20/01/2014 18:30")); } @Test public void getValidFieldFromHash(){ HashMap<String, String> map = new HashMap<>(); map.put("demoValue", "rigth"); assertEquals("rigth", mx.org.cedn.avisosconagua.util.Utils.getValidFieldFromHash(map, "demoValue")); assertEquals("", mx.org.cedn.avisosconagua.util.Utils.getValidFieldFromHash(map, "demoNoValue")); } @Test public void tokenize() { assertThat(mx.org.cedn.avisosconagua.util.Utils.tokenize("{uno}{dos}{tres}", "\\{(.*?)\\}"),hasItems("uno","dos","tres")); } //"\\{(.*?)\\}" }