### Question:
DefaultHeartBeatInfo implements HeartBeatInfo { @Override public @NonNull HeartBeat getHeartBeatCode(@NonNull String heartBeatTag) { long presentTime = System.currentTimeMillis(); boolean shouldSendSdkHB = storage.get().shouldSendSdkHeartBeat(heartBeatTag, presentTime); boolean shouldSendGlobalHB = storage.get().shouldSendGlobalHeartBeat(presentTime); if (shouldSendSdkHB && shouldSendGlobalHB) { return HeartBeat.COMBINED; } else if (shouldSendGlobalHB) { return HeartBeat.GLOBAL; } else if (shouldSendSdkHB) { return HeartBeat.SDK; } return HeartBeat.NONE; } private  DefaultHeartBeatInfo(Context context); @VisibleForTesting  DefaultHeartBeatInfo(Provider<HeartBeatInfoStorage> testStorage); @Override @NonNull HeartBeat getHeartBeatCode(@NonNull String heartBeatTag); static @NonNull Component<HeartBeatInfo> component();  }### Answer:
@Test public void getHeartBeatCode_noHeartBeat() { when(storage.shouldSendSdkHeartBeat(anyString(), anyLong())).thenReturn(Boolean.FALSE); heartBeatInfo.getHeartBeatCode(testSdk); assertThat(heartBeatInfo.getHeartBeatCode(testSdk).getCode()).isEqualTo(0); }
@Test public void getHeartBeatCode_sdkHeartBeat() { when(storage.shouldSendSdkHeartBeat(anyString(), anyLong())).thenReturn(Boolean.TRUE); when(storage.shouldSendGlobalHeartBeat(anyLong())).thenReturn(Boolean.FALSE); heartBeatInfo.getHeartBeatCode(testSdk); assertThat(heartBeatInfo.getHeartBeatCode(testSdk).getCode()).isEqualTo(1); }
@Test public void getHeartBeatCode_globalHeartBeat() { when(storage.shouldSendSdkHeartBeat(anyString(), anyLong())).thenReturn(Boolean.FALSE); when(storage.shouldSendGlobalHeartBeat(anyLong())).thenReturn(Boolean.TRUE); heartBeatInfo.getHeartBeatCode(testSdk); assertThat(heartBeatInfo.getHeartBeatCode(testSdk).getCode()).isEqualTo(2); }
@Test public void getHeartBeatCode_combinedHeartBeat() { when(storage.shouldSendSdkHeartBeat(anyString(), anyLong())).thenReturn(Boolean.TRUE); when(storage.shouldSendGlobalHeartBeat(anyLong())).thenReturn(Boolean.TRUE); heartBeatInfo.getHeartBeatCode(testSdk); assertThat(heartBeatInfo.getHeartBeatCode(testSdk).getCode()).isEqualTo(3); }