// Path: src/main/java/com/knewton/mapreduce/io/StudentEventWritable.java
// public static class StudentEventIdComparator implements Comparator<StudentEventWritable> {
// 
//     @Override
//     public int compare(StudentEventWritable sew1, StudentEventWritable sew2) {
//         return new Long(sew1.studentEvent.getId()).compareTo(sew2.studentEvent.getId());
//     }
// }
// 
// Path: src/main/java/com/knewton/mapreduce/io/StudentEventWritable.java
// public static class StudentEventTimestampComparator implements Comparator<StudentEventWritable> {
// 
//     @Override
//     public int compare(StudentEventWritable sew1, StudentEventWritable sew2) {
//         // Use LongComparator. Takes care of overflows.
//         return new Long(sew1.timestamp).compareTo(sew2.timestamp);
//     }
// }


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import com.knewton.mapreduce.io.StudentEventWritable.StudentEventIdComparator;
import com.knewton.mapreduce.io.StudentEventWritable.StudentEventTimestampComparator;
import com.knewton.thrift.StudentEvent;
import com.knewton.thrift.StudentEventData;
import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.util.Random;
        StudentEvent seEvent = new StudentEvent(10L, seData);

        StudentEventWritable seWritable = new StudentEventWritable(seEvent, 100L);
        StudentEventWritable clonedWritable = seWritable.clone();

        assertEquals(seWritable.getStudentEvent(), clonedWritable.getStudentEvent());
        assertEquals(seWritable.getTimestamp(), clonedWritable.getTimestamp());
    }

    @Test
    public void testCompareTimestamp() {
        StudentEventTimestampComparator comparator = new StudentEventTimestampComparator();
        StudentEventWritable smaller = new StudentEventWritable(new StudentEvent(), 1L);
        StudentEventWritable bigger = new StudentEventWritable(new StudentEvent(), 2L);
        assertTrue(comparator.compare(smaller, bigger) < 0);
        assertTrue(comparator.compare(bigger, smaller) > 0);
        assertEquals(0, comparator.compare(smaller, smaller));
    }

    @Test
    public void testCompareStudentEventId() {
        StudentEventIdComparator comparator = new StudentEventIdComparator();
        StudentEvent seSmaller = new StudentEvent(1L, new StudentEventData());
        StudentEventWritable smaller = new StudentEventWritable(seSmaller, 2L);

        StudentEvent seBigger = new StudentEvent(2L, new StudentEventData());
        StudentEventWritable bigger = new StudentEventWritable(seBigger, 2L);

        assertTrue(comparator.compare(smaller, bigger) < 0);
        assertTrue(comparator.compare(bigger, smaller) > 0);
// Path: src/main/java/com/knewton/mapreduce/io/StudentEventWritable.java
// public static class StudentEventIdComparator implements Comparator<StudentEventWritable> {
// 
//     @Override
//     public int compare(StudentEventWritable sew1, StudentEventWritable sew2) {
//         return new Long(sew1.studentEvent.getId()).compareTo(sew2.studentEvent.getId());
//     }
// }
// 
// Path: src/main/java/com/knewton/mapreduce/io/StudentEventWritable.java
// public static class StudentEventTimestampComparator implements Comparator<StudentEventWritable> {
// 
//     @Override
//     public int compare(StudentEventWritable sew1, StudentEventWritable sew2) {
//         // Use LongComparator. Takes care of overflows.
//         return new Long(sew1.timestamp).compareTo(sew2.timestamp);
//     }
// }


// Path: src/test/java/com/knewton/mapreduce/io/StudentEventWritableTest.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import com.knewton.mapreduce.io.StudentEventWritable.StudentEventIdComparator;
import com.knewton.mapreduce.io.StudentEventWritable.StudentEventTimestampComparator;
import com.knewton.thrift.StudentEvent;
import com.knewton.thrift.StudentEventData;
import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.util.Random;

        StudentEvent seEvent = new StudentEvent(10L, seData);

        StudentEventWritable seWritable = new StudentEventWritable(seEvent, 100L);
        StudentEventWritable clonedWritable = seWritable.clone();

        assertEquals(seWritable.getStudentEvent(), clonedWritable.getStudentEvent());
        assertEquals(seWritable.getTimestamp(), clonedWritable.getTimestamp());
    }

    @Test
    public void testCompareTimestamp() {
        StudentEventTimestampComparator comparator = new StudentEventTimestampComparator();
        StudentEventWritable smaller = new StudentEventWritable(new StudentEvent(), 1L);
        StudentEventWritable bigger = new StudentEventWritable(new StudentEvent(), 2L);
        assertTrue(comparator.compare(smaller, bigger) < 0);
        assertTrue(comparator.compare(bigger, smaller) > 0);
        assertEquals(0, comparator.compare(smaller, smaller));
    }

    @Test
    public void testCompareStudentEventId() {
        StudentEventIdComparator comparator = new StudentEventIdComparator();
        StudentEvent seSmaller = new StudentEvent(1L, new StudentEventData());
        StudentEventWritable smaller = new StudentEventWritable(seSmaller, 2L);

        StudentEvent seBigger = new StudentEvent(2L, new StudentEventData());
        StudentEventWritable bigger = new StudentEventWritable(seBigger, 2L);

        assertTrue(comparator.compare(smaller, bigger) < 0);
        assertTrue(comparator.compare(bigger, smaller) > 0);
        assertEquals(0, comparator.compare(smaller, smaller));