Search in sources :

Example 1 with PlaylistEntity

use of net.rdrei.android.scdl2.api.entity.PlaylistEntity in project scdl by passy.

the class PlaylistEntityTest method testParcel.

@Test
public void testParcel() {
    final TrackEntity track0 = new TrackEntity();
    track0.setId(200l);
    track0.setTitle("Hello, World.");
    final TrackEntity track1 = new TrackEntity();
    track1.setId(201l);
    track1.setTitle("Yet another track");
    final PlaylistEntity playlist = new PlaylistEntity();
    playlist.setId(23l);
    playlist.setDescription("new stuff");
    playlist.setTracks(Arrays.asList(new TrackEntity[] { track0, track1 }));
    final byte[] bytes;
    final Parcel parcel0 = Parcel.obtain();
    try {
        parcel0.writeValue(playlist);
        bytes = parcel0.marshall();
    } finally {
        parcel0.recycle();
    }
    final PlaylistEntity newPlaylist;
    final Parcel parcel1 = Parcel.obtain();
    try {
        parcel1.unmarshall(bytes, 0, bytes.length);
        parcel1.setDataPosition(0);
        newPlaylist = (PlaylistEntity) parcel1.readValue(PlaylistEntity.class.getClassLoader());
    } finally {
        parcel1.recycle();
    }
    assertThat(newPlaylist.getId(), equalTo(23l));
    assertThat(newPlaylist.getDescription(), equalTo("new stuff"));
    assertThat(newPlaylist.getTracks().size(), equalTo(2));
    assertThat(newPlaylist.getTracks().get(0).getId(), equalTo(200l));
}
Also used : TrackEntity(net.rdrei.android.scdl2.api.entity.TrackEntity) PlaylistEntity(net.rdrei.android.scdl2.api.entity.PlaylistEntity) Parcel(android.os.Parcel) Test(org.junit.Test)

Example 2 with PlaylistEntity

use of net.rdrei.android.scdl2.api.entity.PlaylistEntity in project scdl by passy.

the class PlaylistEntityTest method testDescription.

@Test
public void testDescription() {
    final PlaylistEntity entity = new PlaylistEntity();
    entity.setDescription("This is my description");
    assertThat(entity.getDescription(), equalTo("This is my description"));
}
Also used : PlaylistEntity(net.rdrei.android.scdl2.api.entity.PlaylistEntity) Test(org.junit.Test)

Example 3 with PlaylistEntity

use of net.rdrei.android.scdl2.api.entity.PlaylistEntity in project scdl by passy.

the class PlaylistServiceTest method shouldResolvePlaylist.

@Test
public void shouldResolvePlaylist() throws APIException {
    final PlaylistService service = mServiceManager.playlistService();
    final PlaylistEntity entity = service.getPlaylist("13028824");
    assertThat(entity.getDescription(), startsWith("At the tail end of 2013, few summer anthems"));
    assertThat(entity.getTracks().get(0).getId(), equalTo(116980406l));
}
Also used : PlaylistEntity(net.rdrei.android.scdl2.api.entity.PlaylistEntity) PlaylistService(net.rdrei.android.scdl2.api.service.PlaylistService) Test(org.junit.Test)

Aggregations

PlaylistEntity (net.rdrei.android.scdl2.api.entity.PlaylistEntity)3 Test (org.junit.Test)3 Parcel (android.os.Parcel)1 TrackEntity (net.rdrei.android.scdl2.api.entity.TrackEntity)1 PlaylistService (net.rdrei.android.scdl2.api.service.PlaylistService)1