diff options
-rw-r--r-- | src/org/traccar/FilterHandler.java | 11 | ||||
-rw-r--r-- | test/org/traccar/FilterHandlerTest.java | 38 |
2 files changed, 47 insertions, 2 deletions
diff --git a/src/org/traccar/FilterHandler.java b/src/org/traccar/FilterHandler.java index 83d79a3c0..9a6c7936a 100644 --- a/src/org/traccar/FilterHandler.java +++ b/src/org/traccar/FilterHandler.java @@ -175,7 +175,16 @@ public class FilterHandler extends BaseDataHandler { } if (filterType.length() > 0 && !filterLimit(position)) { - Log.info("Position filtered by " + filterType.toString() + "filters from " + position.getDeviceId()); + + StringBuilder logmsg = new StringBuilder(); + logmsg.append("Position filtered by "); + logmsg.append(filterType.toString()); + logmsg.append("filters from device: "); + logmsg.append(Context.getIdentityManager().getDeviceById(position.getDeviceId()).getUniqueId()); + logmsg.append(" with id: "); + logmsg.append(position.getDeviceId()); + + Log.info(logmsg.toString()); return true; } diff --git a/test/org/traccar/FilterHandlerTest.java b/test/org/traccar/FilterHandlerTest.java index bb7e69dc0..9c2ce416e 100644 --- a/test/org/traccar/FilterHandlerTest.java +++ b/test/org/traccar/FilterHandlerTest.java @@ -6,10 +6,46 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import org.junit.Before; import org.junit.Test; +import org.traccar.database.IdentityManager; import org.traccar.model.Position; +import org.traccar.model.Device; public class FilterHandlerTest { + static { + Context.init(new IdentityManager() { + + private Device createDevice() { + Device device = new Device(); + device.setId(1); + device.setName("test"); + device.setUniqueId("123456789012345"); + return device; + } + + @Override + public Device getDeviceById(long id) { + return createDevice(); + } + + @Override + public Device getDeviceByUniqueId(String uniqueId) { + return createDevice(); + } + + @Override + public Position getLastPosition(long deviceId) { + return null; + } + + @Override + public boolean isLatestPosition(Position position) { + return true; + } + + }); + } + private FilterHandler filtingHandler; private FilterHandler passingHandler; @@ -32,7 +68,7 @@ public class FilterHandlerTest { filtingHandler = null; passingHandler = null; } - + private Position createPosition( long deviceId, Date time, |