### Question:
VersionsMapUtils { public static boolean checkAndUpdateVersions(Map<String, Long> versionsMap, String versionKey, Long version) { while (true) { Long oldValue = versionsMap.get(versionKey); if (oldValue == null) { if (versionsMap.putIfAbsent(versionKey, version) == null) { return true; } } else { if (version > oldValue) { if (versionsMap.replace(versionKey, oldValue, version)) { return true; } } else { return false; } } } }  static boolean checkAndUpdateVersions(Map<String, Long> versionsMap, String versionKey,
                                                 Long version);  }### Answer:
@Test public void doTest() { Map<String, Long> versionsMap = new HashMap<>(); Assert.assertTrue(VersionsMapUtils.checkAndUpdateVersions(versionsMap, "mockDataInfoId", 20L)); Assert.assertTrue(new VersionsMapUtils().checkAndUpdateVersions(versionsMap, "mockDataInfoId", 30L)); Assert.assertFalse(new VersionsMapUtils().checkAndUpdateVersions(versionsMap, "mockDataInfoId", 10L)); }