package icepick;

import android.os.Bundle;
import junit.framework.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;

import static org.mockito.Mockito.verify;
import static org.powermock.api.mockito.PowerMockito.when;

@PrepareForTest(Bundle.class)
@RunWith(PowerMockRunner.class)
public class IcepickTest{

  static final String KEY = "KEY";
  static final String VALUE = "value";
  static final String ANOTHER_VALUE = "anotherValue";

  final Bundle state = PowerMockito.mock(Bundle.class);
  final ClassToInject classToInject = new ClassToInject();

  @Test
  public void saveState() throws Exception {
    Icepick.saveInstanceState(classToInject, state);

    verify(state).putString(KEY, VALUE);
  }

  @Test
  public void restoreState() throws Exception {
    when(state.getString(KEY)).thenReturn(ANOTHER_VALUE);

    Icepick.restoreInstanceState(classToInject, state);

    Assert.assertEquals(classToInject.string, ANOTHER_VALUE);
  }

  static class ClassToInject {
    String string = VALUE;
  }

  @SuppressWarnings("unused")
  static class ClassToInject$$Icicle {

    public static void saveInstanceState(ClassToInject target, Bundle outState) {
      outState.putString("KEY", target.string);
    }

    public static void restoreInstanceState(ClassToInject target, Bundle saveInstanceState) {
      target.string = saveInstanceState.getString("KEY");
    }
  }
}

@@ -48,24 +48,18 @@
 ort 
+org.
 junit.
-framework.
 Asse
@@ -416,17 +416,17 @@
 e.class)
-%0A
+ 
 @RunWith
@@ -473,16 +473,17 @@
 pickTest
+ 
 %7B%0A%0A  sta
@@ -506,19 +506,19 @@
  KEY = %22
-KEY
+key
 %22;%0A  sta
@@ -721,34 +721,32 @@
 ject();%0A%0A  @Test
-%0A 
  public void sav
@@ -880,18 +880,16 @@
 %0A  @Test
-%0A 
  public 

Format test