package io.github.plastix.forage.data.local;

import android.location.Location;

import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;

import io.github.plastix.forage.ForageRoboelectricUnitTestRunner;
import io.github.plastix.forage.data.local.model.RealmLocation;

import static com.google.common.truth.Truth.assertThat;

@Ignore("Roboelectric problems")
@RunWith(ForageRoboelectricUnitTestRunner.class)
public class RealmLocationTest {

    @Test
    public void toLocation_shouldReturnCorrectLocation() {
        double lat = 40.7127;
        double lon = 74.0059;

        RealmLocation realmLocation = new RealmLocation();
        realmLocation.latitude = lat;
        realmLocation.longitude = lon;

        Location location = realmLocation.toLocation();

        assertThat(location.getLatitude()).isWithin(0.0).of(lat);
        assertThat(location.getLongitude()).isWithin(0.0).of(lon);
    }
}

@@ -91,19 +91,19 @@
 g.junit.
-Ign
+Bef
 ore;%0Aimp
@@ -159,75 +159,174 @@
 th;%0A
-%0A
 import 
-io.github.plastix.forage.ForageRoboelectricUnitTest
+org.powermock.api.mockito.PowerMockito;%0Aimport org.powermock.core.classloader.annotations.PrepareForTest;%0Aimport org.powermock.modules.junit4.PowerMock
 Runner;%0A
 impo
@@ -321,16 +321,17 @@
 Runner;%0A
+%0A
 import i
@@ -377,32 +377,84 @@
 l.RealmLocation;
+%0Aimport io.github.plastix.forage.util.LocationUtils;
 %0A%0Aimport static 
@@ -499,123 +499,298 @@
 at;%0A
-%0A@Ignore(%22Roboelectric problems%22)%0A@RunWith(ForageRoboelectricUnitTestRunner.class)%0Apublic class RealmLocationTest %7B
+import static org.mockito.Mockito.mock;%0Aimport static org.mockito.Mockito.when;%0A%0A@RunWith(PowerMockRunner.class)%0A@PrepareForTest(LocationUtils.class)%0Apublic class RealmLocationTest %7B%0A%0A    @Before%0A    public void beforeEachTest() %7B%0A        PowerMockito.mockStatic(LocationUtils.class);%0A    %7D
 %0A%0A  
@@ -834,29 +834,20 @@
 ould
-ReturnCorrect
+Call
 Location
 () %7B
@@ -842,16 +842,21 @@
 Location
+Utils
 () %7B%0A   
@@ -1058,24 +1058,29 @@
         
+realm
 Location
  locatio
@@ -1075,123 +1075,517 @@
 tion
- l
+.toL
 ocation
- = realmLocation.toLocation();%0A%0A        assertThat(location.getLatitude()).isWithin(0.0).of(lat
+();%0A%0A        PowerMockito.verifyStatic();%0A        LocationUtils.buildLocation(lat, lon);%0A    %7D%0A%0A    @Test%0A    public void toLocation_shouldReturnFromLocationUtils() %7B%0A        double lat = 40.7127;%0A        double lon = 74.0059;%0A%0A        RealmLocation realmLocation = new RealmLocation();%0A        realmLocation.latitude = lat;%0A        realmLocation.longitude = lon;%0A%0A        Location location = mock(Location.class);%0A        when(LocationUtils.buildLocation(lat, lon)).thenReturn(location
 );%0A
+%0A
         
 asse
@@ -1584,62 +1584,97 @@
     
-assertThat(location.getLongitude()).isWithin(0.0).of(l
+Location result = realmLocation.toLocation();%0A%0A        assertThat(result).isSameAs(locati
 on);

Switch to PowerMock for RealmLocation unit tests