-
-
Save anonymous/865913d6ef9419ca2cf4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private final AbstractCompositeSerializerPelopsCompatible<SomeKey> someKeySerialzier = new AbstractCompositeSerializerPelopsCompatible<SomeKey>(SomeKey.class); | |
@Test | |
public void testToByteBuffer(){ | |
String SOME_STRING = "someKey------WordAsd"; | |
Long SOME_LONG = 31414141L; | |
SomeKey key = new SomeKey(SOME_LONG, SOME_STRING ); | |
ByteBuffer fromPelops = Bytes.composite() | |
.addLong(SOME_LONG) | |
.addUTF8(SOME_STRING ) | |
.build().getBytes(); | |
ByteBuffer fromCompositeSerializer = someKeySerialzier.toByteBuffer(key); | |
assertEquals(fromPelops, fromCompositeSerializer); | |
} | |
@Test | |
public void testFromByteBuffer(){ | |
String SOME_STRING = "someKey------WordAsd"; | |
Long SOME_LONG = 31414141L; | |
ByteBuffer fromPelops = Bytes.composite() | |
.addLong(SOME_LONG) | |
.addUTF8(SOME_STRING) | |
.build().getBytes(); | |
SomeKey indexKey = someKeySerialzier.fromByteBuffer(fromPelops); | |
assertEquals(SOME_LONG, indexKey.getIntVal()); | |
assertEquals(SOME_STRING, indexKey.getStringVal()); | |
} | |
//the SomeKey.class | |
@Data | |
public class SomeKey { | |
@Component(ordinal=0) private int intVal; | |
@Component(ordinal=1) private String stringVal; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment