mirror of
https://github.com/NiciDieNase/chaosflix
synced 2024-11-23 12:53:08 +00:00
add getAllEvents() with Test
This commit is contained in:
parent
289d9c9456
commit
ca081d3305
4 changed files with 41 additions and 23 deletions
|
@ -100,6 +100,28 @@ public class Event extends SugarRecord implements Parcelable, Comparable<Event>
|
|||
parcel.writeString(conferenceUrl);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Event event) {
|
||||
return getSlug().compareTo(event.getSlug());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if(obj instanceof Event){
|
||||
return getGuid().equals(((Event)obj).getGuid());
|
||||
} else {
|
||||
return super.equals(obj);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void update(Event e) {
|
||||
if(!this.updatedAt.equals(e.getUpdatedAt())){
|
||||
// TODO actually update
|
||||
this.save();
|
||||
}
|
||||
}
|
||||
|
||||
public int getApiID(){
|
||||
String[] strings = getUrl().split("/");
|
||||
return Integer.parseInt(strings[strings.length-1]);
|
||||
|
@ -268,26 +290,4 @@ public class Event extends SugarRecord implements Parcelable, Comparable<Event>
|
|||
public void setUpdatedAt(String updatedAt) {
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Event event) {
|
||||
return getSlug().compareTo(event.getSlug());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if(obj instanceof Event){
|
||||
return getGuid().equals(((Event)obj).getGuid());
|
||||
} else {
|
||||
return super.equals(obj);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void update(Event e) {
|
||||
if(!this.updatedAt.equals(e.getUpdatedAt())){
|
||||
// TODO actually update
|
||||
this.save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,6 +43,11 @@ public class MediaCCCClient implements MediaCCCService {
|
|||
return service.getConference(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Call<List<Event>> getEvents() {
|
||||
return service.getEvents();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Call<Event> getEvent(@Path("id") int id) {
|
||||
return service.getEvent(id);
|
||||
|
|
|
@ -22,6 +22,9 @@ public interface MediaCCCService {
|
|||
@GET("public/conferences/{id}")
|
||||
Call<Conference> getConference(@Path("id") int id);
|
||||
|
||||
@GET("public/events")
|
||||
Call<List<Event>> getEvents();
|
||||
|
||||
@GET("public/events/{id}")
|
||||
Call<Event> getEvent(@Path("id") int id);
|
||||
|
||||
|
|
|
@ -95,7 +95,6 @@ public class MediaCCCClientTest{
|
|||
@Test
|
||||
public void sortTest(){
|
||||
try {
|
||||
|
||||
final MediaCCCClient client = new MediaCCCClient();
|
||||
Conferences conferences = client.listConferences().execute().body();
|
||||
Collections.sort(conferences.getConferences());
|
||||
|
@ -109,4 +108,15 @@ public class MediaCCCClientTest{
|
|||
fail();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sortAllEvents(){
|
||||
try{
|
||||
MediaCCCClient client = new MediaCCCClient();
|
||||
Collections.sort(client.getEvents().execute().body());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue