### Question:
AppWakeupMetrics extends SystemMetrics<AppWakeupMetrics> { @Override public AppWakeupMetrics diff(@Nullable AppWakeupMetrics b, @Nullable AppWakeupMetrics output) { if (output == null) { output = new AppWakeupMetrics(); } if (b == null) { output.set(this); } else { output.appWakeups.clear(); for (int i = 0; i < appWakeups.size(); i++) { String tag = appWakeups.keyAt(i); output.appWakeups.put(tag, new WakeupDetails(appWakeups.valueAt(i).reason)); appWakeups.valueAt(i).diff(b.appWakeups.get(tag), output.appWakeups.get(tag)); } } return output; }  @Override AppWakeupMetrics set(AppWakeupMetrics metrics); @Override AppWakeupMetrics sum(@Nullable AppWakeupMetrics b, @Nullable AppWakeupMetrics output); @Override AppWakeupMetrics diff(@Nullable AppWakeupMetrics b, @Nullable AppWakeupMetrics output); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); JSONArray toJSON(); public SimpleArrayMap<String, WakeupDetails> appWakeups; }### Answer:
@Test @Override public void testDiff() throws Exception { AppWakeupMetrics a = getAppWakeupMetrics(7, 5); AppWakeupMetrics b = getAppWakeupMetrics(4, 10); AppWakeupMetrics output = new AppWakeupMetrics(); b.diff(a, output); assertThat(output.appWakeups.size()).isEqualTo(4); verifyKeyAndReason(output.appWakeups); verifyWakeupDetails(output.appWakeups.valueAt(0), 5, 5); verifyWakeupDetails(output.appWakeups.valueAt(1), 5, 5); verifyWakeupDetails(output.appWakeups.valueAt(2), 5, 5); verifyWakeupDetails(output.appWakeups.valueAt(3), 5, 5); }