@Test public void shouldSerde() { SnapshotTriggeringEvents ste = new SnapshotTriggeringEvents(); String json = JSonMapper.toJson(ste); System.out.println("Json=" + json); SnapshotTriggeringEvents ste2 = JSonMapper.fromJson(json, SnapshotTriggeringEvents.class); }
@Test public void shouldSerdeWithEvent() { SnapshotTriggeringEvents ste = new SnapshotTriggeringEvents(); ste.add(a_1_99); String json = JSonMapper.toJson(ste); System.out.println("Json=" + json); SnapshotTriggeringEvents ste2 = JSonMapper.fromJson(json, SnapshotTriggeringEvents.class); System.out.println("ste2=" + ste2); }
@Test public void shouldNotRejectGreaterThan() { SnapshotTriggeringEvents ste = new SnapshotTriggeringEvents(); ste.add(a_1_99); ste.checkForDuplicateEvent(EtopEventContext.decode(a_1_100).get()); }
@Test(expected = DuplicateTriggeringEventException.class) public void shouldRejectLessThan() { SnapshotTriggeringEvents ste = new SnapshotTriggeringEvents(); ste.add(a_1_99); ste.checkForDuplicateEvent(EtopEventContext.decode(a_1_98).get()); }
@Test(expected = DuplicateTriggeringEventException.class) public void shouldRejectEquals() { SnapshotTriggeringEvents ste = new SnapshotTriggeringEvents(); ste.add(a_1_99); ste.checkForDuplicateEvent(EtopEventContext.decode(a_1_99).get()); }
@Test public void shouldSerdeWithEvent2() { SnapshotTriggeringEvents ste = new SnapshotTriggeringEvents(); ste.add(a_1_99); ste.add(a_2_99); String json = JSonMapper.toJson(ste); System.out.println("Json=" + json); SnapshotTriggeringEvents ste2 = JSonMapper.fromJson(json, SnapshotTriggeringEvents.class); System.out.println("ste2=" + ste2); }
@Test public void shouldNotRejectDifferent() { SnapshotTriggeringEvents ste = new SnapshotTriggeringEvents(); ste.add(a_1_99); ste.checkForDuplicateEvent(EtopEventContext.decode(a_2_99).get()); }
@Test public void shouldGetSnapshotTriggeringEventsWithPreviousSnapshot() { SnapshotTriggeringEvents ste1 = new SnapshotTriggeringEvents(); ste1.add(a_1_99); String triggeringEvents = JSonMapper.toJson(ste1); Optional<LoadedSnapshot> previousSnapshot = Optional.of(new LoadedSnapshot(null, triggeringEvents)); List<EventAndTrigger> events = Collections.singletonList(new EventAndTrigger(null, a_1_100)); Optional<EventContext> eventContext = Optional.of(new EventContext(a_2_99)); SnapshotTriggeringEvents ste = SnapshotTriggeringEvents.getSnapshotTriggeringEvents(previousSnapshot, events, eventContext); assertFalse(ste.isEmpty()); }