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