@Test public void getTypeHandlerFrom_Forum() { PublisherData publisherData = mock(PublisherData.class); when(publisherData.getType()).thenReturn("Forum"); NotificationTypeHandler forumTypeHandler = typeHandlerSelectorTestObject.getTypeHandlerFrom(publisherData); assertNotNull("Could not found NotificationTypeHandler for 'forum'", forumTypeHandler); assertTrue("Wrong type-handler for forum", forumTypeHandler instanceof ForumNotificationTypeHandler); }
public NotificationTypeHandler getTypeHandlerFrom(PublisherData publisherData) { String inputPublisherDataType = publisherData.getType(); for (Iterator<NotificationTypeHandler> iterator = notificationTypeHandler.iterator(); iterator.hasNext();) { NotificationTypeHandler notificationTypeHandler = iterator.next(); if (notificationTypeHandler.getPublisherDataType().equals(inputPublisherDataType)) { return notificationTypeHandler; } } return new DummyNotificationTypeHandler(); }
NotificationTypeHandlerSelector { public NotificationTypeHandler getTypeHandlerFrom(PublisherData publisherData) { String inputPublisherDataType = publisherData.getType(); for (Iterator<NotificationTypeHandler> iterator = notificationTypeHandler.iterator(); iterator.hasNext();) { NotificationTypeHandler notificationTypeHandler = iterator.next(); if (notificationTypeHandler.getPublisherDataType().equals(inputPublisherDataType)) { return notificationTypeHandler; } } return new DummyNotificationTypeHandler(); } }
NotificationTypeHandlerSelector { public NotificationTypeHandler getTypeHandlerFrom(PublisherData publisherData) { String inputPublisherDataType = publisherData.getType(); for (Iterator<NotificationTypeHandler> iterator = notificationTypeHandler.iterator(); iterator.hasNext();) { NotificationTypeHandler notificationTypeHandler = iterator.next(); if (notificationTypeHandler.getPublisherDataType().equals(inputPublisherDataType)) { return notificationTypeHandler; } } return new DummyNotificationTypeHandler(); } NotificationTypeHandlerSelector(); }
NotificationTypeHandlerSelector { public NotificationTypeHandler getTypeHandlerFrom(PublisherData publisherData) { String inputPublisherDataType = publisherData.getType(); for (Iterator<NotificationTypeHandler> iterator = notificationTypeHandler.iterator(); iterator.hasNext();) { NotificationTypeHandler notificationTypeHandler = iterator.next(); if (notificationTypeHandler.getPublisherDataType().equals(inputPublisherDataType)) { return notificationTypeHandler; } } return new DummyNotificationTypeHandler(); } NotificationTypeHandlerSelector(); NotificationTypeHandler getTypeHandler(String sourceType); NotificationTypeHandler getTypeHandlerFrom(PublisherData publisherData); }
NotificationTypeHandlerSelector { public NotificationTypeHandler getTypeHandlerFrom(PublisherData publisherData) { String inputPublisherDataType = publisherData.getType(); for (Iterator<NotificationTypeHandler> iterator = notificationTypeHandler.iterator(); iterator.hasNext();) { NotificationTypeHandler notificationTypeHandler = iterator.next(); if (notificationTypeHandler.getPublisherDataType().equals(inputPublisherDataType)) { return notificationTypeHandler; } } return new DummyNotificationTypeHandler(); } NotificationTypeHandlerSelector(); NotificationTypeHandler getTypeHandler(String sourceType); NotificationTypeHandler getTypeHandlerFrom(PublisherData publisherData);  }