From 2407799dc370d741431cbec056c0f2acbe454bf3 Mon Sep 17 00:00:00 2001 From: seym45 Date: Wed, 26 Jul 2023 04:11:40 +0400 Subject: 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 --- src/test/java/org/traccar/protocol/GatorProtocolEncoderTest.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/test/java/org') 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 -- cgit v1.2.3