### Question:
FrequencyMeasurement extends BasicMeasurement { public void add(FrequencyMeasurement other) { for (String cat : d_categories) { if (getFrequency(cat) == null || other.getFrequency(cat) == null) { setFrequency(cat, null); } else { setFrequency(cat, getFrequency(cat) + other.getFrequency(cat)); } } } private  FrequencyMeasurement();  FrequencyMeasurement(PopulationCharacteristic cv);  FrequencyMeasurement(List<String> categories, Map<String, Integer> map); void setFrequency(String category, Integer freq); Integer getFrequency(String category); String[] getCategories(); void add(FrequencyMeasurement other); boolean isOfType(VariableType type); @Override Set<Entity> getDependencies(); @Override String toString(); @Override FrequencyMeasurement clone(); @Override boolean equals(Object o); @Override int hashCode(); static final String PROPERTY_FREQUENCIES; }### Answer:
@Test public void testAdd() { FrequencyMeasurement m = d_meas.clone(); d_meas.setFrequency(getCat(d_cv, 0), 25); d_meas.setFrequency(getCat(d_cv, 1), 20); m.add(d_meas); assertEquals(null, m.getFrequency(getCat(d_cv, 0))); assertEquals(null, m.getFrequency(getCat(d_cv, 1))); m = d_meas.clone(); m.add(d_meas); assertEquals(new Integer(50), m.getFrequency(getCat(d_cv, 0))); assertEquals(new Integer(40), m.getFrequency(getCat(d_cv, 1))); }