test_class.declarator: thrown = ExpectedException.none()
test_class.modifier: @Rule
    public
test_class.original_string: @Rule
    public ExpectedException thrown = ExpectedException.none();
test_class.type: ExpectedException
test_class.var_name: thrown
test_class.file: osrm-text-instructions/libjava-osrm-instructions/src/test/java/org/project_osrm/instructions/TextInstructionsTest.java
test_class.identifier: TextInstructionsTest
test_class.superclass: extends BaseTest
test_case.body: @Test
    public void testFixturesMatchGeneratedInstructions() throws IOException {
      for (String fixture : TextInstructionsFixtures.FIXTURES) {
        String body = loadJsonFixture(fixture);
        FixtureModel model = new Gson().fromJson(body, FixtureModel.class);
        for (Object entry : model.getInstructions().entrySet()) {
          Map.Entry pair = (Map.Entry) entry;
          String language = (String) pair.getKey();
          String compiled = (String) pair.getValue();
          assertEquals(compiled, new TextInstructions(language, "v5").compile(model.getStep()));
        }
      }
    }
test_case.class_method_signature: TextInstructionsTest.testFixturesMatchGeneratedInstructions()
test_case.full_signature: @Test public void testFixturesMatchGeneratedInstructions()
test_case.identifier: testFixturesMatchGeneratedInstructions
test_case.invocations: loadJsonFixture fromJson entrySet getInstructions getKey getValue assertEquals compile getStep
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testFixturesMatchGeneratedInstructions()
focal_class.declarator: logger = Logger.getLogger(TextInstructions.class.getSimpleName())
focal_class.modifier: private static final
focal_class.original_string: private static final Logger logger = Logger.getLogger(TextInstructions.class.getSimpleName());
focal_class.type: Logger
focal_class.var_name: logger
focal_class.declarator: tokenizedInstructionHook
focal_class.modifier: private
focal_class.original_string: private TokenizedInstructionHook tokenizedInstructionHook;
focal_class.type: TokenizedInstructionHook
focal_class.var_name: tokenizedInstructionHook
focal_class.declarator: rootObject
focal_class.modifier: private
focal_class.original_string: private JsonObject rootObject;
focal_class.type: JsonObject
focal_class.var_name: rootObject
focal_class.declarator: versionObject
focal_class.modifier: private
focal_class.original_string: private JsonObject versionObject;
focal_class.type: JsonObject
focal_class.var_name: versionObject
focal_class.file: osrm-text-instructions/libjava-osrm-instructions/src/main/java/org/project_osrm/instructions/TextInstructions.java
focal_class.identifier: TextInstructions
focal_class.class_method_signature: TextInstructions.TextInstructions(String language, String version)
focal_class.full_signature: public  TextInstructions(String language, String version)
focal_class.identifier: TextInstructions
focal_class.modifiers: public
focal_class.parameters: (String language, String version)
focal_class.signature:  TextInstructions(String language, String version)
focal_class.class_method_signature: TextInstructions.getTokenizedInstructionHook()
focal_class.full_signature: public TokenizedInstructionHook getTokenizedInstructionHook()
focal_class.identifier: getTokenizedInstructionHook
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: TokenizedInstructionHook
focal_class.signature: TokenizedInstructionHook getTokenizedInstructionHook()
focal_class.class_method_signature: TextInstructions.setTokenizedInstructionHook(TokenizedInstructionHook tokenizedInstructionHook)
focal_class.full_signature: public void setTokenizedInstructionHook(TokenizedInstructionHook tokenizedInstructionHook)
focal_class.identifier: setTokenizedInstructionHook
focal_class.modifiers: public
focal_class.parameters: (TokenizedInstructionHook tokenizedInstructionHook)
focal_class.return: void
focal_class.signature: void setTokenizedInstructionHook(TokenizedInstructionHook tokenizedInstructionHook)
focal_class.class_method_signature: TextInstructions.getRootObject()
focal_class.full_signature: public JsonObject getRootObject()
focal_class.identifier: getRootObject
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: JsonObject
focal_class.signature: JsonObject getRootObject()
focal_class.class_method_signature: TextInstructions.getVersionObject()
focal_class.full_signature: public JsonObject getVersionObject()
focal_class.identifier: getVersionObject
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: JsonObject
focal_class.signature: JsonObject getVersionObject()
focal_class.class_method_signature: TextInstructions.capitalizeFirstLetter(String text)
focal_class.full_signature: public static String capitalizeFirstLetter(String text)
focal_class.identifier: capitalizeFirstLetter
focal_class.modifiers: public static
focal_class.parameters: (String text)
focal_class.return: String
focal_class.signature: String capitalizeFirstLetter(String text)
focal_class.class_method_signature: TextInstructions.ordinalize(Integer number)
focal_class.full_signature: public String ordinalize(Integer number)
focal_class.identifier: ordinalize
focal_class.modifiers: public
focal_class.parameters: (Integer number)
focal_class.return: String
focal_class.signature: String ordinalize(Integer number)
focal_class.class_method_signature: TextInstructions.directionFromDegree(Double degree)
focal_class.full_signature: public String directionFromDegree(Double degree)
focal_class.identifier: directionFromDegree
focal_class.modifiers: public
focal_class.parameters: (Double degree)
focal_class.return: String
focal_class.signature: String directionFromDegree(Double degree)
focal_class.class_method_signature: TextInstructions.laneConfig(LegStep step)
focal_class.full_signature: public String laneConfig(LegStep step)
focal_class.identifier: laneConfig
focal_class.modifiers: public
focal_class.parameters: (LegStep step)
focal_class.return: String
focal_class.signature: String laneConfig(LegStep step)
focal_class.class_method_signature: TextInstructions.compile(LegStep step)
focal_class.full_signature: public String compile(LegStep step)
focal_class.identifier: compile
focal_class.modifiers: public
focal_class.parameters: (LegStep step)
focal_class.return: String
focal_class.signature: String compile(LegStep step)
focal_method.body: public String compile(LegStep step) {
      if (step.getManeuver() == null) {
        throw new RuntimeException("No step maneuver provided.");
      }
  
      String type = step.getManeuver().getType();
      String modifier = step.getManeuver().getModifier();
      String mode = step.getMode();
  
      if (TextUtils.isEmpty(type)) {
        throw new RuntimeException("Missing step maneuver type.");
      }
  
      if (!type.equals("depart") && !type.equals("arrive") && TextUtils.isEmpty(modifier)) {
        throw new RuntimeException("Missing step maneuver modifier.");
      }
  
      if (getVersionObject().getAsJsonObject(type) == null) {
        // Log for debugging
        logger.log(Level.FINE, "Encountered unknown instruction type: " + type);
  
        // OSRM specification assumes turn types can be added without
        // major version changes. Unknown types are to be treated as
        // type `turn` by clients
        type = "turn";
      }
  
      // Use special instructions if available, otherwise `defaultinstruction`
      JsonObject instructionObject;
      JsonObject modeValue = getVersionObject().getAsJsonObject("modes").getAsJsonObject(mode);
      if (modeValue != null) {
        instructionObject = modeValue;
      } else {
        JsonObject modifierValue = getVersionObject().getAsJsonObject(type).getAsJsonObject(modifier);
        instructionObject = modifierValue == null
          ? getVersionObject().getAsJsonObject(type).getAsJsonObject("default")
          : modifierValue;
      }
  
      // Special case handling
      JsonPrimitive laneInstruction = null;
      switch (type) {
        case "use lane":
          laneInstruction = getVersionObject().getAsJsonObject("constants")
            .getAsJsonObject("lanes").getAsJsonPrimitive(laneConfig(step));
          if (laneInstruction == null) {
            // If the lane combination is not found, default to continue straight
            instructionObject = getVersionObject().getAsJsonObject("use lane")
              .getAsJsonObject("no_lanes");
          }
          break;
        case "rotary":
        case "roundabout":
          if (!TextUtils.isEmpty(step.getRotaryName())
            && step.getManeuver().getExit() != null
            && instructionObject.getAsJsonObject("name_exit") != null) {
            instructionObject = instructionObject.getAsJsonObject("name_exit");
          } else if (step.getRotaryName() != null && instructionObject.getAsJsonObject("name") != null) {
            instructionObject = instructionObject.getAsJsonObject("name");
          } else if (step.getManeuver().getExit() != null && instructionObject.getAsJsonObject("exit") != null) {
            instructionObject = instructionObject.getAsJsonObject("exit");
          } else {
            instructionObject = instructionObject.getAsJsonObject("default");
          }
          break;
        default:
          // NOOP, since no special logic for that type
      }
  
      // Decide way_name with special handling for name and ref
      String wayName;
      String name = TextUtils.isEmpty(step.getName()) ? "" : step.getName();
      String ref = TextUtils.isEmpty(step.getRef()) ? "" : step.getRef().split(";")[0];
  
      // Remove hacks from Mapbox Directions mixing ref into name
      if (name.equals(step.getRef())) {
        // if both are the same we assume that there used to be an empty name, with the ref being filled in for it
        // we only need to retain the ref then
        name = "";
      }
      name = name.replace(" (" + step.getRef() + ")", "");
  
      if (!TextUtils.isEmpty(name) && !TextUtils.isEmpty(ref) && !name.equals(ref)) {
        wayName = name + " (" + ref + ")";
      } else if (TextUtils.isEmpty(name) && !TextUtils.isEmpty(ref)) {
        wayName = ref;
      } else {
        wayName = name;
      }
  
      // Decide which instruction string to use
      // Destination takes precedence over name
      String instruction;
      if (!TextUtils.isEmpty(step.getDestinations())
        && instructionObject.getAsJsonPrimitive("destination") != null) {
        instruction = instructionObject.getAsJsonPrimitive("destination").getAsString();
      } else if (!TextUtils.isEmpty(wayName)
        && instructionObject.getAsJsonPrimitive("name") != null) {
        instruction = instructionObject.getAsJsonPrimitive("name").getAsString();
      } else {
        instruction = instructionObject.getAsJsonPrimitive("default").getAsString();
      }
  
      if (getTokenizedInstructionHook() != null) {
        instruction = getTokenizedInstructionHook().change(instruction);
      }
  
      // Replace tokens
      // NOOP if they don't exist
      String nthWaypoint = ""; // TODO, add correct waypoint counting
      JsonPrimitive modifierValue =
        getVersionObject().getAsJsonObject("constants").getAsJsonObject("modifier").getAsJsonPrimitive(modifier);
      instruction = instruction
        .replace("{way_name}", wayName)
        .replace("{destination}", TextUtils.isEmpty(step.getDestinations()) ? "" : step.getDestinations().split(",")[0])
        .replace("{exit_number}",
          step.getManeuver().getExit() == null ? ordinalize(1) : ordinalize(step.getManeuver().getExit()))
        .replace("{rotary_name}", TextUtils.isEmpty(step.getRotaryName()) ? "" : step.getRotaryName())
        .replace("{lane_instruction}", laneInstruction == null ? "" : laneInstruction.getAsString())
        .replace("{modifier}", modifierValue == null ? "" : modifierValue.getAsString())
        .replace("{direction}", directionFromDegree(step.getManeuver().getBearingAfter()))
        .replace("{nth}", nthWaypoint)
        .replaceAll("\\s+", " "); // remove excess spaces
  
      if (getRootObject().getAsJsonObject("meta").getAsJsonPrimitive("capitalizeFirstLetter").getAsBoolean()) {
        instruction = capitalizeFirstLetter(instruction);
      }
  
      return instruction;
    }
