Esempio n. 1
0
 @Test
 public void testRenameField() {
   docs.home.serialization.v1.ItemAdded event1 =
       docs.home.serialization.v1.ItemAdded.builder()
           .shoppingCartId("123")
           .productId("ab123")
           .quantity(2)
           .build();
   byte[] blob = serializer.toBinary(event1);
   docs.home.serialization.v2c.ItemAdded event2 =
       (docs.home.serialization.v2c.ItemAdded)
           serializer.fromBinary(blob, docs.home.serialization.v2c.ItemAdded.class.getName());
   assertEquals(event1.getProductId(), event2.getItemId());
   assertEquals(event1.getQuantity(), event2.getQuantity());
 }
Esempio n. 2
0
  @Test
  public void testAddMandatoryField() {
    docs.home.serialization.v1.ItemAdded event1 =
        docs.home.serialization.v1.ItemAdded.builder()
            .shoppingCartId("123")
            .productId("ab123")
            .quantity(2)
            .build();
    byte[] blob = serializer.toBinary(event1);
    docs.home.serialization.v2b.ItemAdded event2 =
        (docs.home.serialization.v2b.ItemAdded)
            serializer.fromBinary(blob, docs.home.serialization.v2b.ItemAdded.class.getName());
    assertEquals(event1.getQuantity(), event2.getQuantity());
    assertEquals(0.0, event2.getDiscount(), 0.000001);

    checkSerialization(
        docs.home.serialization.v2b.ItemAdded.builder()
            .shoppingCartId("123")
            .productId("ab123")
            .quantity(2)
            .discount(0.1)
            .build(),
        false);
  }
Esempio n. 3
0
  @Test
  public void testAddOptionalField() {
    docs.home.serialization.v1.ItemAdded event1 =
        docs.home.serialization.v1.ItemAdded.builder()
            .shoppingCartId("123")
            .productId("ab123")
            .quantity(2)
            .build();
    byte[] blob = serializer.toBinary(event1);
    ItemAdded event2 = (ItemAdded) serializer.fromBinary(blob, ItemAdded.class.getName());
    assertEquals(event1.getQuantity(), event2.getQuantity());
    assertEquals(Optional.empty(), event2.getDiscount());
    assertEquals("", event2.getNote());

    checkSerialization(
        ItemAdded.builder()
            .shoppingCartId("123")
            .productId("ab123")
            .quantity(2)
            .discount(0.1)
            .note("thanks")
            .build(),
        false);
  }