// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/Session.java
// @Value
// public class Session implements Parcelable {
// 
//     public static final Parcelable.Creator<Session> CREATOR = new Parcelable.Creator<Session>() {
//         public Session createFromParcel(Parcel source) {
//             return new Session(source);
//         }
// 
//         public Session[] newArray(int size) {
//             return new Session[size];
//         }
//     };
// 
//     int id;
//     String room;
//     List<Speaker> speakers;
//     String title;
//     String description;
//     LocalDateTime fromTime;
//     LocalDateTime toTime;
// 
//     public Session(int id, String room, List<Speaker> speakers, String title, String description, LocalDateTime fromTime, LocalDateTime toTime) {
//         this.id = id;
//         this.room = room;
//         this.speakers = speakers;
//         this.title = title;
//         this.description = description;
//         this.fromTime = fromTime;
//         this.toTime = toTime;
//     }
// 
//     protected Session(Parcel in) {
//         id = in.readInt();
//         room = in.readString();
//         speakers = in.createTypedArrayList(Speaker.CREATOR);
//         title = in.readString();
//         description = in.readString();
//         fromTime = (LocalDateTime) in.readSerializable();
//         toTime = (LocalDateTime) in.readSerializable();
//     }
// 
//     @Override
//     public int describeContents() {
//         return 0;
//     }
// 
//     @Override
//     public void writeToParcel(Parcel dest, int flags) {
//         dest.writeInt(id);
//         dest.writeString(room);
//         dest.writeTypedList(speakers);
//         dest.writeString(title);
//         dest.writeString(description);
//         dest.writeSerializable(fromTime);
//         dest.writeSerializable(toTime);
//     }
// }
// 
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/Speaker.java
// @Value
// public class Speaker implements Parcelable {
// 
//     public static final Parcelable.Creator<Speaker> CREATOR = new Parcelable.Creator<Speaker>() {
//         public Speaker createFromParcel(Parcel source) {
//             return new Speaker(source);
//         }
// 
//         public Speaker[] newArray(int size) {
//             return new Speaker[size];
//         }
//     };
// 
//     int id;
//     String name;
//     String title;
//     String bio;
//     String website;
//     String twitter;
//     String github;
//     String photo;
// 
//     public Speaker(int id, String name, String title, String bio, String website, String twitter, String github, String photo) {
//         this.id = id;
//         this.name = name;
//         this.title = title;
//         this.bio = bio;
//         this.website = website;
//         this.twitter = twitter;
//         this.github = github;
//         this.photo = photo;
//     }
// 
//     protected Speaker(Parcel in) {
//         id = in.readInt();
//         name = in.readString();
//         title = in.readString();
//         bio = in.readString();
//         website = in.readString();
//         twitter = in.readString();
//         github = in.readString();
//         photo = in.readString();
//     }
// 
//     @Override
//     public int describeContents() {
//         return 0;
//     }
// 
//     @Override
//     public void writeToParcel(Parcel dest, int flags) {
//         dest.writeInt(id);
//         dest.writeString(name);
//         dest.writeString(title);
//         dest.writeString(bio);
//         dest.writeString(website);
//         dest.writeString(twitter);
//         dest.writeString(github);
//         dest.writeString(photo);
//     }
// }


import android.os.Build;
import com.nilhcem.devoxxfr.BuildConfig;
import com.nilhcem.devoxxfr.data.app.model.Session;
import com.nilhcem.devoxxfr.data.app.model.Speaker;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricGradleTestRunner;
import org.robolectric.annotation.Config;
import org.threeten.bp.LocalDateTime;
import java.util.Arrays;
import java.util.List;
import static com.google.common.truth.Truth.assertThat;
package com.nilhcem.devoxxfr.data.app;






@RunWith(RobolectricGradleTestRunner.class)
@Config(constants = BuildConfig.class, sdk = Build.VERSION_CODES.LOLLIPOP)
public class DataProviderCacheTest {

    private final DataProviderCache cache = new DataProviderCache();

    private final Session session1 = new Session(1, null, null, null, null, null, null);
    private final Session session2 = new Session(2, null, null, null, null, null, null);
    private final List<Session> sessions = Arrays.asList(session1, session2);

    private final Speaker speaker1 = new Speaker(1, null, null, null, null, null, null, null);
    private final Speaker speaker2 = new Speaker(1, null, null, null, null, null, null, null);
    private final List<Speaker> speakers = Arrays.asList(speaker1, speaker2);

