mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-14 16:40:30 +00:00
Fix false positives in Location.equals().
This commit is contained in:
parent
b4ac8f72cb
commit
ae00988db7
2 changed files with 10 additions and 5 deletions
|
@ -145,7 +145,7 @@ public final class Location implements Serializable
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
public boolean equals(final Object o)
|
||||
{
|
||||
if (o == this)
|
||||
return true;
|
||||
|
@ -154,10 +154,10 @@ public final class Location implements Serializable
|
|||
final Location other = (Location) o;
|
||||
if (this.type != other.type)
|
||||
return false;
|
||||
if (this.id != 0 && this.id == other.id)
|
||||
return true;
|
||||
if (this.lat != 0 && this.lon != 0 && this.lat == other.lat && this.lon == other.lon)
|
||||
return true;
|
||||
if (this.id != 0)
|
||||
return this.id == other.id;
|
||||
if (this.lat != 0 && this.lon != 0)
|
||||
return this.lat == other.lat && this.lon == other.lon;
|
||||
if (!nullSafeEquals(this.name, other.name)) // only discriminate by name if no ids are given
|
||||
return false;
|
||||
return true;
|
||||
|
|
|
@ -17,7 +17,9 @@
|
|||
|
||||
package de.schildbach.pte.live;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.hasItem;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
@ -96,6 +98,9 @@ public class MvvProviderLiveTest extends AbstractProviderLiveTest
|
|||
@Test
|
||||
public void autocompleteLocal() throws Exception
|
||||
{
|
||||
final List<Location> autocompletesFraunhoferStr = provider.autocompleteStations("fraunhofer");
|
||||
assertThat(autocompletesFraunhoferStr, hasItem(new Location(LocationType.STATION, 1000150)));
|
||||
|
||||
final List<Location> autocompletesHirschgarten = provider.autocompleteStations("Hirschgarten");
|
||||
assertEquals("München", autocompletesHirschgarten.get(0).place);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue