Skip to content
Snippets Groups Projects
Unverified Commit a1ef89e9 authored by User expired's avatar User expired
Browse files

fixing broken tests; adding paackage it.unibz.inf.isochrone.algorithm.tile

parent 17b9260b
No related branches found
No related tags found
No related merge requests found
Showing
with 520 additions and 317 deletions
Upcoming version:
-----------------
- fixing broken tests; adding paackage it.unibz.inf.isochrone.algorithm.tile (Nikolaus Krismer)
- fixed some findbugs warnings (Nikolaus Krismer)
- implemented various different types for node queue (Nikolaus Krismer)
- externalizing dependency versions (Nikolaus Krismer)
......
......@@ -2,11 +2,7 @@ package it.unibz.inf.isochrone.algorithm;
import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.geom.GeometryFactory;
import com.vividsolutions.jts.geom.Point;
import com.vividsolutions.jts.geom.PrecisionModel;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
......@@ -20,6 +16,8 @@ import java.util.Set;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import it.unibz.inf.isochrone.algorithm.tile.TileNumber;
import it.unibz.inf.isochrone.algorithm.tile.ZoomInformation;
import it.unibz.inf.isochrone.config.ConfigAlgorithm;
import it.unibz.inf.isochrone.config.ConfigDataset;
import it.unibz.inf.isochrone.db.Database;
......@@ -36,262 +34,6 @@ import it.unibz.inf.isochrone.util.GeoHelperException;
*/
public class MineT extends Mine {
private static final Logger LOGGER = LogManager.getLogger(MineT.class);
private static final int SRID_CALC_TILENUMBER = 4326;
public static final class TileNumber implements Serializable {
public static class BoundingBox {
private final double east;
private final double north;
private final double south;
private final double west;
// Constructor
public BoundingBox(final double north, final double south, final double west, final double east) {
super();
this.east = east;
this.north = north;
this.south = south;
this.west = west;
}
// Getters
public double getEast() {
return east;
}
public double getNorth() {
return north;
}
public double getSouth() {
return south;
}
public double getWest() {
return west;
}
}
private static final long serialVersionUID = -8787007176073126408L;
private final Point seed;
private final int zoomLevel;
private final int x;
private final int y;
private boolean deprecated;
// Constructor
/**
* Creates a tile by a node located inside the tile.
*
* @param lon the longitude of the node
* @param lat the latitude of the node
* @param zoom the zoom level of the tile to create
*/
public TileNumber(final double lon, final double lat, final byte zoom) {
// CHECKSTYLE:OFF MagicNumber
int xtile = (int) Math.floor((lon + 180) / 360 * (1 << zoom));
int ytile = (int) Math.floor((1 - Math.log(Math.tan(Math.toRadians(lat)) + 1 / Math.cos(Math.toRadians(lat))) / Math.PI) / 2 * (1 << zoom));
// CHECKSTYLE:ON MagicNumber
if (xtile < 0) {
xtile = 0;
}
if (xtile >= (1 << zoom)) {
xtile = ((1 << zoom) - 1);
}
if (ytile < 0) {
ytile = 0;
}
if (ytile >= (1 << zoom)) {
ytile = ((1 << zoom) - 1);
}
this.seed = new GeometryFactory(new PrecisionModel(), SRID_CALC_TILENUMBER).createPoint(new Coordinate(lon, lat));
this.x = xtile;
this.y = ytile;
this.zoomLevel = zoom;
}
// Getters
public BoundingBox getBoundingBox() {
return new BoundingBox(
tile2lat(y, zoomLevel),
tile2lat(y + 1, zoomLevel),
tile2lon(x, zoomLevel),
tile2lon(x + 1, zoomLevel)
);
}
public Point getSeed() {
return seed;
}
public int getX() {
return x;
}
public int getY() {
return y;
}
public int getZoomLevel() {
return zoomLevel;
}
public boolean isDeprecated() {
return deprecated;
}
// Setters
public void setDeprecated(final boolean deprecated) {
this.deprecated = deprecated;
}
// Public methods
@Override
public String toString() {
return "TileEntry [zoomLevel=" + zoomLevel + ", x=" + x + ", y=" + y + "]";
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + x;
result = prime * result + y;
result = prime * result + zoomLevel;
return result;
}
@Override
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final TileNumber other = (TileNumber) obj;
if (x != other.x) {
return false;
}
if (y != other.y) {
return false;
}
if (zoomLevel != other.zoomLevel) {
return false;
}
return true;
}
// Private static methods
private static double tile2lat(final int y, final int z) {
final double n = Math.PI - (2.0 * Math.PI * y) / Math.pow(2.0, z);
return Math.toDegrees(Math.atan(Math.sinh(n)));
}
private static double tile2lon(final int x, final int z) {
// CHECKSTYLE:OFF MagicNumber
return x / Math.pow(2.0, z) * 360.0 - 180;
// CHECKSTYLE:ON MagicNumber
}
}
public static final class ZoomInformation implements Serializable, Comparable<ZoomInformation> {
private static final long serialVersionUID = -6111898218753286677L;
private final int fromDuration;
private final byte zoomLevel;
// Constructor
public ZoomInformation(final int fromDuration, final byte zoomLevel) {
if (fromDuration < 0) {
throw new IllegalArgumentException("FromDuration can not be negative!");
}
if (zoomLevel < 0) {
throw new IllegalArgumentException("ZoomLevel can not be negative!");
}
this.fromDuration = fromDuration;
this.zoomLevel = zoomLevel;
}
public ZoomInformation(final byte zoomLevel) {
this(0, zoomLevel);
}
// Getter
public int getFromDuration() {
return fromDuration;
}
public byte getZoomLevel() {
return zoomLevel;
}
// Public methods
@Override
public int compareTo(final ZoomInformation z) {
if (z == null) {
return -1;
}
final int v = (-1) * Integer.compare(fromDuration, z.fromDuration);
if (v != 0) {
return v;
}
return (-1) * Byte.compare(zoomLevel, z.zoomLevel);
}
@Override
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final ZoomInformation other = (ZoomInformation) obj;
if (fromDuration != other.fromDuration) {
return false;
}
if (zoomLevel != other.zoomLevel) {
return false;
}
return true;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + fromDuration;
result = prime * result + zoomLevel;
return result;
}
@Override
public String toString() {
return "ZoomInformation [fromDuration=" + fromDuration + ", zoomLevel=" + zoomLevel + "]";
}
}
private final GeoHelper gHelper;
private final Map<Integer, Collection<IEdge>> loadedEdges;
private final int serverSRID;
......@@ -426,7 +168,7 @@ public class MineT extends Mine {
}
try {
geom = gHelper.convert(serverSRID, SRID_CALC_TILENUMBER, geom);
geom = gHelper.convert(serverSRID, TileNumber.SRID_CALC_TILENUMBER, geom);
} catch (final GeoHelperException e) {
LOGGER.warn("Could not convert node coordinates into EOSG:4362. This will most likely lead to worse performance (and loading the same tile multiple times)");
}
......
......@@ -2,6 +2,7 @@ package it.unibz.inf.isochrone.algorithm;
import java.util.List;
import it.unibz.inf.isochrone.algorithm.tile.ZoomInformation;
import it.unibz.inf.isochrone.config.ConfigAlgorithm;
import it.unibz.inf.isochrone.db.Database;
......
package it.unibz.inf.isochrone.algorithm.tile;
public class BoundingBox {
private final double east;
private final double north;
private final double south;
private final double west;
// Constructor
public BoundingBox(final double north, final double south, final double west, final double east) {
super();
this.east = east;
this.north = north;
this.south = south;
this.west = west;
}
// Getters
public double getEast() {
return east;
}
public double getNorth() {
return north;
}
public double getSouth() {
return south;
}
public double getWest() {
return west;
}
// Public methds
@Override
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final BoundingBox other = (BoundingBox) obj;
if (Double.doubleToLongBits(east) != Double.doubleToLongBits(other.east)) {
return false;
}
if (Double.doubleToLongBits(north) != Double.doubleToLongBits(other.north)) {
return false;
}
if (Double.doubleToLongBits(south) != Double.doubleToLongBits(other.south)) {
return false;
}
if (Double.doubleToLongBits(west) != Double.doubleToLongBits(other.west)) {
return false;
}
return true;
}
@Override
public int hashCode() {
// CHECKSTYLE:OFF MagicNumber
final int prime = 31;
int result = 1;
long temp;
temp = Double.doubleToLongBits(east);
result = prime * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(north);
result = prime * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(south);
result = prime * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(west);
result = prime * result + (int) (temp ^ (temp >>> 32));
// CHECKSTYLE:ON MagicNumber
return result;
}
}
package it.unibz.inf.isochrone.algorithm.tile;
import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.GeometryFactory;
import com.vividsolutions.jts.geom.Point;
import com.vividsolutions.jts.geom.PrecisionModel;
import java.io.Serializable;
public class TileNumber implements Serializable {
public static final int SRID_CALC_TILENUMBER = 4326;
private static final long serialVersionUID = -8787007176073126408L;
private final Point seed;
private final int zoomLevel;
private final int x;
private final int y;
private boolean deprecated;
// Constructor
/**
* Creates a tile by a node located inside the tile.
*
* @param lon the longitude of the node
* @param lat the latitude of the node
* @param zoom the zoom level of the tile to create
*/
public TileNumber(final double lon, final double lat, final byte zoom) {
// CHECKSTYLE:OFF MagicNumber
int xtile = (int) Math.floor((lon + 180) / 360 * (1 << zoom));
int ytile = (int) Math.floor((1 - Math.log(Math.tan(Math.toRadians(lat)) + 1 / Math.cos(Math.toRadians(lat))) / Math.PI) / 2 * (1 << zoom));
// CHECKSTYLE:ON MagicNumber
if (xtile < 0) {
xtile = 0;
}
if (xtile >= (1 << zoom)) {
xtile = ((1 << zoom) - 1);
}
if (ytile < 0) {
ytile = 0;
}
if (ytile >= (1 << zoom)) {
ytile = ((1 << zoom) - 1);
}
this.seed = new GeometryFactory(new PrecisionModel(), SRID_CALC_TILENUMBER).createPoint(new Coordinate(lon, lat));
this.x = xtile;
this.y = ytile;
this.zoomLevel = zoom;
}
// Getters
public BoundingBox getBoundingBox() {
return new BoundingBox(tile2lat(y, zoomLevel), tile2lat(y + 1, zoomLevel), tile2lon(x, zoomLevel), tile2lon(x + 1, zoomLevel));
}
public Point getSeed() {
return seed;
}
public int getX() {
return x;
}
public int getY() {
return y;
}
public int getZoomLevel() {
return zoomLevel;
}
public boolean isDeprecated() {
return deprecated;
}
// Setters
public void setDeprecated(final boolean deprecated) {
this.deprecated = deprecated;
}
// Public methods
@Override
public String toString() {
return "TileEntry [zoomLevel=" + zoomLevel + ", x=" + x + ", y=" + y + "]";
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + x;
result = prime * result + y;
result = prime * result + zoomLevel;
return result;
}
@Override
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final TileNumber other = (TileNumber) obj;
if (x != other.x) {
return false;
}
if (y != other.y) {
return false;
}
if (zoomLevel != other.zoomLevel) {
return false;
}
return true;
}
// Private static methods
private static double tile2lat(final int y, final int z) {
final double n = Math.PI - (2.0 * Math.PI * y) / Math.pow(2.0, z);
return Math.toDegrees(Math.atan(Math.sinh(n)));
}
private static double tile2lon(final int x, final int z) {
// CHECKSTYLE:OFF MagicNumber
return x / Math.pow(2.0, z) * 360.0 - 180;
// CHECKSTYLE:ON MagicNumber
}
}
package it.unibz.inf.isochrone.algorithm.tile;
import java.io.Serializable;
public class ZoomInformation implements Serializable, Comparable<ZoomInformation> {
private static final long serialVersionUID = -6111898218753286677L;
private final int fromDuration;
private final byte zoomLevel;
// Constructor
public ZoomInformation(final int fromDuration, final byte zoomLevel) {
if (fromDuration < 0) {
throw new IllegalArgumentException("FromDuration can not be negative!");
}
if (zoomLevel < 0) {
throw new IllegalArgumentException("ZoomLevel can not be negative!");
}
this.fromDuration = fromDuration;
this.zoomLevel = zoomLevel;
}
public ZoomInformation(final byte zoomLevel) {
this(0, zoomLevel);
}
// Getter
public int getFromDuration() {
return fromDuration;
}
public byte getZoomLevel() {
return zoomLevel;
}
// Public methods
@Override
public int compareTo(final ZoomInformation z) {
if (z == null) {
return -1;
}
final int v = (-1) * Integer.compare(fromDuration, z.fromDuration);
if (v != 0) {
return v;
}
return (-1) * Byte.compare(zoomLevel, z.zoomLevel);
}
@Override
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final ZoomInformation other = (ZoomInformation) obj;
if (fromDuration != other.fromDuration) {
return false;
}
if (zoomLevel != other.zoomLevel) {
return false;
}
return true;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + fromDuration;
result = prime * result + zoomLevel;
return result;
}
@Override
public String toString() {
return "ZoomInformation [fromDuration=" + fromDuration + ", zoomLevel=" + zoomLevel + "]";
}
}
......@@ -485,6 +485,7 @@ public final class ConfigAlgorithm implements Serializable {
result = prime * result + ((travelSpeed == null) ? 0 : travelSpeed.hashCode());
result = prime * result + (useCache ? 1231 : 1237);
result = prime * result + (useIncrementalCache ? 1231 : 1237);
result = prime * result + ((userProfile == null) ? 0 : userProfile.hashCode());
// CHECKSTYLE:ON MagicNumber
return result;
......
......@@ -38,7 +38,7 @@ import org.apache.commons.jcs.access.CacheAccess;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import it.unibz.inf.isochrone.algorithm.MineT.ZoomInformation;
import it.unibz.inf.isochrone.algorithm.tile.ZoomInformation;
import it.unibz.inf.isochrone.db.DbType;
import it.unibz.inf.isochrone.db.DbUtils;
......
......@@ -37,9 +37,9 @@ import org.apache.logging.log4j.Logger;
import at.uibk.dbis.isochrone.profile.WayType;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import it.unibz.inf.isochrone.algorithm.MineT;
import it.unibz.inf.isochrone.config.ConfigAlgorithm.Direction;
import it.unibz.inf.isochrone.config.ConfigAlgorithm.Mode;
import it.unibz.inf.isochrone.algorithm.tile.TileNumber;
import it.unibz.inf.isochrone.config.ConfigDataset;
import it.unibz.inf.isochrone.config.ConfigIsochrone;
import it.unibz.inf.isochrone.network.Edge;
......@@ -732,7 +732,7 @@ public class Database implements AutoCloseable {
return results;
}
public Map<Integer, Collection<IEdge>> loadNetworkTileInformation(final MineT.TileNumber tileNr, final Map<Integer, INode> nodes) {
public Map<Integer, Collection<IEdge>> loadNetworkTileInformation(final TileNumber tileNr, final Map<Integer, INode> nodes) {
final IDbQuery dbQuery = query.getEdgesInTileInformation(mode);
final Map<Integer, Collection<IEdge>> results = new HashMap<>();
......
......@@ -44,6 +44,57 @@ public final class DbTable {
// Public methods
@Override
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final DbTable other = (DbTable) obj;
if (hasGeomColumn != other.hasGeomColumn) {
return false;
}
if (indexName == null) {
if (other.indexName != null) {
return false;
}
} else if (!indexName.equals(other.indexName)) {
return false;
}
if (tableName == null) {
if (other.tableName != null) {
return false;
}
} else if (!tableName.equals(other.tableName)) {
return false;
}
if (type != other.type) {
return false;
}
return true;
}
@Override
public int hashCode() {
// CHECKSTYLE:OFF MagicNumber
final int prime = 31;
int result = 1;
result = prime * result + (hasGeomColumn ? 1231 : 1237);
result = prime * result + ((indexName == null) ? 0 : indexName.hashCode());
result = prime * result + ((tableName == null) ? 0 : tableName.hashCode());
result = prime * result + ((type == null) ? 0 : type.hashCode());
// CHECKSTYLE:ON MagicNumber
return result;
}
@Override
public String toString() {
final String tType = (type == null) ? "null" : type.toString();
......
......@@ -18,7 +18,7 @@ import it.unibz.inf.isochrone.ListenerSetup;
import it.unibz.inf.isochrone.SampleHelper;
import it.unibz.inf.isochrone.TestConfiguration;
import it.unibz.inf.isochrone.TestHelper;
import it.unibz.inf.isochrone.algorithm.MineT.ZoomInformation;
import it.unibz.inf.isochrone.algorithm.tile.ZoomInformation;
import it.unibz.inf.isochrone.plot.sample.SamplePlotter;
import it.unibz.inf.isochrone.plot.sample.SamplePlotter.Aggregator;
import it.unibz.inf.isochrone.plot.sample.SampleProperty;
......
......@@ -29,7 +29,7 @@ import it.unibz.inf.isochrone.ListenerSetup;
import it.unibz.inf.isochrone.MathHelper;
import it.unibz.inf.isochrone.SampleHelper;
import it.unibz.inf.isochrone.TestHelper;
import it.unibz.inf.isochrone.algorithm.MineT.ZoomInformation;
import it.unibz.inf.isochrone.algorithm.tile.ZoomInformation;
import it.unibz.inf.isochrone.plot.AbstractPlotter.SampleType;
import it.unibz.inf.isochrone.plot.BestAdaptivePlotter;
import it.unibz.inf.isochrone.plot.sample.SampleInformation;
......
......@@ -45,7 +45,7 @@ import it.unibz.inf.isochrone.MathHelper;
import it.unibz.inf.isochrone.TestConfiguration;
import it.unibz.inf.isochrone.TestGeoHelper;
import it.unibz.inf.isochrone.TestHelper;
import it.unibz.inf.isochrone.algorithm.MineT;
import it.unibz.inf.isochrone.algorithm.tile.TileNumber;
import it.unibz.inf.isochrone.config.ConfigDataset;
import it.unibz.inf.isochrone.config.ConfigIsochrone;
import it.unibz.inf.isochrone.network.IEdge;
......@@ -629,7 +629,7 @@ public class QueryRuntimeTest {
}
final Coordinate c = geom.getCoordinate();
final MineT.TileNumber tileNr = new MineT.TileNumber(c.x, c.y, zoomLevel);
final TileNumber tileNr = new TileNumber(c.x, c.y, zoomLevel);
final long startTime = System.nanoTime();
try (PreparedStatement stmt = database.getPstmt(query)) {
......
......@@ -18,7 +18,7 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import it.unibz.inf.isochrone.TestHelper;
import it.unibz.inf.isochrone.algorithm.MineT.ZoomInformation;
import it.unibz.inf.isochrone.algorithm.tile.ZoomInformation;
import it.unibz.inf.isochrone.plot.sample.SamplePlotter.Aggregator;
import it.unibz.inf.isochrone.plot.sample.SampleProperty;
......
......@@ -8,8 +8,9 @@ import org.testng.annotations.Listeners;
import org.testng.annotations.Test;
import it.unibz.inf.isochrone.ListenerLogging;
import it.unibz.inf.isochrone.algorithm.MineT.TileNumber;
import it.unibz.inf.isochrone.algorithm.MineT.ZoomInformation;
import it.unibz.inf.isochrone.algorithm.tile.BoundingBox;
import it.unibz.inf.isochrone.algorithm.tile.TileNumber;
import it.unibz.inf.isochrone.algorithm.tile.ZoomInformation;
import nl.jqno.equalsverifier.EqualsVerifier;
@Listeners(ListenerLogging.class)
......@@ -17,6 +18,11 @@ public class EqualityTest {
// Test methods
@Test
public void testBoundingBox() {
EqualsVerifier.forClass(BoundingBox.class).usingGetClass().verify();
}
@Test
public void testCacheKey() {
EqualsVerifier.forClass(CacheKey.class).usingGetClass().verify();
......@@ -24,10 +30,14 @@ public class EqualityTest {
@Test
public void testTileNumber() {
EqualsVerifier.forClass(TileNumber.class).withPrefabValues(CoordinateSequence.class,
new CoordinateArraySequence(new Coordinate[] {new Coordinate(1, 1, 0)}),
new CoordinateArraySequence(new Coordinate[] {new Coordinate(1, 2, 1)})
).usingGetClass().verify();
EqualsVerifier.forClass(TileNumber.class)
.usingGetClass()
.withIgnoredFields("deprecated", "seed")
.withPrefabValues(CoordinateSequence.class,
new CoordinateArraySequence(new Coordinate[] {new Coordinate(1, 1, 0)}),
new CoordinateArraySequence(new Coordinate[] {new Coordinate(1, 2, 1)})
)
.verify();
}
@Test
......
......@@ -6,7 +6,8 @@ import org.testng.annotations.Test;
import it.unibz.inf.isochrone.ConfigAlgorithmHelper;
import it.unibz.inf.isochrone.ListenerLogging;
import it.unibz.inf.isochrone.algorithm.MineT.TileNumber;
import it.unibz.inf.isochrone.algorithm.tile.TileNumber;
import it.unibz.inf.isochrone.algorithm.tile.ZoomInformation;
import it.unibz.inf.isochrone.output.MemoryOutput;
@Listeners(ListenerLogging.class)
......@@ -28,14 +29,14 @@ public class StringifierTest {
@Test
public void testZoomInformation() {
final MineT.ZoomInformation z = new MineT.ZoomInformation((byte) 15);
final ZoomInformation z = new ZoomInformation((byte) 15);
Assert.assertFalse(z.toString().contains("@"));
}
@Test
public void testZoomInformation2() {
final int fromDuration = 1500;
final MineT.ZoomInformation z = new MineT.ZoomInformation(fromDuration, (byte) 15);
final ZoomInformation z = new ZoomInformation(fromDuration, (byte) 15);
Assert.assertFalse(z.toString().contains("@"));
}
......
......@@ -6,7 +6,7 @@ import org.testng.Assert;
import org.testng.annotations.Test;
import it.unibz.inf.isochrone.ConfigAlgorithmHelper;
import it.unibz.inf.isochrone.algorithm.MineT.ZoomInformation;
import it.unibz.inf.isochrone.algorithm.tile.ZoomInformation;
import it.unibz.inf.isochrone.config.ConfigAlgorithm;
import it.unibz.inf.isochrone.config.ConfigDataset;
import it.unibz.inf.isochrone.db.Database;
......
......@@ -5,6 +5,7 @@ import org.testng.annotations.Test;
import it.unibz.inf.isochrone.ListenerLogging;
import nl.jqno.equalsverifier.EqualsVerifier;
import nl.jqno.equalsverifier.Warning;
@Listeners(ListenerLogging.class)
public class EqualityTest {
......@@ -13,37 +14,65 @@ public class EqualityTest {
@Test
public void testElevationBike() {
EqualsVerifier.forClass(ElevationCyclingEstimation.class).usingGetClass().verify();
EqualsVerifier.forClass(ElevationCyclingEstimation.class)
.usingGetClass()
.suppress(Warning.ALL_FIELDS_SHOULD_BE_USED)
.suppress(Warning.INHERITED_DIRECTLY_FROM_OBJECT)
.verify();
}
@Test
public void testElevationWalking() {
EqualsVerifier.forClass(ElevationWalkingEstimation.class).usingGetClass().verify();
EqualsVerifier.forClass(ElevationWalkingEstimation.class)
.usingGetClass()
.suppress(Warning.ALL_FIELDS_SHOULD_BE_USED)
.suppress(Warning.INHERITED_DIRECTLY_FROM_OBJECT)
.verify();
}
@Test
public void testNoop() {
EqualsVerifier.forClass(NoopSpeedEstimation.class).usingGetClass().verify();
EqualsVerifier.forClass(NoopSpeedEstimation.class)
.usingGetClass()
.suppress(Warning.ALL_FIELDS_SHOULD_BE_USED)
.suppress(Warning.INHERITED_DIRECTLY_FROM_OBJECT)
.verify();
}
@Test
public void testSimple() {
EqualsVerifier.forClass(SimpleSpeedEstimation.class).usingGetClass().verify();
EqualsVerifier.forClass(SimpleSpeedEstimation.class)
.usingGetClass()
.suppress(Warning.ALL_FIELDS_SHOULD_BE_USED)
.suppress(Warning.INHERITED_DIRECTLY_FROM_OBJECT)
.verify();
}
@Test
public void testUserProfile() {
EqualsVerifier.forClass(UserProfileEstimation.class).usingGetClass().verify();
EqualsVerifier.forClass(UserProfileEstimation.class)
.usingGetClass()
.suppress(Warning.ALL_FIELDS_SHOULD_BE_USED)
.suppress(Warning.INHERITED_DIRECTLY_FROM_OBJECT)
.verify();
}
@Test
public void testWayTypeBike() {
EqualsVerifier.forClass(WayTypeCyclingEstimation.class).usingGetClass().verify();
EqualsVerifier.forClass(WayTypeCyclingEstimation.class)
.usingGetClass()
.suppress(Warning.ALL_FIELDS_SHOULD_BE_USED)
.suppress(Warning.INHERITED_DIRECTLY_FROM_OBJECT)
.verify();
}
@Test
public void testWayTypeWalking() {
EqualsVerifier.forClass(WayTypeWalkingEstimation.class).usingGetClass().verify();
EqualsVerifier.forClass(WayTypeWalkingEstimation.class)
.usingGetClass()
.suppress(Warning.ALL_FIELDS_SHOULD_BE_USED)
.suppress(Warning.INHERITED_DIRECTLY_FROM_OBJECT)
.verify();
}
}
......@@ -14,12 +14,19 @@ public class EqualityTest {
@Test
public void testConfigAlgorithm() {
EqualsVerifier.forClass(ConfigAlgorithm.class).usingGetClass().suppress(Warning.NONFINAL_FIELDS).verify();
EqualsVerifier.forClass(ConfigAlgorithm.class)
.usingGetClass()
.verify();
}
@Test
public void testConfigDataset() {
EqualsVerifier.forClass(ConfigDataset.class).usingGetClass().suppress(Warning.NONFINAL_FIELDS).verify();
EqualsVerifier.forClass(ConfigDataset.class)
.usingGetClass()
.suppress(Warning.ALL_FIELDS_SHOULD_BE_USED)
.suppress(Warning.INHERITED_DIRECTLY_FROM_OBJECT)
.suppress(Warning.NONFINAL_FIELDS)
.verify();
}
}
......@@ -21,70 +21,109 @@ public class EqualityTest {
@Test
public void testEdge() {
EqualsVerifier.forClass(Edge.class).withPrefabValues(CoordinateSequence.class,
new CoordinateArraySequence(new Coordinate[] {new Coordinate(1, 1)}),
new CoordinateArraySequence(new Coordinate[] {new Coordinate(1, 2)})
).usingGetClass().verify();
EqualsVerifier.forClass(Edge.class)
.usingGetClass()
// .withIgnoredFields("endNode")
.withOnlyTheseFields("id")
.withPrefabValues(CoordinateSequence.class,
new CoordinateArraySequence(new Coordinate[] {new Coordinate(1, 1)}),
new CoordinateArraySequence(new Coordinate[] {new Coordinate(1, 2)})
)
.verify();
}
@Test
public void testEdgeSlope() {
EqualsVerifier.forClass(EdgeSlope.class).withPrefabValues(CoordinateSequence.class,
new CoordinateArraySequence(new Coordinate[] {new Coordinate(1, 1, 0)}),
new CoordinateArraySequence(new Coordinate[] {new Coordinate(1, 2, 1)})
).usingGetClass().verify();
EqualsVerifier.forClass(EdgeSlope.class)
.usingGetClass()
.withOnlyTheseFields("id")
.withPrefabValues(CoordinateSequence.class,
new CoordinateArraySequence(new Coordinate[] {new Coordinate(1, 1, 0)}),
new CoordinateArraySequence(new Coordinate[] {new Coordinate(1, 2, 1)})
)
.verify();
}
@Test
public void testEdgeTyped() {
EqualsVerifier.forClass(EdgeTyped.class).withPrefabValues(CoordinateSequence.class,
new CoordinateArraySequence(new Coordinate[] {new Coordinate(1, 1)}),
new CoordinateArraySequence(new Coordinate[] {new Coordinate(1, 2)})
).usingGetClass().verify();
EqualsVerifier.forClass(EdgeTyped.class)
.usingGetClass()
.withOnlyTheseFields("id")
.withPrefabValues(CoordinateSequence.class,
new CoordinateArraySequence(new Coordinate[] {new Coordinate(1, 1)}),
new CoordinateArraySequence(new Coordinate[] {new Coordinate(1, 2)})
)
.verify();
}
@Test
public void testLocation() {
EqualsVerifier.forClass(Location.class).usingGetClass().verify();
EqualsVerifier.forClass(Location.class)
.usingGetClass()
.withIgnoredFields("distance")
.verify();
}
@Test
public void testMemoryOutput() {
EqualsVerifier.forClass(MemoryOutput.class).usingGetClass().verify();
EqualsVerifier.forClass(MemoryOutput.class)
.suppress(Warning.ALL_FIELDS_SHOULD_BE_USED)
.suppress(Warning.INHERITED_DIRECTLY_FROM_OBJECT)
.usingGetClass()
.verify();
}
@Test
public void testNetworkEntity() {
EqualsVerifier.forClass(NetworkEntity.class).usingGetClass().verify();
EqualsVerifier.forClass(NetworkEntity.class)
.usingGetClass()
.withOnlyTheseFields("id")
.verify();
}
@Test
public void testNode() {
EqualsVerifier.forClass(Node.class).withPrefabValues(CoordinateSequence.class,
new CoordinateArraySequence(new Coordinate[] {new Coordinate(1, 1)}),
new CoordinateArraySequence(new Coordinate[] {new Coordinate(1, 2)})
).usingGetClass().verify();
EqualsVerifier.forClass(Node.class)
.usingGetClass()
.withOnlyTheseFields("id")
.withPrefabValues(CoordinateSequence.class,
new CoordinateArraySequence(new Coordinate[] {new Coordinate(1, 1)}),
new CoordinateArraySequence(new Coordinate[] {new Coordinate(1, 2)})
)
.verify();
}
@Test
public void testNodeConnection() {
EqualsVerifier.forClass(NodeConnection.class).withPrefabValues(CoordinateSequence.class,
new CoordinateArraySequence(new Coordinate[] {new Coordinate(1, 1)}),
new CoordinateArraySequence(new Coordinate[] {new Coordinate(1, 2)})
).usingGetClass().verify();
EqualsVerifier.forClass(NodeConnection.class)
.suppress(Warning.ALL_FIELDS_SHOULD_BE_USED)
.suppress(Warning.INHERITED_DIRECTLY_FROM_OBJECT)
.usingGetClass()
.withPrefabValues(CoordinateSequence.class,
new CoordinateArraySequence(new Coordinate[] {new Coordinate(1, 1)}),
new CoordinateArraySequence(new Coordinate[] {new Coordinate(1, 2)})
)
.verify();
}
@Test
public void testNodeWired() {
EqualsVerifier.forClass(NodeWired.class).withPrefabValues(CoordinateSequence.class,
new CoordinateArraySequence(new Coordinate[] {new Coordinate(1, 1)}),
new CoordinateArraySequence(new Coordinate[] {new Coordinate(1, 2)})
).usingGetClass().verify();
EqualsVerifier.forClass(NodeWired.class)
.usingGetClass()
.withOnlyTheseFields("id")
.withPrefabValues(CoordinateSequence.class,
new CoordinateArraySequence(new Coordinate[] {new Coordinate(1, 1)}),
new CoordinateArraySequence(new Coordinate[] {new Coordinate(1, 2)})
)
.verify();
}
@Test
public void testSchedule() {
EqualsVerifier.forClass(Schedule.class).usingGetClass().suppress(Warning.NONFINAL_FIELDS).verify();
EqualsVerifier.forClass(Schedule.class)
.suppress(Warning.NONFINAL_FIELDS)
.usingGetClass()
.verify();
}
@Test
......@@ -93,7 +132,11 @@ public class EqualityTest {
final Point p1 = gf.createPoint(new Coordinate(1, 1));
final Point p2 = gf.createPoint(new Coordinate(2, 2));
EqualsVerifier.forClass(Seed.class).usingGetClass().withPrefabValues(Point.class, p1, p2).verify();
EqualsVerifier.forClass(Seed.class)
.usingGetClass()
.withOnlyTheseFields("center", "mRadius")
.withPrefabValues(Point.class, p1, p2)
.verify();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment