### Question:
SensorMetrics extends SystemMetrics<SensorMetrics> { @Override public SensorMetrics set(SensorMetrics b) { total.set(b.total); if (isAttributionEnabled && b.isAttributionEnabled) { sensorConsumption.clear(); for (int i = 0, l = b.sensorConsumption.size(); i < l; i++) { sensorConsumption.put(b.sensorConsumption.keyAt(i), b.sensorConsumption.valueAt(i)); } } return this; } SensorMetrics();  SensorMetrics(boolean isAttributionEnabled); @Override SensorMetrics sum(@Nullable SensorMetrics b, @Nullable SensorMetrics output); @Override SensorMetrics diff(@Nullable SensorMetrics b, @Nullable SensorMetrics output); @Override SensorMetrics set(SensorMetrics b); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); @Nullable JSONObject attributionToJSONObject(); public boolean isAttributionEnabled; final Consumption total; final SparseArray<Consumption> sensorConsumption; }### Answer:
@Test public void testSet() { SensorMetrics metrics = new SensorMetrics(true); metrics.set(createAttributedMetrics()); assertThat(metrics).isEqualTo(createAttributedMetrics()); }
@Test public void testUnattributedSet() { SensorMetrics metrics = new SensorMetrics(); metrics.set(createAttributedMetrics()); SensorMetrics comparisonMetrics = createAttributedMetrics(); comparisonMetrics.isAttributionEnabled = false; comparisonMetrics.sensorConsumption.clear(); assertThat(metrics).isEqualTo(comparisonMetrics); }