package com.vaguehope.onosendai.update;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;

import android.content.Context;

@RunWith(MockitoJUnitRunner.class)
public class BatteryNotifyTest {

	@Mock private Context context;
	@Rule public TemporaryFolder tmp = new TemporaryFolder();

	@Before
	public void before () throws Exception {
		when(this.context.getCacheDir()).thenReturn(this.tmp.getRoot());
	}

	@Test
	public void itMarksOverride () throws Exception {
		assertFalse(BatteryNotify.isOverrideEnabled(this.context));
		assertFalse(BatteryNotify.isOverrideEnabled(this.context));
		verify(this.context, times(1)).getCacheDir();

		BatteryNotify.enableOverride(this.context);
		verify(this.context, times(2)).getCacheDir();

		assertTrue(BatteryNotify.isOverrideEnabled(this.context));
		assertTrue(BatteryNotify.isOverrideEnabled(this.context));
		verify(this.context, times(3)).getCacheDir();
	}

	@Test
	public void itMarksAndResetsNotification () throws Exception {
		assertTrue(BatteryNotify.shouldNotifyNotUpdating(this.context));
		assertFalse(BatteryNotify.shouldNotifyNotUpdating(this.context));
		assertFalse(BatteryNotify.shouldNotifyNotUpdating(this.context));
		verify(this.context, times(1)).getCacheDir();

		BatteryNotify.clearNotUpdating(this.context);
		verify(this.context, times(2)).getCacheDir();

		assertTrue(BatteryNotify.shouldNotifyNotUpdating(this.context));
		assertFalse(BatteryNotify.shouldNotifyNotUpdating(this.context));
		assertFalse(BatteryNotify.shouldNotifyNotUpdating(this.context));
		verify(this.context, times(3)).getCacheDir();
	}

}

@@ -437,27 +437,65 @@
 ito.
-runners.MockitoJUni
+MockitoAnnotations;%0Aimport org.robolectric.RobolectricTes
 tRun
@@ -546,19 +546,22 @@
 ith(
-MockitoJUni
+RobolectricTes
 tRun
@@ -748,16 +748,54 @@
 ption %7B%0A
+%09%09MockitoAnnotations.initMocks(this);%0A
 %09%09when(t

Fix UnsatisfiedLinkError in BatteryNotifyTest.