-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added display service - parking locations and scheduled works
- Loading branch information
1 parent
8b8d024
commit 18e948c
Showing
18 changed files
with
427 additions
and
46 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,56 @@ | ||
package api; | ||
|
||
import retrofit.RestAdapter; | ||
import util.Util; | ||
import android.test.AndroidTestCase; | ||
|
||
import com.atapiwrapper.library.BuildConfig; | ||
import com.atapiwrapper.library.api.AtApi; | ||
import com.atapiwrapper.library.api.model.ServerResponse; | ||
import com.atapiwrapper.library.api.model.realtime.vehiclelocations.VehicleLocationResponse; | ||
import com.atapiwrapper.library.api.service.RealtimeService; | ||
import com.atapiwrapper.library.api.model.display.ParkingLocation; | ||
import com.atapiwrapper.library.api.model.display.ScheduledWork; | ||
import com.atapiwrapper.library.api.service.DisplayService; | ||
|
||
import java.util.List; | ||
|
||
import retrofit.RestAdapter; | ||
import util.Util; | ||
|
||
/** | ||
* Tests the realtime api requests and responses | ||
*/ | ||
public class TATDisplays extends AndroidTestCase { | ||
|
||
private RestAdapter mRestAdapter; | ||
private RealtimeService mRealtimeService; | ||
private DisplayService mDisplayService; | ||
|
||
@Override protected void setUp() throws Exception { | ||
super.setUp(); | ||
|
||
AtApi api = new AtApi(BuildConfig.API_KEY); | ||
mRestAdapter = api.getRestAdapter(Util.getClient()); | ||
mRealtimeService = mRestAdapter.create(RealtimeService.class); | ||
mDisplayService = mRestAdapter.create(DisplayService.class); | ||
} | ||
|
||
public void testVehicleLocations() { | ||
public void testParkingLocations() { | ||
|
||
ServerResponse<VehicleLocationResponse> result = mRealtimeService.vehiclelocations(); | ||
ServerResponse<List<ParkingLocation>> result = mDisplayService.parkingLocations(); | ||
|
||
//make sure we have content | ||
assertNotNull(result); | ||
assertNotNull(result.getStatus()); | ||
assertEquals(result.getStatus(), ServerResponse.STATUS_OK); | ||
assertNotNull(result.getResponse()); | ||
assertNotNull(result.getResponse().getVehicleLocations()); | ||
assertTrue(result.getResponse().getVehicleLocations().size() > 0); | ||
assertTrue(result.getResponse().size() > 0); | ||
} | ||
public void testVehicleLocationsByTripId() { | ||
|
||
ServerResponse<VehicleLocationResponse> result = mRealtimeService.vehiclelocationsByTripId("2212GW582020451266647"); | ||
|
||
//make sure we have content | ||
assertNotNull(result); | ||
assertNotNull(result.getStatus()); | ||
assertEquals(result.getStatus(), ServerResponse.STATUS_OK); | ||
assertNotNull(result.getResponse()); | ||
assertNotNull(result.getResponse().getVehicleLocations()); | ||
assertTrue(result.getResponse().getVehicleLocations().size() == 1); | ||
} | ||
|
||
public void testVehicleLocationsByVehicleId() { | ||
|
||
ServerResponse<VehicleLocationResponse> result = mRealtimeService.vehiclelocationsByTripId( | ||
"4f9abf121ddd83f8eeed3a42ac2e159615fe5b3800333d0b9ca51f38700d1678"); | ||
public void testScheduledWorks() { | ||
ServerResponse<List<ScheduledWork>> result = mDisplayService.scheduledWorks(); | ||
|
||
//make sure we have content | ||
assertNotNull(result); | ||
assertNotNull(result.getStatus()); | ||
assertEquals(result.getStatus(), ServerResponse.STATUS_OK); | ||
assertNotNull(result.getResponse()); | ||
assertNotNull(result.getResponse().getVehicleLocations()); | ||
assertTrue(result.getResponse().getVehicleLocations().size() == 1); | ||
assertTrue(result.getResponse().size() > 0); | ||
} | ||
|
||
} |
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
80 changes: 80 additions & 0 deletions
80
lib/src/main/java/com/atapiwrapper/library/api/model/display/ParkingLocation.java
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 |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package com.atapiwrapper.library.api.model.display; | ||
|
||
import android.os.Parcel; | ||
import android.os.Parcelable; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
public class ParkingLocation implements Parcelable { | ||
@JsonProperty("id") private Integer id; | ||
@JsonProperty("address") private String address; | ||
@JsonProperty("mobilitySpaces") private Integer mobilitySpaces; | ||
@JsonProperty("name") private String name; | ||
@JsonProperty("longitude") private Double longitude; | ||
@JsonProperty("latitude") private Double latitude; | ||
@JsonProperty("type") private String type; | ||
|
||
public Integer getId() { | ||
return id; | ||
} | ||
|
||
public String getAddress() { | ||
return address; | ||
} | ||
|
||
public Integer getMobilitySpaces() { | ||
return mobilitySpaces; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public Double getLongitude() { | ||
return longitude; | ||
} | ||
|
||
public Double getLatitude() { | ||
return latitude; | ||
} | ||
|
||
public String getType() { | ||
return type; | ||
} | ||
|
||
@Override public int describeContents() { | ||
return 0; | ||
} | ||
|
||
@Override public void writeToParcel(Parcel dest, int flags) { | ||
dest.writeValue(this.id); | ||
dest.writeString(this.address); | ||
dest.writeValue(this.mobilitySpaces); | ||
dest.writeString(this.name); | ||
dest.writeValue(this.longitude); | ||
dest.writeValue(this.latitude); | ||
dest.writeString(this.type); | ||
} | ||
|
||
public ParkingLocation() {} | ||
|
||
private ParkingLocation(Parcel in) { | ||
this.id = (Integer) in.readValue(Integer.class.getClassLoader()); | ||
this.address = in.readString(); | ||
this.mobilitySpaces = (Integer) in.readValue(Integer.class.getClassLoader()); | ||
this.name = in.readString(); | ||
this.longitude = (Double) in.readValue(Double.class.getClassLoader()); | ||
this.latitude = (Double) in.readValue(Double.class.getClassLoader()); | ||
this.type = in.readString(); | ||
} | ||
|
||
public static Parcelable.Creator<ParkingLocation> CREATOR = new Parcelable.Creator<ParkingLocation>() { | ||
public ParkingLocation createFromParcel(Parcel source) { | ||
return new ParkingLocation(source); | ||
} | ||
|
||
public ParkingLocation[] newArray(int size) { | ||
return new ParkingLocation[size]; | ||
} | ||
}; | ||
} |
132 changes: 132 additions & 0 deletions
132
lib/src/main/java/com/atapiwrapper/library/api/model/display/ScheduledWork.java
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 |
---|---|---|
@@ -0,0 +1,132 @@ | ||
package com.atapiwrapper.library.api.model.display; | ||
|
||
import android.os.Parcel; | ||
import android.os.Parcelable; | ||
|
||
import com.atapiwrapper.library.api.model.geometry.Geometry; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
public class ScheduledWork implements Parcelable { | ||
@JsonProperty("region") private String region; | ||
@JsonProperty("startDate") private String startDate; | ||
@JsonProperty("lastUpdated") private String lastUpdated; | ||
@JsonProperty("endDate") private String endDate; | ||
@JsonProperty("code") private String code; | ||
@JsonProperty("type") private String type; | ||
@JsonProperty("geometry") private Geometry geometry; | ||
@JsonProperty("id") private Integer id; | ||
@JsonProperty("contractorCompany") private String contractorCompany; | ||
@JsonProperty("suburb") private String suburb; | ||
@JsonProperty("address") private String address; | ||
@JsonProperty("description") private String description; | ||
@JsonProperty("name") private String name; | ||
@JsonProperty("longitude") private Double longitude; | ||
@JsonProperty("latitude") private Double latitude; | ||
|
||
public String getRegion() { | ||
return region; | ||
} | ||
|
||
public String getStartDate() { | ||
return startDate; | ||
} | ||
|
||
public String getLastUpdated() { | ||
return lastUpdated; | ||
} | ||
|
||
public String getEndDate() { | ||
return endDate; | ||
} | ||
|
||
public String getCode() { | ||
return code; | ||
} | ||
|
||
public String getType() { | ||
return type; | ||
} | ||
|
||
public Geometry getGeometry() { | ||
return geometry; | ||
} | ||
|
||
public Integer getId() { | ||
return id; | ||
} | ||
|
||
public String getContractorCompany() { | ||
return contractorCompany; | ||
} | ||
|
||
public String getSuburb() { | ||
return suburb; | ||
} | ||
|
||
public String getAddress() { | ||
return address; | ||
} | ||
|
||
public String getDescription() { | ||
return description; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public Double getLongitude() { | ||
return longitude; | ||
} | ||
|
||
public Double getLatitude() { | ||
return latitude; | ||
} | ||
|
||
|
||
@Override public int describeContents() { return 0; } | ||
|
||
@Override public void writeToParcel(Parcel dest, int flags) { | ||
dest.writeString(this.region); | ||
dest.writeString(this.startDate); | ||
dest.writeString(this.lastUpdated); | ||
dest.writeString(this.endDate); | ||
dest.writeString(this.code); | ||
dest.writeString(this.type); | ||
// dest.writeParcelable(this.geometry, flags); | ||
dest.writeValue(this.id); | ||
dest.writeString(this.contractorCompany); | ||
dest.writeString(this.suburb); | ||
dest.writeString(this.address); | ||
dest.writeString(this.description); | ||
dest.writeString(this.name); | ||
dest.writeValue(this.longitude); | ||
dest.writeValue(this.latitude); | ||
} | ||
|
||
public ScheduledWork() {} | ||
|
||
private ScheduledWork(Parcel in) { | ||
this.region = in.readString(); | ||
this.startDate = in.readString(); | ||
this.lastUpdated = in.readString(); | ||
this.endDate = in.readString(); | ||
this.code = in.readString(); | ||
this.type = in.readString(); | ||
// this.geometry = in.readParcelable(Geometry.class.getClassLoader()); | ||
this.id = (Integer) in.readValue(Integer.class.getClassLoader()); | ||
this.contractorCompany = in.readString(); | ||
this.suburb = in.readString(); | ||
this.address = in.readString(); | ||
this.description = in.readString(); | ||
this.name = in.readString(); | ||
this.longitude = (Double) in.readValue(Double.class.getClassLoader()); | ||
this.latitude = (Double) in.readValue(Double.class.getClassLoader()); | ||
} | ||
|
||
public static Parcelable.Creator<ScheduledWork> CREATOR = new Parcelable.Creator<ScheduledWork>() { | ||
public ScheduledWork createFromParcel(Parcel source) {return new ScheduledWork(source);} | ||
|
||
public ScheduledWork[] newArray(int size) {return new ScheduledWork[size];} | ||
}; | ||
} |
20 changes: 20 additions & 0 deletions
20
lib/src/main/java/com/atapiwrapper/library/api/model/geometry/Geometry.java
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.atapiwrapper.library.api.model.geometry; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
/** | ||
* Geometry returned by the server can be of different types determined by the type attribute. This is handled by a custom deserializerin | ||
* {@link com.atapiwrapper.library.api.AtApi} | ||
*/ | ||
public abstract class Geometry { | ||
@JsonProperty("encoded") protected boolean encoded; | ||
@JsonProperty("type") protected String type; | ||
|
||
public boolean isEncoded() { | ||
return encoded; | ||
} | ||
|
||
public String getType() { | ||
return type; | ||
} | ||
} |
Oops, something went wrong.