aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/org/traccar/BaseTest.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-05-30 14:04:24 -0700
committerAnton Tananaev <anton@traccar.org>2022-05-30 14:04:24 -0700
commit014cf82a9e63a36e944e293932f9edf27e452919 (patch)
tree7ac5899f535fbf47e66dc1321738c951473a009b /src/test/java/org/traccar/BaseTest.java
parentce661ec77a957b70c15509c6801e6f34b32ad11d (diff)
downloadtrackermap-server-014cf82a9e63a36e944e293932f9edf27e452919.tar.gz
trackermap-server-014cf82a9e63a36e944e293932f9edf27e452919.tar.bz2
trackermap-server-014cf82a9e63a36e944e293932f9edf27e452919.zip
No context dependency for decoder
Diffstat (limited to 'src/test/java/org/traccar/BaseTest.java')
-rw-r--r--src/test/java/org/traccar/BaseTest.java30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/test/java/org/traccar/BaseTest.java b/src/test/java/org/traccar/BaseTest.java
index 1dddbb03b..35374a363 100644
--- a/src/test/java/org/traccar/BaseTest.java
+++ b/src/test/java/org/traccar/BaseTest.java
@@ -1,9 +1,39 @@
package org.traccar;
+import org.traccar.config.Config;
+import org.traccar.database.ConnectionManager;
+import org.traccar.database.IdentityManager;
+import org.traccar.database.MediaManager;
+import org.traccar.database.StatisticsManager;
+import org.traccar.model.Device;
+
+import static org.mockito.Mockito.*;
+
public class BaseTest {
static {
Context.init(new TestIdentityManager());
}
+ protected <T extends BaseProtocolDecoder> T inject(T decoder) throws Exception {
+ decoder.setConfig(new Config());
+ var device = mock(Device.class);
+ when(device.getId()).thenReturn(1L);
+ var identityManager = mock(IdentityManager.class);
+ when(identityManager.getByUniqueId(any())).thenReturn(device);
+ decoder.setIdentityManager(identityManager);
+ decoder.setConnectionManager(mock(ConnectionManager.class));
+ decoder.setStatisticsManager(mock(StatisticsManager.class));
+ decoder.setMediaManager(mock(MediaManager.class));
+ return decoder;
+ }
+
+ protected <T extends BaseFrameDecoder> T inject(T decoder) throws Exception {
+ return decoder;
+ }
+
+ protected <T extends BaseProtocolEncoder> T inject(T encoder) throws Exception {
+ return encoder;
+ }
+
}