Package org.opentripplanner.graph_builder.impl.osm

Source Code of org.opentripplanner.graph_builder.impl.osm.TestTemplateLibrary

/* This program is free software: you can redistribute it and/or
modify it under the terms of the GNU Lesser 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 org.opentripplanner.graph_builder.impl.osm;

import java.util.HashMap;
import java.util.Map;

import junit.framework.TestCase;

import org.opentripplanner.openstreetmap.model.OSMWithTags;

/**
* @author laurent
*/
public class TestTemplateLibrary extends TestCase {

    public void testTemplate() {
        OSMWithTags osmTags = new OSMWithTags();
        osmTags.addTag("note", "Note EN");
        osmTags.addTag("description:fr", "Description FR");
        osmTags.addTag("wheelchair:description", "Wheelchair description EN");
        osmTags.addTag("wheelchair:description:fr", "Wheelchair description FR");

        assertEquals(null, TemplateLibrary.generate(null, osmTags));
        assertEquals("", TemplateLibrary.generate("", osmTags));
        assertEquals("Static text", TemplateLibrary.generate("Static text", osmTags));
        assertEquals("Note: Note EN", TemplateLibrary.generate("Note: {note}", osmTags));
        assertEquals("Inexistant: ",
                TemplateLibrary.generate("Inexistant: {foobar:description}", osmTags));
        assertEquals("Wheelchair note: Wheelchair description EN",
                TemplateLibrary.generate("Wheelchair note: {wheelchair:description}", osmTags));

        assertEquals(null, TemplateLibrary.generateI18N(null, osmTags, "en"));
        Map<String, String> expected = new HashMap<>();

        expected.put("en", "");
        assertEquals(expected, TemplateLibrary.generateI18N("", osmTags, "en"));

        expected.clear();
        expected.put("en", "Note: Note EN");
        assertEquals(expected, TemplateLibrary.generateI18N("Note: {note}", osmTags, "en"));

        expected.clear();
        expected.put("fr", "Note: Note EN");
        assertEquals(expected, TemplateLibrary.generateI18N("Note: {note}", osmTags, "fr"));

        expected.clear();
        expected.put("fr", "Desc: Description FR");
        assertEquals(expected, TemplateLibrary.generateI18N("Desc: {description}", osmTags, "fr"));

        expected.clear();
        expected.put("en", "Note: Note EN, Wheelchair description EN");
        expected.put("fr", "Note: Note EN, Wheelchair description FR");
        assertEquals(expected, TemplateLibrary.generateI18N(
                "Note: {note}, {wheelchair:description}", osmTags, "en"));

        expected.clear();
        expected.put("fr", "Note: Note EN, Wheelchair description FR, ");
        assertEquals(expected, TemplateLibrary.generateI18N(
                "Note: {note}, {wheelchair:description}, {foobar:description}", osmTags, "fr"));

    }

}
TOP

Related Classes of org.opentripplanner.graph_builder.impl.osm.TestTemplateLibrary

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.