Ejemplo n.º 1
0
  @Test
  public void testDeserialization() {
    RecordingEvent event1 =
        RecordingEvent.fromString(
            "event=[,data=adapterId#className#value,action=click,description text]");
    Assert.assertEquals("description text", event1.getDescription());
    Assert.assertTrue(event1.getSubject() instanceof Data);
    Assert.assertEquals("adapterId", ((Data) event1.getSubject()).getAdapterId());
    Assert.assertEquals("className", ((Data) event1.getSubject()).getClassName());
    Assert.assertEquals("value", ((Data) event1.getSubject()).getValue());
    Assert.assertTrue(event1.getAction() instanceof ClickAction);

    RecordingEvent event2 =
        RecordingEvent.fromString("event=[grp,view=viewId,action=click,description text]");
    Assert.assertEquals("grp", event2.getGroup());
    Assert.assertEquals("description text", event2.getDescription());
    Assert.assertTrue(event2.getSubject() instanceof View);
    Assert.assertEquals("viewId", ((View) event2.getSubject()).getId());
    Assert.assertTrue(event2.getAction() instanceof ClickAction);

    RecordingEvent event3 = RecordingEvent.fromString("event=[grp,view=viewId,action=click,]");
    Assert.assertNull(event3.getDescription());
    Assert.assertEquals("grp", event3.getGroup());
    Assert.assertTrue(event3.getSubject() instanceof View);
    Assert.assertEquals("viewId", ((View) event3.getSubject()).getId());
    Assert.assertTrue(event3.getAction() instanceof ClickAction);

    RecordingEvent event4 = RecordingEvent.fromString("event=[,view=viewId,action=click,]");
    Assert.assertNull(event4.getDescription());
    Assert.assertNull(event4.getGroup());
    Assert.assertTrue(event4.getSubject() instanceof View);
    Assert.assertEquals("viewId", ((View) event4.getSubject()).getId());
    Assert.assertTrue(event4.getAction() instanceof ClickAction);
  }