Commit 13a9ccf7 authored by Hallvard Trætteberg's avatar Hallvard Trætteberg

Made it work!

parent e19f8e27
......@@ -2,7 +2,7 @@ image:
file: .gitpod.Dockerfile
tasks:
- init: sdk use java 14.0.2.j9-adpt
- init: sdk use java 14.0.2.j9-adpt && mvn org.apache.maven.plugins:maven-install-plugin:2.5.2:install-file -Dfile=libs/fx-map-control-1.0.jar
command: cd simpleexample
ports:
......
{
"java.configuration.updateBuildConfiguration": "automatic"
}
\ No newline at end of file
......@@ -7,6 +7,25 @@
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.11.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.11.2</version>
</dependency>
<dependency>
<groupId>fischer.clemens</groupId>
<artifactId>fx-map-control</artifactId>
<version>1.0</version>
</dependency>
<!-- JavaFX -->
<dependency>
<groupId>org.openjfx</groupId>
......@@ -28,6 +47,12 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>2.28.2</version>
</dependency>
<!-- Test with TextFX -->
<dependency>
<groupId>org.testfx</groupId>
......
module simpleexample {
requires transitive com.fasterxml.jackson.core;
requires transitive com.fasterxml.jackson.databind;
requires javafx.fxml;
requires transitive javafx.graphics;
requires javafx.controls;
requires fx.map.control;
exports simpleex.core;
exports simpleex.json;
exports simpleex.ui;
opens simpleex.ui to javafx.fxml;
}
......@@ -2,15 +2,18 @@ package simpleex.core;
import java.util.HashMap;
import java.util.Map;
import org.junit.Assert;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.fail;
import org.junit.jupiter.api.Test;
public class LatLongTest {
@Test
public void testToString() {
final LatLong latLong = new LatLong(63.0, 10.0);
Assert.assertEquals(Double.toString(63) + "," + Double.toString(10), latLong.toString());
assertEquals(Double.toString(63) + "," + Double.toString(10), latLong.toString());
}
@Test
......@@ -20,24 +23,24 @@ public class LatLongTest {
testLatLong(LatLong.valueOf("63.0; 10.0", ";"), 63.0, 10.0);
try {
testLatLong(LatLong.valueOf("63.0; 10.0", ","), 63.0, 10.0);
Assert.fail("Should throw IllegalArgumentException");
fail("Should throw IllegalArgumentException");
} catch (final IllegalArgumentException e) {
// ok
} catch (final Exception e) {
Assert.fail("Should throw IllegalArgumentException");
fail("Should throw IllegalArgumentException");
}
}
private void testLatLong(final LatLong latLong, final double lat, final double lon) {
Assert.assertEquals(lat, latLong.getLatitude(), 0.0);
Assert.assertEquals(lon, latLong.getLongitude(), 0.0);
assertEquals(lat, latLong.getLatitude(), 0.0);
assertEquals(lon, latLong.getLongitude(), 0.0);
}
@Test
public void testEquals() {
Assert.assertTrue(new LatLong(63.0, 10.0).equals(new LatLong(63.0, 10.0)));
Assert.assertFalse(new LatLong(10.0, 63.0).equals(new LatLong(63.0, 10.0)));
Assert.assertFalse(new LatLong(10.0, 63.0).equals(null));
assertTrue(new LatLong(63.0, 10.0).equals(new LatLong(63.0, 10.0)));
assertFalse(new LatLong(10.0, 63.0).equals(new LatLong(63.0, 10.0)));
assertFalse(new LatLong(10.0, 63.0).equals(null));
}
@Test
......@@ -45,8 +48,8 @@ public class LatLongTest {
final Map<LatLong, String> map = new HashMap<>();
map.put(new LatLong(63.0, 10.0), "first");
map.put(new LatLong(63.0, 10.0), "second");
Assert.assertEquals(1, map.size());
Assert.assertEquals("second", map.get(new LatLong(63.0, 10.0)));
assertEquals(1, map.size());
assertEquals("second", map.get(new LatLong(63.0, 10.0)));
}
@Test
......@@ -66,6 +69,6 @@ public class LatLongTest {
}
private void checkDistance(final double d, final double lower, final double upper) {
Assert.assertTrue(d + " isn't between " + lower + " and " + upper, d <= upper && d >= lower);
assertTrue(d <= upper && d >= lower, d + " isn't between " + lower + " and " + upper);
}
}
......@@ -2,33 +2,35 @@ package simpleex.core;
import java.util.Arrays;
import java.util.Iterator;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public class LatLongsTest {
private LatLongs latLongs;
@Before
@BeforeEach
public void setUp() {
latLongs = new LatLongs();
}
@Test
public void testEmptyConstructor() {
Assert.assertEquals(0, latLongs.getLatLongCount());
assertEquals(0, latLongs.getLatLongCount());
}
private static void checkLatLongs(final LatLongs latLongs1, final LatLong... latLongs2) {
Assert.assertEquals(latLongs2.length, latLongs1.getLatLongCount());
assertEquals(latLongs2.length, latLongs1.getLatLongCount());
final Iterator<LatLong> it = latLongs1.iterator();
for (int i = 0; i < latLongs2.length; i++) {
Assert.assertTrue(it.hasNext());
Assert.assertEquals(latLongs2[i], latLongs1.getLatLong(i));
Assert.assertEquals(latLongs2[i], it.next());
assertTrue(it.hasNext());
assertEquals(latLongs2[i], latLongs1.getLatLong(i));
assertEquals(latLongs2[i], it.next());
}
Assert.assertFalse(it.hasNext());
assertFalse(it.hasNext());
}
@Test
......@@ -44,9 +46,9 @@ public class LatLongsTest {
@Test
public void testAddLatLong() {
latLongs.addLatLong(new LatLong(63.0, 10.3));
Assert.assertEquals(1, latLongs.getLatLongCount());
assertEquals(1, latLongs.getLatLongCount());
latLongs.addLatLong(new LatLong(63.1, 10.2));
Assert.assertEquals(2, latLongs.getLatLongCount());
assertEquals(2, latLongs.getLatLongCount());
}
@Test
......
package simpleex.json;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Assert;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
import simpleex.core.LatLong;
import simpleex.core.LatLongs;
......@@ -15,7 +15,7 @@ public class LatLongsJsonTest {
protected void assertEqualsIgnoreWhitespace(final String expected, final String actual)
throws Exception {
Assert.assertEquals(expected, actual.replaceAll("\\s+", ""));
assertEquals(expected, actual.replaceAll("\\s+", ""));
}
@Test
......@@ -29,8 +29,8 @@ public class LatLongsJsonTest {
public void testLatLongsDeserialization() throws Exception {
final String json = "[{\"latitude\":63.1,\"longitude\":12.3}, [63.0,12.4]]";
final LatLongs latLongs = objectMapper.readValue(json, LatLongs.class);
Assert.assertEquals(2, latLongs.getLatLongCount());
Assert.assertEquals(new LatLong(63.1, 12.3), latLongs.getLatLong(0));
Assert.assertEquals(new LatLong(63.0, 12.4), latLongs.getLatLong(1));
assertEquals(2, latLongs.getLatLongCount());
assertEquals(new LatLong(63.1, 12.3), latLongs.getLatLong(0));
assertEquals(new LatLong(63.0, 12.4), latLongs.getLatLong(1));
}
}
......@@ -7,10 +7,12 @@ import fxmapcontrol.Location;
import fxmapcontrol.MapBase;
import java.util.ArrayList;
import java.util.List;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.testfx.framework.junit.ApplicationTest;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.testfx.framework.junit5.ApplicationTest;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
......@@ -22,7 +24,7 @@ import simpleex.core.LatLongs;
public class FxAppTest extends ApplicationTest {
@BeforeClass
@BeforeAll
public static void headless() {
if (Boolean.valueOf(System.getProperty("gitlab-ci", "false"))) {
System.setProperty("prism.verbose", "true"); // optional
......@@ -70,16 +72,16 @@ public class FxAppTest extends ApplicationTest {
@Test
public void testController() {
Assert.assertNotNull(this.controller);
assertNotNull(this.controller);
}
@Test
public void testLocationListView() {
final ListView<?> locationListView = lookup("#locationListView").query();
// list contains equals elements in same order
Assert.assertEquals(latLongList, locationListView.getItems());
assertEquals(latLongList, locationListView.getItems());
// first list element is auto-selected
Assert.assertEquals(0, locationListView.getSelectionModel().getSelectedIndex());
assertEquals(0, locationListView.getSelectionModel().getSelectedIndex());
}
@Test
......@@ -88,8 +90,8 @@ public class FxAppTest extends ApplicationTest {
// center of map view is approx. the first LatLong object
final Location center = mapView.getCenter();
final double epsilon = 0.000001; // round-off error
Assert.assertEquals(latLongList.get(0).getLatitude(), center.getLatitude(), epsilon);
Assert.assertEquals(latLongList.get(0).getLongitude(), center.getLongitude(), epsilon);
assertEquals(latLongList.get(0).getLatitude(), center.getLatitude(), epsilon);
assertEquals(latLongList.get(0).getLongitude(), center.getLongitude(), epsilon);
}
@Test
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment