package org.robolectric.res.builder;

import android.content.Intent;

import org.assertj.core.api.Assertions;
import org.junit.Test;

import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

public class DefaultPackageManagerIntentComparatorTest {

  @Test
  public void validCompareResult() {
    final DefaultPackageManager.IntentComparator intentComparator = new DefaultPackageManager.IntentComparator();

    Assertions.assertThat(intentComparator.compare(null, null)).isEqualTo(0);
    Assertions.assertThat(intentComparator.compare(new Intent(), null)).isEqualTo(1);
    Assertions.assertThat(intentComparator.compare(null, new Intent())).isEqualTo(-1);

    Intent intent1 = new Intent();
    Intent intent2 = new Intent();

    Assertions.assertThat(intentComparator.compare(intent1, intent2)).isEqualTo(0);
  }

  @Test
  public void canSustainConcurrentModification() {
    final DefaultPackageManager.IntentComparator intentComparator = new DefaultPackageManager.IntentComparator();

    Intent mockedIntent1 = mock(Intent.class);
    when(mockedIntent1.getAction()).thenReturn("actionstring0", (String) null);

    Intent mockedIntent2 = mock(Intent.class);
    when(mockedIntent2.getAction()).thenReturn("actionstring1", (String) null);

    Assertions.assertThat(intentComparator.compare(mockedIntent1, mockedIntent2)).isEqualTo(-1);
  }

}

@@ -1019,31 +1019,25 @@
 %0A    Intent 
-mockedI
+i
 ntent1 = moc
@@ -1037,74 +1037,18 @@
 1 = 
-mock(Intent.class);%0A    when(mockedIntent1.getAction()).thenReturn
+new Intent
 (%22ac
@@ -1059,35 +1059,19 @@
 string0%22
-, (String) null
 );%0A
-%0A
     Inte
@@ -1073,23 +1073,17 @@
  Intent 
-mockedI
+i
 ntent2 =
@@ -1087,74 +1087,18 @@
 2 = 
-mock(Intent.class);%0A    when(mockedIntent2.getAction()).thenReturn
+new Intent
 (%22ac
@@ -1113,27 +1113,11 @@
 ng1%22
-, (String) null
 );%0A
-%0A
     
@@ -1167,23 +1167,17 @@
 are(
-mockedI
+i
 ntent1, 
 mock
@@ -1176,15 +1176,9 @@
 t1, 
-mockedI
+i
 nten

Remove unnecessary Intent mocking.