### Question:
Stats { public void addStatistics(Stats stats) { for (String pathKey : stats.getStatisticKeys()) { for (String type : stats.getStatisticTypes()){ if (!this.statTypes.containsKey(type)) { this.statTypes.put(type,stats.statTypes.get(type)); } } if (this.stats.containsKey(pathKey)) { for (Entry<String, Double> stat : stats.getStatistics(pathKey).entrySet()){ this.stats.get(pathKey).putIfAbsent(stat.getKey(),stat.getValue()); } } else { LinkedHashMap<String, Double> hm = new LinkedHashMap<String,Double>(); this.stats.put(pathKey,hm); for (String st : this.getStatisticTypes()){ this.stats.get(pathKey).put(this.getStatisticType(st).getKey(), 0.0); } for (Entry<String, Double> stat : stats.getStatistics(pathKey).entrySet()){ this.stats.get(pathKey).put(stat.getKey(),stat.getValue()); } } } }  void putStatisticType(Stat stat); Stat getStatisticType(String key); Set<String> getStatisticTypes(); Set<String> getStatisticKeys(); LinkedHashMap<String,Double> getStatistics(String group, String scenario, String step); LinkedHashMap<String,Double> getStatistics(String group, String scenario); LinkedHashMap<String,Double> getStatistics(String groupOrKey); Double getStatistic(String name,String group, String scenario, String step); Double getStatistic(String name,String group, String scenario); Double getStatistic(String name,String groupOrKey); void putStatistic(String name, Double value, String group, String scenario, String step); void putStatistic(String name,Double value, String group, String scenario); void putStatistic(String name,Double value,String groupOrKey); void putKey(String group, String scenario, String step); void putKey(String group, String scenario); void putKey(String groupOrKey); void addStatistics(Stats stats); boolean isEmpty(); static String SEP; }### Answer:
@Test public void testAddStatistics() { Stats fstats = new Stats(); fstats.putStatisticType(Stats.StatType.PASSED.type); fstats.putStatisticType(Stats.StatType.FAILED.type); fstats.putKey("grp","scn"); fstats.putKey("grp"); Stats stats = new Stats(); stats.addStatistics(fstats); LinkedHashMap<String,Double> result =stats.getStatistics("grp", "scn"); int i = 0; for (Entry<String, Double> set : result.entrySet()) { if (i==0) assertEquals("pass",set.getKey()); else assertEquals("fail",set.getKey()); i++; } LinkedHashMap<String,Double> result2 =stats.getStatistics("grp"); i = 0; for (Entry<String, Double> set : result2.entrySet()) { if (i==0) assertEquals("pass",set.getKey()); else assertEquals("fail",set.getKey()); i++; } }