package app.intra.util;

import android.os.Parcel;

import org.junit.Test;

import static org.junit.Assert.*;

public class AppInfoTest {
  final String LABEL1 = "label1", LABEL2 = "label2";
  final String NAME1 = "name.1", NAME2 = "name.2";
  final AppInfo APP1 = new AppInfo(LABEL1, NAME1);
  final AppInfo APP2 = new AppInfo(LABEL2, NAME2);
  final AppInfo NULL1 = new AppInfo(null, NAME1);
  final AppInfo NULL2 = new AppInfo(null, NAME2);

  @Test
  public void equal() {
    assertEquals(0, APP1.compareTo(new AppInfo(LABEL1, NAME1)));
    assertEquals(0, NULL1.compareTo(new AppInfo(null, NAME1)));
    assertEquals(0, APP1.compareTo(APP1));
    assertEquals(0, NULL1.compareTo(NULL1));
  }

  @Test
  public void notEqual() {
    assertEquals(-1, APP1.compareTo(APP2));
    assertEquals(1, APP2.compareTo(APP1));
    assertEquals(-1, APP1.compareTo(NULL1));
    assertEquals(1, NULL1.compareTo(APP1));
    assertEquals(-1, APP2.compareTo(NULL2));
    assertEquals(1, NULL2.compareTo(APP2));
    assertEquals(-1, APP2.compareTo(NULL1));
    assertEquals(1, NULL1.compareTo(APP2));
    assertEquals(-1, NULL1.compareTo(NULL2));
    assertEquals(1, NULL2.compareTo(NULL1));
  }

  private void roundtrip(AppInfo info) {
    Parcel parcel1 = Parcel.obtain();
    info.writeToParcel(parcel1, 0);
    byte[] data = parcel1.marshall();
    parcel1.recycle();
    Parcel parcel2 = Parcel.obtain();
    parcel2.unmarshall(data, 0, data.length);
    parcel2.setDataPosition(0);
    AppInfo copy = AppInfo.CREATOR.createFromParcel(parcel2);
    parcel2.recycle();
    assertEquals(0, info.compareTo(copy));
  }

  @Test
  public void writeToParcel() {
    roundtrip(APP1);
    roundtrip(NULL1);
  }
}
@@ -460,17 +460,26 @@
 ic void 
-e
+compareToE
 qual() %7B
@@ -727,12 +727,20 @@
 oid 
-notE
+compareToUne
 qual
@@ -1209,17 +1209,42 @@
 te void 
-r
+verifyParcelSerializationR
 oundtrip
@@ -1692,30 +1692,80 @@
     
-roundtrip(APP1);%0A    r
+verifyParcelSerializationRoundtrip(APP1);%0A    verifyParcelSerializationR
 ound

Rename test methods