placemarkt / address-formatter-java

Maven package for formatting data in the OpenStreetMaps address field generated by the Nominatim API.
MIT License
7 stars 0 forks source link

Unexpected hyphen for addresses in India with no postcode #7

Closed mmmaction closed 3 weeks ago

mmmaction commented 7 months ago

Hi

I am using this great library. For the following input values with country India and no postcode provided, the outcome is not as expected and contains an unwanted hyphen (-> Pune -), see test below.

The following JUnit Test

    @Test
    void test_AddressFormatter_noPostalCode_India() throws IOException {

        var formatter = new AddressFormatter(false, false);
        String json = "{country_code: 'IN',\n"
                + "road: 'Baner',\n"
                + "city: 'Pune',\n"
                + "state: 'Maharashtra',\n"
                + "country: 'India',}";
        String formatted = formatter.format(json);

        var expected = "Baner\nPune\nMaharashtra\nIndia\n";
        assertThat(formatted, equalTo(expected));
    }

Leads to

java.lang.AssertionError: 
Expected: "Baner\nPune\nMaharashtra\nIndia\n"
     but: was "Baner\nPune -\nMaharashtra\nIndia\n"
rkoeze commented 1 month ago

Thanks for reporting this @mmmaction and apologies for the delayed response. I became a father recently and have been adjusting to a new set of priorities! I have more bandwidth now and will take a look.

rkoeze commented 3 weeks ago

@mmmaction this has been fixed in release v0.0.12. Thank you for the bug report!