aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/org/traccar/protocol
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-05-30 11:49:39 -0700
committerAnton Tananaev <anton@traccar.org>2022-05-30 11:49:39 -0700
commit154ff3b2175e67b3fac531cb9c5c5c68880f5e12 (patch)
treef448a59c75b64deea60b1bd6e79d66790f62a4a8 /src/test/java/org/traccar/protocol
parentb1a971eedb18a11af2cdc70ba5f8004bae89defd (diff)
downloadtrackermap-server-154ff3b2175e67b3fac531cb9c5c5c68880f5e12.tar.gz
trackermap-server-154ff3b2175e67b3fac531cb9c5c5c68880f5e12.tar.bz2
trackermap-server-154ff3b2175e67b3fac531cb9c5c5c68880f5e12.zip
Inject media manager
Diffstat (limited to 'src/test/java/org/traccar/protocol')
-rw-r--r--src/test/java/org/traccar/protocol/WatchProtocolDecoderTest.java18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/test/java/org/traccar/protocol/WatchProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/WatchProtocolDecoderTest.java
index ef6c33da9..50baaa81a 100644
--- a/src/test/java/org/traccar/protocol/WatchProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/WatchProtocolDecoderTest.java
@@ -1,12 +1,11 @@
package org.traccar.protocol;
-import io.netty.buffer.ByteBuf;
import org.junit.Test;
-import org.traccar.Context;
import org.traccar.ProtocolTest;
+import org.traccar.database.MediaManager;
import org.traccar.model.Position;
-import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.*;
public class WatchProtocolDecoderTest extends ProtocolTest {
@@ -148,14 +147,15 @@ public class WatchProtocolDecoderTest extends ProtocolTest {
var decoder = new WatchProtocolDecoder(null);
- verifyNull(decoder.decode(null, null, buffer("[CS*1234567890*0004*TK,1]")));
+ var mediaManager = mock(MediaManager.class);
+ when(mediaManager.writeFile(any(), any(), any())).thenReturn("mock.amr");
+ decoder.setMediaManager(mediaManager);
- ByteBuf data = binary("7d5b5d2c2aff");
+ verifyAttribute(decoder, concatenateBuffers(
+ buffer("[CS*1234567890*000e*TK,#!AMR"), binary("7d5b5d2c2aff"), buffer("]")),
+ Position.KEY_AUDIO, "mock.amr");
- Object decodedObject = decoder.decode(null, null, concatenateBuffers(buffer("[CS*1234567890*000e*TK,#!AMR"), data.resetReaderIndex(), buffer("]")));
- assertEquals("1234567890/mock.amr", ((Position) decodedObject).getAttributes().get("audio"));
-
- verifyFrame(concatenateBuffers(buffer("#!AMR"), data.resetReaderIndex()), ((MockMediaManager) Context.getMediaManager()).readFile("1234567890/mock.amr"));
+ verify(mediaManager).writeFile(any(), any(), any());
}