@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); }
@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; }
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; } }
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); }
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(); }
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();  }