### Question:
UZUtilBase { public static void getDetailEntity(final Context context, final String entityId, final CallbackGetDetailEntity callbackGetDetailEntity) { UZService service = UZRestClient.createService(UZService.class); UZAPIMaster.getInstance().subscribe(service.retrieveAnEntity(entityId), new ApiSubscriber<ResultRetrieveAnEntity>() { @Override public void onSuccess(ResultRetrieveAnEntity result) { if (result == null || result.getData() == null || result.getData().getId() == null || result.getData().getId().isEmpty()) { getDataFromEntityIdLIVE(context, entityId, callbackGetDetailEntity); } else { if (callbackGetDetailEntity != null) { Data d = result.getData(); callbackGetDetailEntity.onSuccess(d); } } } @Override public void onFail(Throwable e) { if (callbackGetDetailEntity != null) { callbackGetDetailEntity.onError(e); } } }); }  static void getDetailEntity(final Context context, final String entityId, final CallbackGetDetailEntity callbackGetDetailEntity); static void getDataFromEntityIdLIVE(final Context context, String entityId, final CallbackGetDetailEntity callbackGetDetailEntity);  }### Answer:
@Test public void test_getDetailEntity_success_with_data() { Data mockData = Mockito.mock(Data.class); String mockDataId = "None-Empty-Id"; ArgumentCaptor<Observable> arg1 = ArgumentCaptor.forClass(Observable.class); ArgumentCaptor<ApiSubscriber> arg2 = ArgumentCaptor.forClass(ApiSubscriber.class); ResultRetrieveAnEntity result = Mockito.mock(ResultRetrieveAnEntity.class); Mockito.when(result.getData()).thenReturn(mockData); Mockito.when(result.getData().getId()).thenReturn(mockDataId); PowerMockito.when(UZRestClient.createService(UZService.class)).thenReturn(Mockito.mock(UZService.class)); PowerMockito.when(UZAPIMaster.getInstance()).thenReturn(Mockito.mock(UZAPIMaster.class)); UZUtilBase.getDetailEntity(context, entityId, callbackGetDetailEntity); PowerMockito.verifyStatic(UZRestClient.class); UZRestClient.createService(UZService.class); Mockito.verify(UZAPIMaster.getInstance()).subscribe(arg1.capture(), arg2.capture()); arg2.getValue().onSuccess(result); Mockito.verify(callbackGetDetailEntity).onSuccess(result.getData()); }
@Test public void test_getDetailEntity_error() { ArgumentCaptor<Observable> arg1 = ArgumentCaptor.forClass(Observable.class); ArgumentCaptor<ApiSubscriber> arg2 = ArgumentCaptor.forClass(ApiSubscriber.class); Throwable error = Mockito.mock(Throwable.class); PowerMockito.when(UZRestClient.createService(UZService.class)).thenReturn(Mockito.mock(UZService.class)); PowerMockito.when(UZAPIMaster.getInstance()).thenReturn(Mockito.mock(UZAPIMaster.class)); UZUtilBase.getDetailEntity(context, entityId, callbackGetDetailEntity); PowerMockito.verifyStatic(UZRestClient.class); UZRestClient.createService(UZService.class); Mockito.verify(UZAPIMaster.getInstance()).subscribe(arg1.capture(), arg2.capture()); arg2.getValue().onError(error); Mockito.verify(callbackGetDetailEntity).onError(error); }