aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/org
diff options
context:
space:
mode:
authorseym45 <seym45@gmail.com>2023-07-26 04:11:40 +0400
committerseym45 <seym45@gmail.com>2023-07-26 04:11:40 +0400
commit2407799dc370d741431cbec056c0f2acbe454bf3 (patch)
tree9e658adb0c49d088ee67c1921f2a0ab79969cc8e /src/test/java/org
parent6ac15f2c6fb8798c6906c24e97b0048736270215 (diff)
downloadtrackermap-server-2407799dc370d741431cbec056c0f2acbe454bf3.tar.gz
trackermap-server-2407799dc370d741431cbec056c0f2acbe454bf3.tar.bz2
trackermap-server-2407799dc370d741431cbec056c0f2acbe454bf3.zip
Refactor method encodeId and encodeContent
- Replace method getCalibrationByteFromHexString with xor checksum - Rewrite method encodeContent with ByteBuf instead of String - Refactor encodeId by replacing short variable names and use ByteBuf
Diffstat (limited to 'src/test/java/org')
-rw-r--r--src/test/java/org/traccar/protocol/GatorProtocolEncoderTest.java9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/test/java/org/traccar/protocol/GatorProtocolEncoderTest.java b/src/test/java/org/traccar/protocol/GatorProtocolEncoderTest.java
index a3bc3af2b..babd7285d 100644
--- a/src/test/java/org/traccar/protocol/GatorProtocolEncoderTest.java
+++ b/src/test/java/org/traccar/protocol/GatorProtocolEncoderTest.java
@@ -1,5 +1,7 @@
package org.traccar.protocol;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
import org.junit.jupiter.api.Test;
import org.traccar.ProtocolTest;
import org.traccar.model.Command;
@@ -11,7 +13,12 @@ public class GatorProtocolEncoderTest extends ProtocolTest {
@Test
void testEncodeId() throws Exception {
var encoder = inject(new GatorProtocolEncoder(null));
- assertEquals("2008958C", encoder.encodeId(13332082112L));
+ ByteBuf pseudoId = Unpooled.buffer();
+ pseudoId.writeByte(0x20);
+ pseudoId.writeByte(0x08);
+ pseudoId.writeByte(0x95);
+ pseudoId.writeByte(0x8C);
+ assertEquals(pseudoId, encoder.encodeId(13332082112L));
}
@Test