diff options
author | Jan Srnicek <jsrnicek@cisco.com> | 2016-09-23 16:39:09 +0200 |
---|---|---|
committer | Jan Srnicek <jsrnicek@cisco.com> | 2016-09-23 16:41:57 +0200 |
commit | 60d69218642cc976fa606fd8a38623d8c035dd86 (patch) | |
tree | a0ccb089d93198ff7c9974eaf3e39e44a1a1f06d /vpp-common/vpp-translate-utils/src/test/java/io/fd/honeycomb/translate/v3po/util/ByteDataTranslatorTest.java | |
parent | 08cd3ae5fd61d60ec07996179146c956459c084f (diff) |
HONEYCOMB-145 - Utility Class Refactoring
problematic mockito-all changed to mockito-core( https://github.com/mockito/mockito/issues/324)
Translate Utils Splitted to multiple Trait Interfaces
Ipv4Translator - Logic for translation of ipv4-based data
Ipv6Translator - Logic for translation of ipv6-based data
MacTranslator - Logic for translation of mac-based data
AddressTranslator - Aggregation trait for Ipv4/Ipv6/Mac
JvppReplyConsumer - Logic for extracting replies from jvpp calls
ByteDataTranslator - any byte-based conversions
Plus some existing utility classes changed to traits
Change-Id: I342b625954223966802e65dca0fabf8456c89345
Signed-off-by: Jan Srnicek <jsrnicek@cisco.com>
Diffstat (limited to 'vpp-common/vpp-translate-utils/src/test/java/io/fd/honeycomb/translate/v3po/util/ByteDataTranslatorTest.java')
-rw-r--r-- | vpp-common/vpp-translate-utils/src/test/java/io/fd/honeycomb/translate/v3po/util/ByteDataTranslatorTest.java | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/vpp-common/vpp-translate-utils/src/test/java/io/fd/honeycomb/translate/v3po/util/ByteDataTranslatorTest.java b/vpp-common/vpp-translate-utils/src/test/java/io/fd/honeycomb/translate/v3po/util/ByteDataTranslatorTest.java new file mode 100644 index 000000000..86ff5ff77 --- /dev/null +++ b/vpp-common/vpp-translate-utils/src/test/java/io/fd/honeycomb/translate/v3po/util/ByteDataTranslatorTest.java @@ -0,0 +1,39 @@ +package io.fd.honeycomb.translate.v3po.util; + +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +/** + * Created by jsrnicek on 23.9.2016. + */ +public class ByteDataTranslatorTest implements ByteDataTranslator { + + @Test + public void testBooleanToByte() { + assertEquals(0, booleanToByte(null)); + assertEquals(0, booleanToByte(false)); + assertEquals(1, booleanToByte(true)); + } + + @Test + public void testByteToBoolean() { + assertEquals(Boolean.FALSE, byteToBoolean((byte) 0)); + assertEquals(Boolean.TRUE, byteToBoolean((byte) 1)); + } + + @Test(expected = IllegalArgumentException.class) + public void testByteToBooleanFailed() { + byteToBoolean((byte) 123); + } + + @Test + public void testToString() { + final byte[] expected = "test".getBytes(); + final byte[] cString = new byte[expected.length + 10]; + System.arraycopy(expected, 0, cString, 0, expected.length); + final String jString = toString(cString); + assertArrayEquals(expected, jString.getBytes()); + } +}
\ No newline at end of file |