|
| 1 | +package us.brianolsen.instructions; |
| 2 | + |
| 3 | +import static org.junit.Assert.assertEquals; |
| 4 | + |
| 5 | +import java.nio.file.Paths; |
| 6 | + |
| 7 | +import org.junit.Test; |
| 8 | + |
| 9 | +import com.mapbox.services.api.directions.v5.models.LegStep; |
| 10 | +import com.mapbox.services.api.directions.v5.models.StepManeuver; |
| 11 | + |
| 12 | +import us.brianolsen.instructions.util.ResourceUtil; |
| 13 | + |
| 14 | +public class OSRMTextInstructionsSimpleCompileTest extends BaseTest { |
| 15 | + protected static final String FIXTURES_DIRECTORY = Paths.get( // |
| 16 | + ResourceUtil.getNodeModuleDirectory(MODULE_NAME, MODULE_VERSION).getAbsolutePath(), // |
| 17 | + "test", "fixtures", VERSION).toString(); |
| 18 | + |
| 19 | + @Test |
| 20 | + public void testSimpleCompileCommands() { |
| 21 | + try (OSRMTextInstructions textInstructions = new OSRMTextInstructions(VERSION)) { |
| 22 | + String wayName = "Route 66"; |
| 23 | + StepManeuver maneuver = new StepManeuver("turn", "left", 1); |
| 24 | + |
| 25 | + LegStep step = new LegStep(); |
| 26 | + step.setManeuver(maneuver); |
| 27 | + step.setName(wayName); |
| 28 | + |
| 29 | + assertEquals("Turn left onto Route 66", textInstructions.compile("en", step, null)); |
| 30 | + assertEquals("Gire a la izquierda en Route 66", textInstructions.compile("es", step, null)); |
| 31 | + assertEquals("Svolta a sinistra in Route 66", textInstructions.compile("it", step, null)); |
| 32 | + assertEquals("Ga linksaf naar Route 66", textInstructions.compile("nl", step, null)); |
| 33 | + assertEquals("左转,上Route 66", textInstructions.compile("zh-Hans", step, null)); |
| 34 | + |
| 35 | + maneuver = new StepManeuver(); |
| 36 | + maneuver.setBearingAfter(340); |
| 37 | + maneuver.setType("depart"); |
| 38 | + step.setManeuver(maneuver); |
| 39 | + |
| 40 | + assertEquals("Head north on Route 66", textInstructions.compile("en", step, null)); |
| 41 | + assertEquals("Ve a norte en Route 66", textInstructions.compile("es", step, null)); |
| 42 | + assertEquals("Continua verso nord in Route 66", textInstructions.compile("it", step, null)); |
| 43 | + assertEquals("Neem Route 66 in noordelijke richting", textInstructions.compile("nl", step, null)); |
| 44 | + assertEquals("出发向北,上Route 66", textInstructions.compile("zh-Hans", step, null)); |
| 45 | + |
| 46 | + maneuver = new StepManeuver(); |
| 47 | + maneuver.setBearingAfter(152); |
| 48 | + maneuver.setType("depart"); |
| 49 | + step.setManeuver(maneuver); |
| 50 | + |
| 51 | + assertEquals("Head southeast on Route 66", textInstructions.compile("en", step, null)); |
| 52 | + assertEquals("Ve a sureste en Route 66", textInstructions.compile("es", step, null)); |
| 53 | + assertEquals("Continua verso sud-est in Route 66", textInstructions.compile("it", step, null)); |
| 54 | + assertEquals("Neem Route 66 in zuidoostelijke richting", textInstructions.compile("nl", step, null)); |
| 55 | + assertEquals("出发向东南,上Route 66", textInstructions.compile("zh-Hans", step, null)); |
| 56 | + |
| 57 | + maneuver = new StepManeuver(); |
| 58 | + maneuver.setType("fork"); |
| 59 | + maneuver.setModifier("sharp right"); |
| 60 | + step.setManeuver(maneuver); |
| 61 | + |
| 62 | + assertEquals("Take a sharp right at the fork onto Route 66", textInstructions.compile("en", step, null)); |
| 63 | + assertEquals("Gire a la derecha en el cruce en Route 66", textInstructions.compile("es", step, null)); |
| 64 | + assertEquals("Svolta a destra al bivio in Route 66", textInstructions.compile("it", step, null)); |
| 65 | + assertEquals("Rechtsaf op de splitsing naar Route 66", textInstructions.compile("nl", step, null)); |
| 66 | + assertEquals("在岔道保持向右,上Route 66", textInstructions.compile("zh-Hans", step, null)); |
| 67 | + |
| 68 | + } catch (RuntimeException e) { |
| 69 | + System.err.println(e); |
| 70 | + } |
| 71 | + } |
| 72 | + |
| 73 | +} |
0 commit comments