From 0d347cd7aac2ebfad01c1635f3893964be2e67ae Mon Sep 17 00:00:00 2001 From: Renaud Allard Date: Thu, 20 Oct 2016 07:19:10 +0200 Subject: Reuse EvenHandlerTest device rename log message variable --- src/org/traccar/FilterHandler.java | 18 ++++++++--------- test/org/traccar/FilterHandlerTest.java | 36 ++------------------------------- 2 files changed, 11 insertions(+), 43 deletions(-) diff --git a/src/org/traccar/FilterHandler.java b/src/org/traccar/FilterHandler.java index 9a6c7936a..f9904ccaf 100644 --- a/src/org/traccar/FilterHandler.java +++ b/src/org/traccar/FilterHandler.java @@ -176,15 +176,15 @@ public class FilterHandler extends BaseDataHandler { if (filterType.length() > 0 && !filterLimit(position)) { - 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()); + StringBuilder message = new StringBuilder(); + message.append("Position filtered by "); + message.append(filterType.toString()); + message.append("filters from device: "); + message.append(Context.getIdentityManager().getDeviceById(position.getDeviceId()).getUniqueId()); + message.append(" with id: "); + message.append(position.getDeviceId()); + + Log.info(message.toString()); return true; } diff --git a/test/org/traccar/FilterHandlerTest.java b/test/org/traccar/FilterHandlerTest.java index 9c2ce416e..a03c04536 100644 --- a/test/org/traccar/FilterHandlerTest.java +++ b/test/org/traccar/FilterHandlerTest.java @@ -12,45 +12,13 @@ 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 EventHandlerTest deviceHandler; private FilterHandler filtingHandler; private FilterHandler passingHandler; @Before public void setUp() { + deviceHandler = new EventHandlerTest(); passingHandler = new FilterHandler(); filtingHandler = new FilterHandler(); filtingHandler.setFilterInvalid(true); -- cgit v1.2.3