StringWidgetUtils { public static StringData getStringNumberData(String answer, FormEntryPrompt prompt) { if (WidgetAppearanceUtils.useThousandSeparator(prompt)) { answer = ThousandsSeparatorTextWatcher.getOriginalString(answer); } if (answer.isEmpty()) { return null; } else { try { return new StringData(answer); } catch (Exception numberFormatException) { return null; } } } private  StringWidgetUtils(); @SuppressFBWarnings("BX_UNBOXING_IMMEDIATELY_REBOXED") static Integer getIntegerAnswerValueFromIAnswerData(IAnswerData dataHolder); @SuppressFBWarnings({"BX_UNBOXING_IMMEDIATELY_REBOXED", "BX_UNBOXED_AND_COERCED_FOR_TERNARY_OPERATOR"}) static Double getDoubleAnswerValueFromIAnswerData(IAnswerData dataHolder); static IntegerData getIntegerData(String answer, FormEntryPrompt prompt); static DecimalData getDecimalData(String answer, FormEntryPrompt prompt); static StringData getStringNumberData(String answer, FormEntryPrompt prompt); static void adjustEditTextAnswerToIntegerWidget(EditText answerText, FormEntryPrompt prompt); static void adjustEditTextAnswerToDecimalWidget(EditText answerText, FormEntryPrompt prompt); static void adjustEditTextAnswerToStringNumberWidget(EditText answerText, FormEntryPrompt prompt);  }
@Test public void getStringNumberDataTest() { when(formEntryPrompt.getAppearanceHint()).thenReturn(null); assertNull(StringWidgetUtils.getDecimalData("", formEntryPrompt)); assertEquals("0", StringWidgetUtils.getStringNumberData("0", formEntryPrompt).getDisplayText()); assertEquals("50", StringWidgetUtils.getStringNumberData("50", formEntryPrompt).getDisplayText()); assertEquals("7.75", StringWidgetUtils.getStringNumberData("7.75", formEntryPrompt).getDisplayText()); assertEquals("-22.123", StringWidgetUtils.getStringNumberData("-22.123", formEntryPrompt).getDisplayText()); }