focal_method.class_method_signature: TextInstructions.compile(LegStep step)
focal_method.full_signature: public String compile(LegStep step)
focal_method.identifier: compile
focal_method.invocations: getManeuver getType getManeuver getModifier getManeuver getMode isEmpty equals equals isEmpty getAsJsonObject getVersionObject log getAsJsonObject getAsJsonObject getVersionObject getAsJsonObject getAsJsonObject getVersionObject getAsJsonObject getAsJsonObject getVersionObject getAsJsonPrimitive getAsJsonObject getAsJsonObject getVersionObject laneConfig getAsJsonObject getAsJsonObject getVersionObject isEmpty getRotaryName getExit getManeuver getAsJsonObject getAsJsonObject getRotaryName getAsJsonObject getAsJsonObject getExit getManeuver getAsJsonObject getAsJsonObject getAsJsonObject isEmpty getName getName isEmpty getRef split getRef equals getRef replace getRef isEmpty isEmpty equals isEmpty isEmpty isEmpty getDestinations getAsJsonPrimitive getAsString getAsJsonPrimitive isEmpty getAsJsonPrimitive getAsString getAsJsonPrimitive getAsString getAsJsonPrimitive getTokenizedInstructionHook change getTokenizedInstructionHook getAsJsonPrimitive getAsJsonObject getAsJsonObject getVersionObject replaceAll replace replace replace replace replace replace replace replace isEmpty getDestinations split getDestinations getExit getManeuver ordinalize ordinalize getExit getManeuver isEmpty getRotaryName getRotaryName getAsString getAsString directionFromDegree getBearingAfter getManeuver getAsBoolean getAsJsonPrimitive getAsJsonObject getRootObject capitalizeFirstLetter
focal_method.modifiers: public
focal_method.parameters: (LegStep step)
focal_method.return: String
focal_method.signature: String compile(LegStep step)