### Question:
LongObjectNamesResolver { public synchronized String resolveObjectFileName(final String fullLengthName) { if (fullLengthName.length() > 100) { return resolveLongName(fullLengthName); } else { return fullLengthName; } }  synchronized String resolveObjectFileName(final String fullLengthName);  }### Answer:
@Test void testSmallNamesJustPass() { String shortName = "aShortName"; String resolvedFileName = resolver.resolveObjectFileName(shortName); assertEquals(shortName, resolvedFileName); }
@Test void testLongNameIsShortened() { String longObjectName = "veryVeryVeryLongNameThatIsLongerThan100CharactersIsExpectedToBeShortenedByLongObjectNamesResolverSuchThatFileNamesDoNotBecomeTooLong"; String resolvedFileName = resolver.resolveObjectFileName(longObjectName); assertEquals( "veryVeryVeryLongNameThatIsLongerThan100CharactersIsExpectedToBeShortenedByLongObjectNamesResolverSuc-0", resolvedFileName, "Expected shortened name with suffix of collision index (0 for no collision yet)"); }
@Test void testLongNamesResolvedCorrectly() { String longObjectName1 = "veryVeryVeryLongNameThatIsLongerThan100CharactersIsExpectedToBeShortenedByLongObjectNamesResolverSuchThatFileNamesDoNotBecomeTooLongOne"; String longObjectName2 = "veryVeryVeryLongNameThatIsLongerThan100CharactersIsExpectedToBeShortenedByLongObjectNamesResolverSuchThatFileNamesDoNotBecomeTooLongTwo"; String resolvedFileName1_firstCall = resolver.resolveObjectFileName(longObjectName1); String resolvedFileName2_firstCall = resolver.resolveObjectFileName(longObjectName2); String resolvedFileName1_secondCall = resolver.resolveObjectFileName(longObjectName1); String resolvedFileName2_secondCall = resolver.resolveObjectFileName(longObjectName2); assertEquals( "veryVeryVeryLongNameThatIsLongerThan100CharactersIsExpectedToBeShortenedByLongObjectNamesResolverSuc-0", resolvedFileName1_firstCall, "Expected shortened name with suffix of collision index (0 for no collision yet)"); assertEquals( "veryVeryVeryLongNameThatIsLongerThan100CharactersIsExpectedToBeShortenedByLongObjectNamesResolverSuc-1", resolvedFileName2_firstCall, "Expected shortened name with suffix of collision index (1 for first collision)"); assertEquals( resolvedFileName1_firstCall, resolvedFileName1_secondCall, "Expected same shortened name for calling resolver twice for same long name."); assertEquals( resolvedFileName2_firstCall, resolvedFileName2_secondCall, "Expected same shortened name for calling resolver twice for same long name."); }