private void mockSdkStatusChange(SdkStatus fromStatus, SdkStatus toStatus) { when(mockSdkService.getStatus()).thenReturn(fromStatus); when(mockSdkService.isInstallSupported()).thenReturn(true); // the only way to enable READY status before blocking on the same thread test thread starts. doAnswer( invocation -> { ((SdkStatusUpdateListener) invocation.getArgument(0)) .onSdkStatusChange(mockSdkService, toStatus); when(mockSdkService.getStatus()).thenReturn(toStatus); return null; }) .when(mockSdkService) .addStatusUpdateListener(any()); } }
cloudSdkService.addStatusUpdateListener(sdkStatusUpdateListener); sdkLogging.log(CloudSdkMessageBundle.getString("managedsdk.waiting.for.sdk.ready") + "\n");