package de.stephanlindauer.criticalmaps.model;

import org.junit.Test;
import org.osmdroid.util.GeoPoint;

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

public class OwnLocationModelTest {
    @Test
    public void hasPreciseLocation_impreciseLocationIsReportedAsImprecise() {
        OwnLocationModel tested = new OwnLocationModel();

        tested.setLocation(new GeoPoint(0d, 0d), 50.0f);

        assertThat(tested.hasPreciseLocation()).isFalse();
    }

    @Test
    public void hasPreciseLocation_preciseLocationIsReportedAsPrecise() {
        OwnLocationModel tested = new OwnLocationModel();

        tested.setLocation(new GeoPoint(0d, 0d), 49.9f);

        assertThat(tested.hasPreciseLocation()).isTrue();
    }

    @Test(expected = NullPointerException.class)
    public void getLocationJson_throwsWhenNoLocation() {
        // TODO use JUnit's assertThrows() instead when 4.13 is out
        OwnLocationModel tested = new OwnLocationModel();
        tested.getLocationJson();
    }

    @Test
    public void getLocationJson_returnsCorrectJson() {
        OwnLocationModel tested = new OwnLocationModel();

        String expected = "{\"latitude\":\"40741895\",\"longitude\":\"-73989308\"}";
        tested.setLocation(new GeoPoint(40.741895d, -73.989308d), 1.1f);
        assertThat(tested.getLocationJson().toString()).isEqualTo(expected);
    }
}

@@ -155,16 +155,61 @@
 ertThat;
+%0Aimport static org.junit.Assert.assertThrows;
 %0A%0Apublic
@@ -788,47 +788,8 @@
 Test
-(expected = NullPointerException.class)
 %0A   
@@ -846,76 +846,8 @@
 ) %7B%0A
-        // TODO use JUnit's assertThrows() instead when 4.13 is out%0A
     
@@ -900,31 +900,74 @@
 odel();%0A
+%0A
        
+ assertThrows(NullPointerException.class,
  tested
-.
+::
 getLocat
@@ -973,17 +973,16 @@
 tionJson
-(
 );%0A    %7D

Use Assert#assertThrows.