    @Test
    public void should_save_sessions_in_memory_keeping_save_time() {
        // Given When
        LocalDateTime before = LocalDateTime.now();
        cache.saveSessions(sessions);
        LocalDateTime after = LocalDateTime.now();

        // Then
        assertThat(cache.sessions).hasSize(2);
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/Session.java
// @Value
// public class Session implements Parcelable {
// 
//     public static final Parcelable.Creator<Session> CREATOR = new Parcelable.Creator<Session>() {
//         public Session createFromParcel(Parcel source) {
//             return new Session(source);
//         }
// 
//         public Session[] newArray(int size) {
//             return new Session[size];
//         }
//     };
// 
//     int id;
//     String room;
//     List<Speaker> speakers;
//     String title;
//     String description;
//     LocalDateTime fromTime;
//     LocalDateTime toTime;
// 
//     public Session(int id, String room, List<Speaker> speakers, String title, String description, LocalDateTime fromTime, LocalDateTime toTime) {
//         this.id = id;
//         this.room = room;
//         this.speakers = speakers;
//         this.title = title;
//         this.description = description;
//         this.fromTime = fromTime;
//         this.toTime = toTime;
//     }
// 
//     protected Session(Parcel in) {
//         id = in.readInt();
//         room = in.readString();
//         speakers = in.createTypedArrayList(Speaker.CREATOR);
//         title = in.readString();
//         description = in.readString();
//         fromTime = (LocalDateTime) in.readSerializable();
//         toTime = (LocalDateTime) in.readSerializable();
//     }
// 
//     @Override
//     public int describeContents() {
//         return 0;
//     }
// 
//     @Override
//     public void writeToParcel(Parcel dest, int flags) {
//         dest.writeInt(id);
//         dest.writeString(room);
//         dest.writeTypedList(speakers);
//         dest.writeString(title);
//         dest.writeString(description);
//         dest.writeSerializable(fromTime);
//         dest.writeSerializable(toTime);
//     }
// }
// 
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/Speaker.java
// @Value
// public class Speaker implements Parcelable {
// 
//     public static final Parcelable.Creator<Speaker> CREATOR = new Parcelable.Creator<Speaker>() {
//         public Speaker createFromParcel(Parcel source) {
//             return new Speaker(source);
//         }
// 
//         public Speaker[] newArray(int size) {
//             return new Speaker[size];
//         }
//     };
// 
//     int id;
//     String name;
//     String title;
//     String bio;
//     String website;
//     String twitter;
//     String github;
//     String photo;
// 
//     public Speaker(int id, String name, String title, String bio, String website, String twitter, String github, String photo) {
//         this.id = id;
//         this.name = name;
//         this.title = title;
//         this.bio = bio;
//         this.website = website;
//         this.twitter = twitter;
//         this.github = github;
//         this.photo = photo;
//     }
// 
//     protected Speaker(Parcel in) {
//         id = in.readInt();
//         name = in.readString();
//         title = in.readString();
//         bio = in.readString();
//         website = in.readString();
//         twitter = in.readString();
//         github = in.readString();
//         photo = in.readString();
//     }
// 
//     @Override
//     public int describeContents() {
//         return 0;
//     }
// 
//     @Override
//     public void writeToParcel(Parcel dest, int flags) {
//         dest.writeInt(id);
//         dest.writeString(name);
//         dest.writeString(title);
//         dest.writeString(bio);
//         dest.writeString(website);
//         dest.writeString(twitter);
//         dest.writeString(github);
//         dest.writeString(photo);
//     }
// }


// Path: app/src/test/java/com/nilhcem/devoxxfr/data/app/DataProviderCacheTest.java
import android.os.Build;
import com.nilhcem.devoxxfr.BuildConfig;
import com.nilhcem.devoxxfr.data.app.model.Session;
import com.nilhcem.devoxxfr.data.app.model.Speaker;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricGradleTestRunner;
import org.robolectric.annotation.Config;
import org.threeten.bp.LocalDateTime;
import java.util.Arrays;
import java.util.List;
import static com.google.common.truth.Truth.assertThat;

package com.nilhcem.devoxxfr.data.app;






@RunWith(RobolectricGradleTestRunner.class)
@Config(constants = BuildConfig.class, sdk = Build.VERSION_CODES.LOLLIPOP)
public class DataProviderCacheTest {

    private final DataProviderCache cache = new DataProviderCache();

    private final Session session1 = new Session(1, null, null, null, null, null, null);
    private final Session session2 = new Session(2, null, null, null, null, null, null);
    private final List<Session> sessions = Arrays.asList(session1, session2);

    private final Speaker speaker1 = new Speaker(1, null, null, null, null, null, null, null);
    private final Speaker speaker2 = new Speaker(1, null, null, null, null, null, null, null);
    private final List<Speaker> speakers = Arrays.asList(speaker1, speaker2);

    @Test
    public void should_save_sessions_in_memory_keeping_save_time() {
        // Given When
        LocalDateTime before = LocalDateTime.now();
        cache.saveSessions(sessions);
        LocalDateTime after = LocalDateTime.now();

        // Then
        assertThat(cache.sessions).hasSize(2);
        assertThat(cache.sessionsFetchedTime).isAtLeast(before);