-
Notifications
You must be signed in to change notification settings - Fork 48
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
Null pointer fix #423
Merged
Merged
Null pointer fix #423
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -403,66 +403,80 @@ public void checkFlushIsCalled() { | |
} | ||
|
||
@Test | ||
public void checksSetBaseUrlWithValidHost() throws Exception { | ||
public void checksSetBaseUrlWithValidHostAndWithConnection() throws Exception { | ||
Context mockedContext = obtainNetworkConnectedMockedContext(); | ||
TelemetryClient mockedTelemetryClient = mock(TelemetryClient.class); | ||
MapboxTelemetry theMapboxTelemetry = obtainMapboxTelemetryWith(mockedTelemetryClient); | ||
theMapboxTelemetry.setBaseUrl(DEFAULT_STAGING_EVENTS_HOST); | ||
Callback mockedHttpCallback = mock(Callback.class); | ||
MapboxTelemetry theMapboxTelemetry = obtainMapboxTelemetryWith(mockedContext, mockedTelemetryClient, | ||
mockedHttpCallback); | ||
assertTrue(theMapboxTelemetry.setBaseUrl(DEFAULT_STAGING_EVENTS_HOST)); | ||
verify(mockedTelemetryClient, times(1)).setBaseUrl(eq(DEFAULT_STAGING_EVENTS_HOST)); | ||
} | ||
|
||
@Test | ||
public void checksSetBaseUrlWithValidHostAndWithoutConnection() throws Exception { | ||
Context mockedContext = obtainNetworkNotConnectedMockedContext(); | ||
TelemetryClient mockedTelemetryClient = mock(TelemetryClient.class); | ||
Callback mockedHttpCallback = mock(Callback.class); | ||
MapboxTelemetry theMapboxTelemetry = obtainMapboxTelemetryWith(mockedContext, mockedTelemetryClient, | ||
mockedHttpCallback); | ||
assertFalse(theMapboxTelemetry.setBaseUrl(DEFAULT_STAGING_EVENTS_HOST)); | ||
verify(mockedTelemetryClient, never()).setBaseUrl(eq(DEFAULT_STAGING_EVENTS_HOST)); | ||
} | ||
|
||
@Test | ||
public void checksSetBaseUrlWithNullHost() throws Exception { | ||
TelemetryClient mockedTelemetryClient = mock(TelemetryClient.class); | ||
MapboxTelemetry theMapboxTelemetry = obtainMapboxTelemetryWith(mockedTelemetryClient); | ||
theMapboxTelemetry.setBaseUrl(null); | ||
assertFalse(theMapboxTelemetry.setBaseUrl(null)); | ||
verify(mockedTelemetryClient, never()).setBaseUrl(any(String.class)); | ||
} | ||
|
||
@Test | ||
public void checksSetBaseUrlWithEmptyHost() throws Exception { | ||
TelemetryClient mockedTelemetryClient = mock(TelemetryClient.class); | ||
MapboxTelemetry theMapboxTelemetry = obtainMapboxTelemetryWith(mockedTelemetryClient); | ||
theMapboxTelemetry.setBaseUrl(""); | ||
assertFalse(theMapboxTelemetry.setBaseUrl("")); | ||
verify(mockedTelemetryClient, never()).setBaseUrl(any(String.class)); | ||
} | ||
|
||
@Test | ||
public void checksSetBaseUrlWithInvalidHostOne() throws Exception { | ||
TelemetryClient mockedTelemetryClient = mock(TelemetryClient.class); | ||
MapboxTelemetry theMapboxTelemetry = obtainMapboxTelemetryWith(mockedTelemetryClient); | ||
theMapboxTelemetry.setBaseUrl("[email protected]"); | ||
assertFalse(theMapboxTelemetry.setBaseUrl("[email protected]")); | ||
verify(mockedTelemetryClient, never()).setBaseUrl(any(String.class)); | ||
} | ||
|
||
@Test | ||
public void checksSetBaseUrlWithInvalidHostTwo() throws Exception { | ||
TelemetryClient mockedTelemetryClient = mock(TelemetryClient.class); | ||
MapboxTelemetry theMapboxTelemetry = obtainMapboxTelemetryWith(mockedTelemetryClient); | ||
theMapboxTelemetry.setBaseUrl("new host.com"); | ||
assertFalse(theMapboxTelemetry.setBaseUrl("new host.com")); | ||
verify(mockedTelemetryClient, never()).setBaseUrl(any(String.class)); | ||
} | ||
|
||
@Test | ||
public void checksSetBaseUrlWithInvalidHostThree() throws Exception { | ||
TelemetryClient mockedTelemetryClient = mock(TelemetryClient.class); | ||
MapboxTelemetry theMapboxTelemetry = obtainMapboxTelemetryWith(mockedTelemetryClient); | ||
theMapboxTelemetry.setBaseUrl("host..com"); | ||
assertFalse(theMapboxTelemetry.setBaseUrl("host..com")); | ||
verify(mockedTelemetryClient, never()).setBaseUrl(any(String.class)); | ||
} | ||
|
||
@Test | ||
public void checksSetBaseUrlWithInvalidHostFour() throws Exception { | ||
TelemetryClient mockedTelemetryClient = mock(TelemetryClient.class); | ||
MapboxTelemetry theMapboxTelemetry = obtainMapboxTelemetryWith(mockedTelemetryClient); | ||
theMapboxTelemetry.setBaseUrl("host.c"); | ||
assertFalse(theMapboxTelemetry.setBaseUrl("host.c")); | ||
verify(mockedTelemetryClient, never()).setBaseUrl(any(String.class)); | ||
} | ||
|
||
@Test | ||
public void checksSetBaseUrlWithInvalidHostFive() throws Exception { | ||
TelemetryClient mockedTelemetryClient = mock(TelemetryClient.class); | ||
MapboxTelemetry theMapboxTelemetry = obtainMapboxTelemetryWith(mockedTelemetryClient); | ||
theMapboxTelemetry.setBaseUrl("host.com."); | ||
assertFalse(theMapboxTelemetry.setBaseUrl("host.com.")); | ||
verify(mockedTelemetryClient, never()).setBaseUrl(any(String.class)); | ||
} | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
do you need to check for network here?
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.
TelemetryClient
is created inside that check. It's a pipeline used byMapboxTelemetry
class to initTelemetryClient
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.
checkNetworkAndParameters()
checks for both network connection and init as required, so if you need the network check then this is fine, if the intent is to check and initTelemetryClient
then you couldcheckRequiredParameters(..)
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.
we discussed it internally and decided to check network connection as well.