Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java

Looks Like the space is messing me up??

I'm getting the right output for my code but there seems to be an extra space than what the Gradle prepareSubmission task is looking for? The test result is saying

java.lang.AssertionError: 
Expected: iterable containing ["First is $1.00 (USD) which is $15,48 (Argentine Peso)", "Second is $2.00 (USD) which is $30,96 (Argentine Peso)"]
     but: item 0: was "First is $1.00 (USD) which is $15.48 (Argentine Peso)"

Here's my code:

  public static List<String> getPricesConvertedForArgentina(List<HousingRecord> records) 

{
    Locale argLocale = Locale.forLanguageTag("es-AR");
    // This fluctuates and is hardcoded temporarily
    BigDecimal argPesoToUsdRate = new BigDecimal("15.48");

    // TODO: These functions are in working order, but separately they don't match the single Function signature expected
    Function<Integer, BigDecimal> usdToArgentinePesoConverter = usd -> argPesoToUsdRate.multiply(new BigDecimal(usd));

    Function<BigDecimal, String> argentineCurrencyFormatter = price -> {
      Currency currentCurrency = Currency.getInstance(argLocale);
      NumberFormat currencyFormatter =
        NumberFormat.getCurrencyInstance(argLocale);
      return String.format("%s (%s)",
        currencyFormatter.format(price),
        currentCurrency.getDisplayName()
      );
    };

    Function<Integer, String> argConvertAndFormat = usdToArgentinePesoConverter.andThen(argentineCurrencyFormatter);

    return getConvertedPriceStatements(records,
      // TODO: Correct this.  It should to convert AND format.  However, there is room parameter wise for only one Function...hmmm.
      argConvertAndFormat.andThen(
        homeValueIndex -> homeValueIndex
      )
    );
Caleb Kleveter
Caleb Kleveter
Treehouse Moderator 37,862 Points

Hey William. I would like to help you, but I haven't used Java in a while. One thing I did notice in your error though: The expected pesos was $15,48, but it got $15.48. One has a comma, the other has a period or decimal. Hope that helps!

My bad, that was my work around code, this was the output from the testSubmission originally

java.lang.AssertionError: Expected: iterable containing ["First is $1.00 (USD) which is $15,48 (Argentine Peso)", "Second is $2.00 (USD) which is $30,96 (Argentine Peso)"] but: item 0: was "First is $1.00 (USD) which is $ 15,48 (Argentine Peso)"

Tonnie Fanadez
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Tonnie Fanadez
UX Design Techdegree Graduate 22,796 Points

William Daugherty gosh I have been sitting here for hours now trying to figure this out. Anyway on your original output the expected value is $15.48 but the output value is $ 15.48 . getting the same error and I am stuck. Did you Eventually pass this challenge?