Skip to content
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

Fix static marker annotation url generation #479

Merged
merged 1 commit into from
Jun 17, 2017

Conversation

Guardiola31337
Copy link
Contributor

@Guardiola31337 Guardiola31337 commented Jun 12, 2017

Fixes mapbox/mapbox-gl-native#9107

  • Fix tests
  • Add new tests
  • Verify when a label is not a valid Maki icon (not blocker)

👀 @zugaldia @cammace

@@ -167,7 +177,11 @@ public Builder setLabel(String label) {
* @since 2.1.0
*/
public String getColor() {
return color;
if (color.isEmpty()) {
return EMPTY;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just return null if a color isn't set?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

@@ -144,12 +149,17 @@ public Builder setName(String name) {
* @since 2.1.0
*/
public String getLabel() {
return label;
if (label.isEmpty()) {
return EMPTY;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just return null if a label isn't set?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cammace null is not valid because getLabel is called when parsing (String.format) and label is an optional param (note that -was removed from the default string because if the label was empty url was incorrect. A Null Object pattern could be implemented though.

BTW null is considered The worst mistake of computer science: Null References: The Billion Dollar Mistake 😉

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol, I've read that interview 😄 . Sounds good.

@@ -65,8 +65,76 @@ public void requireMarkerLon() throws ServicesException {
new StaticMarkerAnnotation.Builder().setName(Constants.PIN_SMALL).setLat(2.0).build();
}

@Test(expected = ServicesException.class)
Copy link

@cammace cammace Jun 15, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we be more explicit on which ServiceException we expect to occur here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO just testing that an exception is thrown when an url is not valid is 👌
If more explicitness needed, what about creating a new specific exception?
BTW, is that explicitness really needed in this case?

@Guardiola31337 Guardiola31337 merged commit 055640f into master Jun 17, 2017
@Guardiola31337 Guardiola31337 deleted the pg-static-marker-url-issue branch June 17, 2017 09:37
@zugaldia zugaldia mentioned this pull request Jun 20, 2017
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants