ItemEventFactory extends AbstractEventFactory { private Event createAddedEvent(String topic, String payload) { ItemDTO itemDTO = deserializePayload(payload, ItemDTO.class); return new ItemAddedEvent(topic, payload, itemDTO); } ItemEventFactory(); static ItemCommandEvent createCommandEvent(String itemName, Command command, String source); static ItemCommandEvent createCommandEvent(String itemName, Command command); static ItemStateEvent createStateEvent(String itemName, State state, String source); static ItemStateEvent createStateEvent(String itemName, State state); static ItemStatePredictedEvent createStatePredictedEvent(String itemName, State state,
            boolean isConfirmation); static ItemStateChangedEvent createStateChangedEvent(String itemName, State newState, State oldState); static GroupItemStateChangedEvent createGroupStateChangedEvent(String itemName, String memberName,
            State newState, State oldState); static ItemAddedEvent createAddedEvent(Item item); static ItemRemovedEvent createRemovedEvent(Item item); static ItemUpdatedEvent createUpdateEvent(Item item, Item oldItem);  }
@Test public void testCreateAddedEvent() { ItemAddedEvent event = ItemEventFactory.createAddedEvent(ITEM); assertEquals(ItemAddedEvent.TYPE, event.getType()); assertEquals(ITEM_ADDED_EVENT_TOPIC, event.getTopic()); assertNotNull(event.getItem()); assertEquals(ITEM_NAME, event.getItem().name); assertEquals(CoreItemFactory.SWITCH, event.getItem().type); }