-
Notifications
You must be signed in to change notification settings - Fork 627
Create native proxy object to check provider on each call and mediate… #2532
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
… between desired return value and default behavior)
Coverage ReportAffected SDKs
Test Logs
NotesHTML coverage reports can be produced locally with Head commit (461cf834) is created by Prow via merging commits: 2cc1cc4 6aabb02. |
Binary Size ReportAffected SDKs
Test Logs
NotesHead commit (461cf834) is created by Prow via merging commits: 2cc1cc4 6aabb02. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we add a test for the proxy where when the provider is filled with a value we would see the expected call into the native component?
if (provider.get() != null) { | ||
return provider.get().hasCrashDataForSession(sessionId); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recommend caching the result of get()
instead of calling into it twice. This will make code more readable and more conventional as per Injecting Providers where in more traditional DI setups each call to get()
could return a newly created instance if the component is not a singleton.
While all Firebase components are singletons, it could be beneficial to be consistent with common conventions for future readers of this code(including ourselves).
if (provider.get() != null) { | |
return provider.get().hasCrashDataForSession(sessionId); | |
} | |
Foo native = provider.get(); | |
if (native != null) { | |
return native.hasCrashDataForSession(sessionId); | |
} |
Here and throughout
@Mock private CrashlyticsNativeComponent component; | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
MockitoAnnotations.initMocks(this); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: for this simple case you can just use the more concise:
@Mock private CrashlyticsNativeComponent component; | |
@Before | |
public void setUp() throws Exception { | |
MockitoAnnotations.initMocks(this); | |
} | |
private final CrashlyticsNativeComponent component = mock(CrashlyticsNativeComponent.class); |
import org.mockito.Mockito; | ||
import org.mockito.MockitoAnnotations; | ||
|
||
public class ProviderProxyNative { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a @RunWith(AndroidJUnit4.class)
@davidmotson: The following test failed, say
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
… between desired return value and default behavior)