@Test public void testHistoryParser_withForward_WittoutParames() throws Exception { IDispatcher disp = createMock(IDispatcher.class); HistoryTokenParser<PlatformEvents, PlatformEvents> toTest = new HistoryTokenParser<PlatformEvents, PlatformEvents>( disp, PlatformEvents.class, null); disp.fireEvent(eq(PlatformEvents.COMPLETE_REGISTRATION), isNull(ILocation.class), isA(ICustomData.class)); disp.fireEvent(PlatformEvents.FORWARD_TO_TARIFBERATUNG, (ILocation) null, (ICustomData) null); replay(disp); ICustomData userData = toTest.parseTokenAndFireEvents("COMPLETE_REGISTRATION;FORWARD_TO_TARIFBERATUNG"); assertNotNull("User daten objekt erwartet", userData); assertNotNull("Forward erwartet", userData.forwardEvent()); assertNull(userData.userObject()); userData.forwardEvent().execute(); verify(disp); }
public ICustomData parseTokenAndFireEvents(String token) { final String[] split = token.split(";"); if (split.length > 1) { final IEvent firstEventToFire = parseEventType(split[0]); final IEvent secondEventToFire = parseEventType(split[1]); IForwardEvent forwardEvent = null; if (secondEventToFire != null) { final ICustomData custDataEvent2 = parseUserData(split[1]); forwardEvent = new IForwardEvent() { @Override public void execute() { dispacher.fireEvent(secondEventToFire, (ILocation) null, custDataEvent2); } @Override public String toString() { if (custDataEvent2 != null && custDataEvent2.userObject() != null) { return secondEventToFire.eventName() + "=" + custDataEvent2.userObject(); } else { return secondEventToFire.eventName(); } } }; } if (firstEventToFire != null && forwardEvent != null) { final ICustomData userData = parseUserData(split[0], forwardEvent); dispacher.fireEvent(firstEventToFire, (ILocation) null, userData); return userData; } else if (firstEventToFire != null) { final ICustomData userData = parseUserData(split[0]); dispacher.fireEvent(firstEventToFire, (ILocation) null, userData); return userData; } } else { IEvent eventToFire = parseEventType(token); if (eventToFire != null) { final ICustomData userData = parseUserData(token); dispacher.fireEvent(eventToFire, (ILocation) null, userData); return userData; } } return null; }
HistoryTokenParser { public ICustomData parseTokenAndFireEvents(String token) { final String[] split = token.split(";"); if (split.length > 1) { final IEvent firstEventToFire = parseEventType(split[0]); final IEvent secondEventToFire = parseEventType(split[1]); IForwardEvent forwardEvent = null; if (secondEventToFire != null) { final ICustomData custDataEvent2 = parseUserData(split[1]); forwardEvent = new IForwardEvent() { @Override public void execute() { dispacher.fireEvent(secondEventToFire, (ILocation) null, custDataEvent2); } @Override public String toString() { if (custDataEvent2 != null && custDataEvent2.userObject() != null) { return secondEventToFire.eventName() + "=" + custDataEvent2.userObject(); } else { return secondEventToFire.eventName(); } } }; } if (firstEventToFire != null && forwardEvent != null) { final ICustomData userData = parseUserData(split[0], forwardEvent); dispacher.fireEvent(firstEventToFire, (ILocation) null, userData); return userData; } else if (firstEventToFire != null) { final ICustomData userData = parseUserData(split[0]); dispacher.fireEvent(firstEventToFire, (ILocation) null, userData); return userData; } } else { IEvent eventToFire = parseEventType(token); if (eventToFire != null) { final ICustomData userData = parseUserData(token); dispacher.fireEvent(eventToFire, (ILocation) null, userData); return userData; } } return null; } }
HistoryTokenParser { public ICustomData parseTokenAndFireEvents(String token) { final String[] split = token.split(";"); if (split.length > 1) { final IEvent firstEventToFire = parseEventType(split[0]); final IEvent secondEventToFire = parseEventType(split[1]); IForwardEvent forwardEvent = null; if (secondEventToFire != null) { final ICustomData custDataEvent2 = parseUserData(split[1]); forwardEvent = new IForwardEvent() { @Override public void execute() { dispacher.fireEvent(secondEventToFire, (ILocation) null, custDataEvent2); } @Override public String toString() { if (custDataEvent2 != null && custDataEvent2.userObject() != null) { return secondEventToFire.eventName() + "=" + custDataEvent2.userObject(); } else { return secondEventToFire.eventName(); } } }; } if (firstEventToFire != null && forwardEvent != null) { final ICustomData userData = parseUserData(split[0], forwardEvent); dispacher.fireEvent(firstEventToFire, (ILocation) null, userData); return userData; } else if (firstEventToFire != null) { final ICustomData userData = parseUserData(split[0]); dispacher.fireEvent(firstEventToFire, (ILocation) null, userData); return userData; } } else { IEvent eventToFire = parseEventType(token); if (eventToFire != null) { final ICustomData userData = parseUserData(token); dispacher.fireEvent(eventToFire, (ILocation) null, userData); return userData; } } return null; } HistoryTokenParser(IDispatcher dispacher, Class<T> plattformEventClass, Class<Z> optionalSubEventClass); }
HistoryTokenParser { public ICustomData parseTokenAndFireEvents(String token) { final String[] split = token.split(";"); if (split.length > 1) { final IEvent firstEventToFire = parseEventType(split[0]); final IEvent secondEventToFire = parseEventType(split[1]); IForwardEvent forwardEvent = null; if (secondEventToFire != null) { final ICustomData custDataEvent2 = parseUserData(split[1]); forwardEvent = new IForwardEvent() { @Override public void execute() { dispacher.fireEvent(secondEventToFire, (ILocation) null, custDataEvent2); } @Override public String toString() { if (custDataEvent2 != null && custDataEvent2.userObject() != null) { return secondEventToFire.eventName() + "=" + custDataEvent2.userObject(); } else { return secondEventToFire.eventName(); } } }; } if (firstEventToFire != null && forwardEvent != null) { final ICustomData userData = parseUserData(split[0], forwardEvent); dispacher.fireEvent(firstEventToFire, (ILocation) null, userData); return userData; } else if (firstEventToFire != null) { final ICustomData userData = parseUserData(split[0]); dispacher.fireEvent(firstEventToFire, (ILocation) null, userData); return userData; } } else { IEvent eventToFire = parseEventType(token); if (eventToFire != null) { final ICustomData userData = parseUserData(token); dispacher.fireEvent(eventToFire, (ILocation) null, userData); return userData; } } return null; } HistoryTokenParser(IDispatcher dispacher, Class<T> plattformEventClass, Class<Z> optionalSubEventClass); ICustomData parseTokenAndFireEvents(String token); }
HistoryTokenParser { public ICustomData parseTokenAndFireEvents(String token) { final String[] split = token.split(";"); if (split.length > 1) { final IEvent firstEventToFire = parseEventType(split[0]); final IEvent secondEventToFire = parseEventType(split[1]); IForwardEvent forwardEvent = null; if (secondEventToFire != null) { final ICustomData custDataEvent2 = parseUserData(split[1]); forwardEvent = new IForwardEvent() { @Override public void execute() { dispacher.fireEvent(secondEventToFire, (ILocation) null, custDataEvent2); } @Override public String toString() { if (custDataEvent2 != null && custDataEvent2.userObject() != null) { return secondEventToFire.eventName() + "=" + custDataEvent2.userObject(); } else { return secondEventToFire.eventName(); } } }; } if (firstEventToFire != null && forwardEvent != null) { final ICustomData userData = parseUserData(split[0], forwardEvent); dispacher.fireEvent(firstEventToFire, (ILocation) null, userData); return userData; } else if (firstEventToFire != null) { final ICustomData userData = parseUserData(split[0]); dispacher.fireEvent(firstEventToFire, (ILocation) null, userData); return userData; } } else { IEvent eventToFire = parseEventType(token); if (eventToFire != null) { final ICustomData userData = parseUserData(token); dispacher.fireEvent(eventToFire, (ILocation) null, userData); return userData; } } return null; } HistoryTokenParser(IDispatcher dispacher, Class<T> plattformEventClass, Class<Z> optionalSubEventClass); ICustomData parseTokenAndFireEvents(String token);  }