mirror of
https://github.com/NiciDieNase/chaosflix
synced 2024-12-03 17:39:16 +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);
|
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(){
|
public int getApiID(){
|
||||||
String[] strings = getUrl().split("/");
|
String[] strings = getUrl().split("/");
|
||||||
return Integer.parseInt(strings[strings.length-1]);
|
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) {
|
public void setUpdatedAt(String updatedAt) {
|
||||||
this.updatedAt = 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);
|
return service.getConference(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Call<List<Event>> getEvents() {
|
||||||
|
return service.getEvents();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Call<Event> getEvent(@Path("id") int id) {
|
public Call<Event> getEvent(@Path("id") int id) {
|
||||||
return service.getEvent(id);
|
return service.getEvent(id);
|
||||||
|
|
|
@ -22,6 +22,9 @@ public interface MediaCCCService {
|
||||||
@GET("public/conferences/{id}")
|
@GET("public/conferences/{id}")
|
||||||
Call<Conference> getConference(@Path("id") int id);
|
Call<Conference> getConference(@Path("id") int id);
|
||||||
|
|
||||||
|
@GET("public/events")
|
||||||
|
Call<List<Event>> getEvents();
|
||||||
|
|
||||||
@GET("public/events/{id}")
|
@GET("public/events/{id}")
|
||||||
Call<Event> getEvent(@Path("id") int id);
|
Call<Event> getEvent(@Path("id") int id);
|
||||||
|
|
||||||
|
|
|
@ -95,7 +95,6 @@ public class MediaCCCClientTest{
|
||||||
@Test
|
@Test
|
||||||
public void sortTest(){
|
public void sortTest(){
|
||||||
try {
|
try {
|
||||||
|
|
||||||
final MediaCCCClient client = new MediaCCCClient();
|
final MediaCCCClient client = new MediaCCCClient();
|
||||||
Conferences conferences = client.listConferences().execute().body();
|
Conferences conferences = client.listConferences().execute().body();
|
||||||
Collections.sort(conferences.getConferences());
|
Collections.sort(conferences.getConferences());
|
||||||
|
@ -109,4 +108,15 @@ public class MediaCCCClientTest{
|
||||||
fail();
|
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