Search in sources :

Example 1 with ByteArraySerdeFactory

use of org.apache.beam.runners.samza.runtime.SamzaStoreStateInternals.ByteArraySerdeFactory in project beam by apache.

the class SamzaTimerInternalsFactoryTest method testByteArray.

@Test
public void testByteArray() {
    ByteArray key1 = ByteArray.of("hello world".getBytes(StandardCharsets.UTF_8));
    Serde<ByteArray> serde = new ByteArraySerdeFactory().getSerde("", null);
    byte[] keyBytes = serde.toBytes(key1);
    ByteArray key2 = serde.fromBytes(keyBytes);
    assertEquals(key1, key2);
    Map<ByteArray, String> map = new HashMap<>();
    map.put(key1, "found it");
    assertEquals("found it", map.get(key2));
    map.remove(key1);
    assertTrue(!map.containsKey(key2));
    assertTrue(map.isEmpty());
}
Also used : HashMap(java.util.HashMap) ByteArray(org.apache.beam.runners.samza.runtime.SamzaStoreStateInternals.ByteArray) ByteArraySerdeFactory(org.apache.beam.runners.samza.runtime.SamzaStoreStateInternals.ByteArraySerdeFactory) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Aggregations

HashMap (java.util.HashMap)1 ByteArray (org.apache.beam.runners.samza.runtime.SamzaStoreStateInternals.ByteArray)1 ByteArraySerdeFactory (org.apache.beam.runners.samza.runtime.SamzaStoreStateInternals.ByteArraySerdeFactory)1 Test (org.junit.Test)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1