### Question:
ShortcutHelper { public String getPart(final String text, final int part) { if (part < 1) { throw new RuntimeException("The first part is the number one."); } int beginIndex = 0; if (part > 1) { final int i = part - 2; final String s = "{" + i + "}"; beginIndex = text.indexOf(s); if (beginIndex < 0) { throw new RuntimeException("The translation " + text + " is missing parameters."); } else { beginIndex += String.valueOf(i).length() + 2; } } final int i2 = part - 1; final String s2 = "{" + i2 + "}"; int endIndex = text.indexOf(s2); if (endIndex < 0) { endIndex = text.length(); } return text.substring(beginIndex, endIndex); } ShortcutHelper(); @Inject  ShortcutHelper(final AuthorizationManager authorizationManager,
                          final User user,
                          final PlaceManager placeManager); String getPart(final String text,
                          final int part); void goTo(final String perspectiveIdentifier); boolean authorize(final String perspective); boolean authorize(final HomeShortcut shortcut);  }### Answer:
@Test(expected = RuntimeException.class) public void partLessThanOneTest() { shortcutHelper.getPart("text", 0); }
@Test(expected = RuntimeException.class) public void nonexistentSecondPartTest() { shortcutHelper.getPart("text", 2); }
@Test(expected = RuntimeException.class) public void nonexistentThirdPartTest() { shortcutHelper.getPart("text{0}more-text", 3); }
@Test public void onlyOnePartTest() { final String text = "first-part"; final String firstPart = shortcutHelper.getPart(text, 1); assertEquals("first-part", firstPart); }
@Test public void threeValidPartsTest() { final String text = "first-part{0}second-part{1}third-part"; final String firstPart = shortcutHelper.getPart(text, 1); assertEquals("first-part", firstPart); final String secondPart = shortcutHelper.getPart(text, 2); assertEquals("second-part", secondPart); final String thirdPart = shortcutHelper.getPart(text, 3); assertEquals("third-part", thirdPart); }