### Question:
HealthStatsMetrics extends SystemMetrics<HealthStatsMetrics> { @VisibleForTesting static <K, V> ArrayMap<K, V> opArrayMaps(int op, ArrayMap<K, V> a, @Nullable ArrayMap<K, V> b) { int aSize = a.size(); ArrayMap<K, V> output = new ArrayMap<>(); for (int i = 0; i < aSize; i++) { K key = a.keyAt(i); V bValue = b == null ? null : b.get(key); output.put(key, bValue == null ? a.valueAt(i) : (V) opValues(op, a.valueAt(i), bValue)); } if (op == OP_SUM) { int bSize = b == null ? 0 : b.size(); for (int i = 0; i < bSize; i++) { K key = b.keyAt(i); if (a.get(key) == null) { output.put(key, b.valueAt(i)); } } } return output; } HealthStatsMetrics();  HealthStatsMetrics(HealthStats healthStats);  HealthStatsMetrics(HealthStatsMetrics metrics); @Override HealthStatsMetrics sum(
      @Nullable HealthStatsMetrics b, @Nullable HealthStatsMetrics output); @Override HealthStatsMetrics diff(
      @Nullable HealthStatsMetrics b, @Nullable HealthStatsMetrics output); @Override HealthStatsMetrics set(HealthStatsMetrics b); HealthStatsMetrics set(HealthStats healthStats); @Override String toString(); static String getKeyName(int key); JSONObject toJSONObject(); @Override boolean equals(Object o); @Override int hashCode(); public String dataType; final SparseArray<Long> measurement; final SparseArray<TimerMetrics> timer; final SparseArray<ArrayMap<String, Long>> measurements; final SparseArray<ArrayMap<String, TimerMetrics>> timers; final SparseArray<ArrayMap<String, HealthStatsMetrics>> stats; }### Answer:
@Test public void testSumArrayMaps() { ArrayMap<String, Long> a = new ArrayMap<>(); a.put("a", 1L); a.put("c", 2L); ArrayMap<String, Long> b = new ArrayMap<>(); b.put("b", 1L); b.put("c", 3L); ArrayMap<String, Long> sum = HealthStatsMetrics.opArrayMaps(OP_SUM, a, b); assertThat(sum.get("a")).isEqualTo(1); assertThat(sum.get("b")).isEqualTo(1); assertThat(sum.get("c")).isEqualTo(5); assertThat(sum.size()).isEqualTo(3); }
@Test public void testDiffArrayMaps() { ArrayMap<String, Long> a = new ArrayMap<>(); a.put("a", 1L); a.put("c", 2L); ArrayMap<String, Long> b = new ArrayMap<>(); b.put("b", 1L); b.put("c", 3L); ArrayMap<String, Long> sum = HealthStatsMetrics.opArrayMaps(OP_DIFF, a, b); assertThat(sum.get("a")).isEqualTo(1); assertThat(sum.get("c")).isEqualTo(-1); assertThat(sum.size()).isEqualTo(2); }