### Question:
MetadataWithMostRecentDate { public void createOrUpdate(String fieldName, String dataTypeOutputName, String normalizerClassName, long eventDate) { String identifier = createKey(fieldName, dataTypeOutputName, normalizerClassName); MostRecentEventDateAndKeyComponents value = mostRecentDates.get(identifier); if (null == value) { mostRecentDates.put(identifier, new MostRecentEventDateAndKeyComponents(fieldName, dataTypeOutputName, normalizerClassName, eventDate)); } else if (eventDate > value.getMostRecentDate()) { value.setMostRecentDate(eventDate); } } MetadataWithMostRecentDate(Text columnFamily); void createOrUpdate(String fieldName, String dataTypeOutputName, String normalizerClassName, long eventDate); Collection<MostRecentEventDateAndKeyComponents> entries(); void clear(); Text getColumnFamily(); static final String IGNORED_NORMALIZER_CLASS; }### Answer:
@Test public void testNoReplacement() { MetadataWithMostRecentDate counters = new MetadataWithMostRecentDate(COLUMN_FAMILY); counters.createOrUpdate(fieldName, dataTypeName, normalizerClassName, date); counters.createOrUpdate(fieldName, dataTypeName, normalizerClassName, 123L); assertOneEntryWithExpectedDate(counters, date); }
@Test public void testReplacement() { MetadataWithMostRecentDate counters = new MetadataWithMostRecentDate(COLUMN_FAMILY); counters.createOrUpdate(fieldName, dataTypeName, normalizerClassName, 123L); counters.createOrUpdate(fieldName, dataTypeName, normalizerClassName, date); assertOneEntryWithExpectedDate(counters, date); }
@Test public void testAssignments() { MetadataWithMostRecentDate counters = new MetadataWithMostRecentDate(COLUMN_FAMILY); counters.createOrUpdate(fieldName, dataTypeName, normalizerClassName, date); MetadataWithMostRecentDate.MostRecentEventDateAndKeyComponents entry = getOnlyEntry(counters); Assert.assertEquals(fieldName, entry.getFieldName()); Assert.assertEquals(dataTypeName, entry.getDataType()); Assert.assertEquals(normalizerClassName, entry.getNormalizerClassName()); Assert.assertEquals(date, entry.getMostRecentDate()); }