### Question:
NeedlemanWunschEditDistance { public static int getEditDistance( String source, String target, boolean caseSensitive, int changeCost, int openGapCost, int continueGapCost) { if (!caseSensitive) { source = Ascii.toLowerCase(source); target = Ascii.toLowerCase(target); } int sourceLength = source.length(); int targetLength = target.length(); if (sourceLength == 0) { return scriptCost(openGapCost, continueGapCost, targetLength); } if (targetLength == 0) { return scriptCost(openGapCost, continueGapCost, sourceLength); } int[][] mMatrix = new int[sourceLength + 1][targetLength + 1]; int[][] dMatrix = new int[sourceLength + 1][targetLength + 1]; int[][] iMatrix = new int[sourceLength + 1][targetLength + 1]; mMatrix[0][0] = dMatrix[0][0] = iMatrix[0][0] = 0; for (int i = 1; i <= sourceLength; i++) { mMatrix[i][0] = dMatrix[i][0] = scriptCost(openGapCost, continueGapCost, i); iMatrix[i][0] = Integer.MAX_VALUE / 2; } for (int j = 1; j <= targetLength; j++) { mMatrix[0][j] = iMatrix[0][j] = scriptCost(openGapCost, continueGapCost, j); dMatrix[0][j] = Integer.MAX_VALUE / 2; } for (int i = 1; i <= sourceLength; i++) { char sourceI = source.charAt(i - 1); for (int j = 1; j <= targetLength; j++) { char targetJ = target.charAt(j - 1); int cost = (sourceI == targetJ) ? 0 : changeCost; mMatrix[i][j] = cost + Ints.min(mMatrix[i - 1][j - 1], iMatrix[i - 1][j - 1], dMatrix[i - 1][j - 1]); dMatrix[i][j] = Math.min( mMatrix[i - 1][j] + openGapCost + continueGapCost, dMatrix[i - 1][j] + continueGapCost); iMatrix[i][j] = Math.min( mMatrix[i][j - 1] + openGapCost + continueGapCost, iMatrix[i][j - 1] + continueGapCost); } } int costOfEditScriptEndingWithMatch = mMatrix[sourceLength][targetLength]; int costOfEditScriptEndingWithDelete = dMatrix[sourceLength][targetLength]; int costOfEditScriptEndingWithInsert = iMatrix[sourceLength][targetLength]; return Ints.min( costOfEditScriptEndingWithMatch, costOfEditScriptEndingWithDelete, costOfEditScriptEndingWithInsert); } private  NeedlemanWunschEditDistance(); static int getEditDistance(
      String source,
      String target,
      boolean caseSensitive,
      int changeCost,
      int openGapCost,
      int continueGapCost); static int getWorstCaseEditDistance(
      int sourceLength, int targetLength, int changeCost, int openGapCost, int continueGapCost); static double getNormalizedEditDistance(
      String source,
      String target,
      boolean caseSensitive,
      int changeCost,
      int openGapCost,
      int continueGapCost);  }### Answer:
@Test public void needlemanWunschEditDistance_returnsZero_withIdenticalNames() { String identifier = "foo"; double distance = NeedlemanWunschEditDistance.getEditDistance( identifier, identifier, false, 1, 1, 10); assertThat(distance).isEqualTo(0.0); }
@Test public void needlemanWunschEditDistance_matchesLevenschtein_withHugeGapCost() { String identifier = "fooBar"; String otherIdentifier = "bazQux"; double levenschtein = LevenshteinEditDistance.getEditDistance(identifier, otherIdentifier); double needlemanWunsch = NeedlemanWunschEditDistance.getEditDistance( identifier, otherIdentifier, false, 1, 1000, 1000); assertThat(needlemanWunsch).isEqualTo(levenschtein); }