Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
add schema test
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin authored and Łukasz Paczos committed Apr 18, 2019
1 parent a66cc60 commit 8bbd380
Show file tree
Hide file tree
Showing 13 changed files with 305 additions and 80 deletions.
1 change: 1 addition & 0 deletions platform/android/MapboxGLAndroidSDK/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
dependency-graph-mapbox-libraries.png
src/test/resources/mobile-event*
1 change: 1 addition & 0 deletions platform/android/MapboxGLAndroidSDK/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ dependencies {
testImplementation dependenciesList.mockk
testImplementation dependenciesList.robolectric
testImplementation dependenciesList.kotlinLib
testImplementation dependenciesList.commonsIO
}

android {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,24 @@
*/
@SuppressLint("ParcelCreator")
public abstract class MapBaseEvent extends Event {
final String event;
final String created;
private final String event;
private final String created;

MapBaseEvent(PhoneState phoneState) {
event = getEventName();
this.event = getEventName();
this.created = phoneState.getCreated();
}

abstract String getEventName();

public String getEvent() {
return event;
}

public String getCreated() {
return created;
}

@Override
public int describeContents() {
return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ class MapClickEvent extends MapBaseEvent {
private final String cellularNetworkType;
private final String carrier;
private final String orientation;
private final double latitude;
private final double longitude;
private final double lat;
private final double lng;
private final double zoom;
private final int batteryLevel;
private final boolean pluggedIn;
Expand All @@ -23,8 +23,8 @@ class MapClickEvent extends MapBaseEvent {
MapClickEvent(PhoneState phoneState, MapState mapState) {
super(phoneState);
this.gesture = mapState.getGesture();
this.latitude = mapState.getLatitude();
this.longitude = mapState.getLongitude();
this.lat = mapState.getLatitude();
this.lng = mapState.getLongitude();
this.zoom = mapState.getZoom();
this.batteryLevel = phoneState.getBatteryLevel();
this.pluggedIn = phoneState.isPluggedIn();
Expand All @@ -39,10 +39,6 @@ String getEventName() {
return EVENT_NAME;
}

String getCreated() {
return created;
}

String getGesture() {
return gesture;
}
Expand All @@ -59,12 +55,12 @@ String getOrientation() {
return orientation;
}

double getLatitude() {
return latitude;
double getLat() {
return lat;
}

double getLongitude() {
return longitude;
double getLng() {
return lng;
}

double getZoom() {
Expand Down Expand Up @@ -94,10 +90,10 @@ public boolean equals(Object o) {

MapClickEvent that = (MapClickEvent) o;

if (Double.compare(that.latitude, latitude) != 0) {
if (Double.compare(that.lat, lat) != 0) {
return false;
}
if (Double.compare(that.longitude, longitude) != 0) {
if (Double.compare(that.lng, lng) != 0) {
return false;
}
if (Double.compare(that.zoom, zoom) != 0) {
Expand All @@ -112,9 +108,6 @@ public boolean equals(Object o) {
if (wifi != that.wifi) {
return false;
}
if (created != null ? !created.equals(that.created) : that.created != null) {
return false;
}
if (gesture != null ? !gesture.equals(that.gesture) : that.gesture != null) {
return false;
}
Expand All @@ -132,15 +125,13 @@ public boolean equals(Object o) {
public int hashCode() {
int result;
long temp;
result = event.hashCode();
result = 31 * result + (created != null ? created.hashCode() : 0);
result = 31 * result + (gesture != null ? gesture.hashCode() : 0);
result = gesture != null ? gesture.hashCode() : 0;
result = 31 * result + (cellularNetworkType != null ? cellularNetworkType.hashCode() : 0);
result = 31 * result + (carrier != null ? carrier.hashCode() : 0);
result = 31 * result + (orientation != null ? orientation.hashCode() : 0);
temp = Double.doubleToLongBits(latitude);
temp = Double.doubleToLongBits(lat);
result = 31 * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(longitude);
temp = Double.doubleToLongBits(lng);
result = 31 * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(zoom);
result = 31 * result + (int) (temp ^ (temp >>> 32));
Expand All @@ -153,14 +144,12 @@ public int hashCode() {
@Override
public String toString() {
return "MapClickEvent{"
+ "event='" + event + '\''
+ ", created='" + created + '\''
+ ", gesture='" + gesture + '\''
+ ", cellularNetworkType='" + cellularNetworkType + '\''
+ ", carrier='" + carrier + '\''
+ ", orientation='" + orientation + '\''
+ ", latitude=" + latitude
+ ", longitude=" + longitude
+ ", lat=" + lat
+ ", lng=" + lng
+ ", zoom=" + zoom
+ ", batteryLevel=" + batteryLevel
+ ", pluggedIn=" + pluggedIn
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ String getEventName() {
return EVENT_NAME;
}

String getCreated() {
return created;
}

String getOrientation() {
return orientation;
}
Expand Down Expand Up @@ -105,9 +101,6 @@ public boolean equals(Object o) {
if (wifi != that.wifi) {
return false;
}
if (created != null ? !created.equals(that.created) : that.created != null) {
return false;
}
if (orientation != null ? !orientation.equals(that.orientation) : that.orientation != null) {
return false;
}
Expand All @@ -122,9 +115,7 @@ public boolean equals(Object o) {
public int hashCode() {
int result;
long temp;
result = event.hashCode();
result = 31 * result + (created != null ? created.hashCode() : 0);
result = 31 * result + (orientation != null ? orientation.hashCode() : 0);
result = orientation != null ? orientation.hashCode() : 0;
result = 31 * result + (carrier != null ? carrier.hashCode() : 0);
result = 31 * result + (cellularNetworkType != null ? cellularNetworkType.hashCode() : 0);
result = 31 * result + batteryLevel;
Expand All @@ -142,8 +133,6 @@ public int hashCode() {
@Override
public String toString() {
return "MapDragendEvent{"
+ "event='" + event + '\''
+ ", created='" + created + '\''
+ ", orientation='" + orientation + '\''
+ ", carrier='" + carrier + '\''
+ ", cellularNetworkType='" + cellularNetworkType + '\''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,6 @@ String getModel() {
return model;
}

String getCreated() {
return created;
}

String getUserId() {
return userId;
}
Expand Down Expand Up @@ -131,9 +127,6 @@ public boolean equals(Object o) {
if (model != null ? !model.equals(that.model) : that.model != null) {
return false;
}
if (created != null ? !created.equals(that.created) : that.created != null) {
return false;
}
if (userId != null ? !userId.equals(that.userId) : that.userId != null) {
return false;
}
Expand All @@ -149,12 +142,10 @@ public boolean equals(Object o) {

@Override
public int hashCode() {
int result = event.hashCode();
result = 31 * result + operatingSystem.hashCode();
int result = operatingSystem != null ? operatingSystem.hashCode() : 0;
result = 31 * result + sdkIdentifier.hashCode();
result = 31 * result + sdkVersion.hashCode();
result = 31 * result + (model != null ? model.hashCode() : 0);
result = 31 * result + (created != null ? created.hashCode() : 0);
result = 31 * result + (userId != null ? userId.hashCode() : 0);
result = 31 * result + (carrier != null ? carrier.hashCode() : 0);
result = 31 * result + (cellularNetworkType != null ? cellularNetworkType.hashCode() : 0);
Expand All @@ -170,12 +161,10 @@ public int hashCode() {
@Override
public String toString() {
return "MapLoadEvent{"
+ "event='" + event + '\''
+ ", operatingSystem='" + operatingSystem + '\''
+ ", sdkIdentifier='" + sdkIdentifier + '\''
+ ", sdkVersion='" + sdkVersion + '\''
+ ", model='" + model + '\''
+ ", created='" + created + '\''
+ ", userId='" + userId + '\''
+ ", carrier='" + carrier + '\''
+ ", cellularNetworkType='" + cellularNetworkType + '\''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ String getEventName() {
return EVENT_NAME;
}

String getCreated() {
return created;
}

Double getMinZoom() {
return minZoom;
}
Expand Down Expand Up @@ -104,9 +100,6 @@ public boolean equals(Object o) {
if (state != that.state) {
return false;
}
if (created != null ? !created.equals(that.created) : that.created != null) {
return false;
}
if (minZoom != null ? !minZoom.equals(that.minZoom) : that.minZoom != null) {
return false;
}
Expand All @@ -122,9 +115,7 @@ public boolean equals(Object o) {

@Override
public int hashCode() {
int result = event.hashCode();
result = 31 * result + (created != null ? created.hashCode() : 0);
result = 31 * result + (minZoom != null ? minZoom.hashCode() : 0);
int result = minZoom != null ? minZoom.hashCode() : 0;
result = 31 * result + (maxZoom != null ? maxZoom.hashCode() : 0);
result = 31 * result + (shapeForOfflineRegion != null ? shapeForOfflineRegion.hashCode() : 0);
result = 31 * result + (styleURL != null ? styleURL.hashCode() : 0);
Expand All @@ -137,8 +128,6 @@ public int hashCode() {
@Override
public String toString() {
return "OfflineDownloadEndEvent{"
+ "event='" + event + '\''
+ ", created='" + created + '\''
+ ", minZoom=" + minZoom
+ ", maxZoom=" + maxZoom
+ ", shapeForOfflineRegion='" + shapeForOfflineRegion + '\''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ String getEventName() {
return EVENT_NAME;
}

String getCreated() {
return created;
}

Double getMinZoom() {
return minZoom;
}
Expand Down Expand Up @@ -67,9 +63,6 @@ public boolean equals(Object o) {

OfflineDownloadStartEvent that = (OfflineDownloadStartEvent) o;

if (created != null ? !created.equals(that.created) : that.created != null) {
return false;
}
if (minZoom != null ? !minZoom.equals(that.minZoom) : that.minZoom != null) {
return false;
}
Expand All @@ -85,9 +78,7 @@ public boolean equals(Object o) {

@Override
public int hashCode() {
int result = event.hashCode();
result = 31 * result + (created != null ? created.hashCode() : 0);
result = 31 * result + (minZoom != null ? minZoom.hashCode() : 0);
int result = minZoom != null ? minZoom.hashCode() : 0;
result = 31 * result + (maxZoom != null ? maxZoom.hashCode() : 0);
result = 31 * result + (shapeForOfflineRegion != null ? shapeForOfflineRegion.hashCode() : 0);
result = 31 * result + (styleURL != null ? styleURL.hashCode() : 0);
Expand All @@ -97,8 +88,6 @@ public int hashCode() {
@Override
public String toString() {
return "OfflineDownloadStartEvent{"
+ "event='" + event + '\''
+ ", created='" + created + '\''
+ ", minZoom=" + minZoom
+ ", maxZoom=" + maxZoom
+ ", shapeForOfflineRegion='" + shapeForOfflineRegion + '\''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ public void setUp() {
public void testClickEvent() {
mapState.setGesture(TelemetryConstants.DOUBLE_TAP);
MapClickEvent mapClickEvent = MapEventFactory.buildMapClickEvent(phoneState, mapState);
assertEquals(LATITUDE, mapClickEvent.getLatitude(), 0);
assertEquals(LONGITUDE, mapClickEvent.getLongitude(), 0);
assertEquals(LATITUDE, mapClickEvent.getLat(), 0);
assertEquals(LONGITUDE, mapClickEvent.getLng(), 0);
assertEquals(ZOOM, mapClickEvent.getZoom(), 0);
assertEquals(BATTERY_LEVEL, mapClickEvent.getBatteryLevel());
assertEquals(CARRIER, mapClickEvent.getCarrier());
Expand Down
Loading

0 comments on commit 8bbd380

Please sign in to comment.