diff options
author | Abyss777 <abyss@fox5.ru> | 2017-09-08 11:08:38 +0500 |
---|---|---|
committer | Abyss777 <abyss@fox5.ru> | 2017-09-08 11:08:38 +0500 |
commit | 640770638943146f5c2e7dcfb0c05b84fc9b3cff (patch) | |
tree | d728cea2cf1c4a1b8d19b12c7bb6aae91e576900 /test | |
parent | d36fa0963f8e1045d2f974cd88a0be68aea6f2ef (diff) | |
download | trackermap-server-640770638943146f5c2e7dcfb0c05b84fc9b3cff.tar.gz trackermap-server-640770638943146f5c2e7dcfb0c05b84fc9b3cff.tar.bz2 trackermap-server-640770638943146f5c2e7dcfb0c05b84fc9b3cff.zip |
Implement skipping filtering by list of attributes
Diffstat (limited to 'test')
-rw-r--r-- | test/org/traccar/BaseTest.java | 8 | ||||
-rw-r--r-- | test/org/traccar/FilterHandlerTest.java | 64 |
2 files changed, 66 insertions, 6 deletions
diff --git a/test/org/traccar/BaseTest.java b/test/org/traccar/BaseTest.java index 37956f11d..4b9ee5451 100644 --- a/test/org/traccar/BaseTest.java +++ b/test/org/traccar/BaseTest.java @@ -40,25 +40,25 @@ public class BaseTest { @Override public boolean lookupAttributeBoolean( long deviceId, String attributeName, boolean defaultValue, boolean lookupConfig) { - return false; + return defaultValue; } @Override public String lookupAttributeString( long deviceId, String attributeName, String defaultValue, boolean lookupConfig) { - return null; + return defaultValue; } @Override public int lookupAttributeInteger( long deviceId, String attributeName, int defaultValue, boolean lookupConfig) { - return 0; + return defaultValue; } @Override public long lookupAttributeLong( long deviceId, String attributeName, long defaultValue, boolean lookupConfig) { - return 0; + return defaultValue; } }); diff --git a/test/org/traccar/FilterHandlerTest.java b/test/org/traccar/FilterHandlerTest.java index e91566635..7ebab3af5 100644 --- a/test/org/traccar/FilterHandlerTest.java +++ b/test/org/traccar/FilterHandlerTest.java @@ -3,6 +3,8 @@ package org.traccar; import org.junit.After; import org.junit.Before; import org.junit.Test; +import org.traccar.database.IdentityManager; +import org.traccar.model.Device; import org.traccar.model.Position; import java.util.Date; @@ -10,7 +12,65 @@ import java.util.Date; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; -public class FilterHandlerTest extends BaseTest { +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 getById(long id) { + return createDevice(); + } + + @Override + public Device getByUniqueId(String uniqueId) { + return createDevice(); + } + + @Override + public Position getLastPosition(long deviceId) { + return null; + } + + @Override + public boolean isLatestPosition(Position position) { + return true; + } + + @Override + public boolean lookupAttributeBoolean( + long deviceId, String attributeName, boolean defaultValue, boolean lookupConfig) { + return defaultValue; + } + + @Override + public String lookupAttributeString( + long deviceId, String attributeName, String defaultValue, boolean lookupConfig) { + return "alarm,result"; + } + + @Override + public int lookupAttributeInteger( + long deviceId, String attributeName, int defaultValue, boolean lookupConfig) { + return defaultValue; + } + + @Override + public long lookupAttributeLong( + long deviceId, String attributeName, long defaultValue, boolean lookupConfig) { + return defaultValue; + } + + }); + } private FilterHandler filtingHandler; private FilterHandler passingHandler; @@ -77,7 +137,7 @@ public class FilterHandlerTest extends BaseTest { assertNotNull(passingHandler.decode(null, null, position)); position.set(Position.KEY_ALARM, Position.ALARM_GENERAL); - filtingHandler.setSkipAlarms(true); + filtingHandler.setSkipAttributes(true); assertNotNull(filtingHandler.decode(null, null, position)); } |