### Question:
RelatedItemIndexingMessageFactory implements EventFactory<RelatedItemIndexingMessage> { @Override public RelatedItemIndexingMessage newInstance() { return new RelatedItemIndexingMessage(configuration); } RelatedItemIndexingMessageFactory(Configuration configuration); @Override RelatedItemIndexingMessage newInstance();  }### Answer:
@Test public void testRelatedItemIndexingMessageWith4RelatedItems() throws Exception { System.setProperty(PROPNAME_MAX_NO_OF_RELATED_ITEMS_PER_INDEX_REQUEST,"4"); Configuration config = new SystemPropertiesConfiguration(); RelatedItemIndexingMessageFactory factory = new RelatedItemIndexingMessageFactory(config); RelatedItemIndexingMessage message = factory.newInstance(); assertEquals(4, message.getMaxNumberOfRelatedItemsAllowed()); }
@Test public void testRelatedItemIndexingMessage() { System.setProperty(PROPNAME_MAX_NO_OF_RELATED_ITEMS_PER_INDEX_REQUEST,"2"); Configuration config = new SystemPropertiesConfiguration(); RelatedItemIndexingMessageFactory factory = new RelatedItemIndexingMessageFactory(config); RelatedItemIndexingMessage message = factory.newInstance(); assertEquals(2, message.getMaxNumberOfRelatedItemsAllowed()); }
@Test public void testRelatedItemIndexingMessageRestrictsNumberOfProperties() { System.setProperty(PROPNAME_MAX_NO_OF_RELATED_ITEMS_PER_INDEX_REQUEST,"2"); System.setProperty(PROPNAME_MAX_NO_OF_RELATED_ITEM_PROPERTES,"3"); Configuration config = new SystemPropertiesConfiguration(); RelatedItemIndexingMessageFactory factory = new RelatedItemIndexingMessageFactory(config); RelatedItemIndexingMessage message = factory.newInstance(); assertEquals(2, message.getMaxNumberOfRelatedItemsAllowed()); assertEquals(3, message.getIndexingMessageProperties().getMaxNumberOfAvailableProperties()); }