@Test public void testConvertFromTwoItemsIndexingMessage() throws Exception { RelatedItemIndexingMessageConverter converter = getConverter(); RelatedItemIndexingMessage message = getIndexingMessageWithTwoRelatedItem(); RelatedItem[] products = converter.convertFrom(message); Arrays.sort(products, new RelatedItemComparator()); assertEquals("Should only have found a single product",2,products.length); RelatedItem product1 = products[0]; RelatedItem product2 = products[1]; assertEquals(DATE, product1.getDate()); assertEquals("1",new String(product1.getId())); assertEquals("the related product should have 3 properties, two inherited, one for itself",5,product1.getAdditionalProperties().getNumberOfProperties()); assertEquals(DATE, product2.getDate()); assertEquals("2",new String(product2.getId())); assertEquals("the related product should have 3 properties, two inherited, one for itself",5,product2.getAdditionalProperties().getNumberOfProperties()); Map<String,String> props = new HashMap<String,String>(); product1.getAdditionalProperties().convertTo(props); assertEquals(SITE,props.get("site")); assertEquals(CHANNEL,props.get("channel")); assertEquals(DEPARTMENT,props.get("department")); assertEquals("laptops",props.get("subcategory")); assertEquals("apple mac",props.get("name")); }
public RelatedItem[] convertFrom(RelatedItemIndexingMessage message) { RelatedItemSet items = message.getRelatedItems(); int numberOfRelatedItems = items.getNumberOfRelatedItems(); RelatedItem[] relatedItems = new RelatedItem[numberOfRelatedItems]; RelatedItemInfo[][] idLists = relatedIds(items.getListOfRelatedItemInfomation(), items.getNumberOfRelatedItems()); int length = numberOfRelatedItems-1; for(int i =0;i<numberOfRelatedItems;i++) { RelatedItemInfo id = idLists[i][length]; relatedItems[i] = createRelatedItem(message, id, idLists[i], message.getIndexingMessageProperties()); } return relatedItems; }
BasicRelatedItemIndexingMessageConverter implements RelatedItemIndexingMessageConverter { public RelatedItem[] convertFrom(RelatedItemIndexingMessage message) { RelatedItemSet items = message.getRelatedItems(); int numberOfRelatedItems = items.getNumberOfRelatedItems(); RelatedItem[] relatedItems = new RelatedItem[numberOfRelatedItems]; RelatedItemInfo[][] idLists = relatedIds(items.getListOfRelatedItemInfomation(), items.getNumberOfRelatedItems()); int length = numberOfRelatedItems-1; for(int i =0;i<numberOfRelatedItems;i++) { RelatedItemInfo id = idLists[i][length]; relatedItems[i] = createRelatedItem(message, id, idLists[i], message.getIndexingMessageProperties()); } return relatedItems; } }
BasicRelatedItemIndexingMessageConverter implements RelatedItemIndexingMessageConverter { public RelatedItem[] convertFrom(RelatedItemIndexingMessage message) { RelatedItemSet items = message.getRelatedItems(); int numberOfRelatedItems = items.getNumberOfRelatedItems(); RelatedItem[] relatedItems = new RelatedItem[numberOfRelatedItems]; RelatedItemInfo[][] idLists = relatedIds(items.getListOfRelatedItemInfomation(), items.getNumberOfRelatedItems()); int length = numberOfRelatedItems-1; for(int i =0;i<numberOfRelatedItems;i++) { RelatedItemInfo id = idLists[i][length]; relatedItems[i] = createRelatedItem(message, id, idLists[i], message.getIndexingMessageProperties()); } return relatedItems; } BasicRelatedItemIndexingMessageConverter(Configuration configuration); }
BasicRelatedItemIndexingMessageConverter implements RelatedItemIndexingMessageConverter { public RelatedItem[] convertFrom(RelatedItemIndexingMessage message) { RelatedItemSet items = message.getRelatedItems(); int numberOfRelatedItems = items.getNumberOfRelatedItems(); RelatedItem[] relatedItems = new RelatedItem[numberOfRelatedItems]; RelatedItemInfo[][] idLists = relatedIds(items.getListOfRelatedItemInfomation(), items.getNumberOfRelatedItems()); int length = numberOfRelatedItems-1; for(int i =0;i<numberOfRelatedItems;i++) { RelatedItemInfo id = idLists[i][length]; relatedItems[i] = createRelatedItem(message, id, idLists[i], message.getIndexingMessageProperties()); } return relatedItems; } BasicRelatedItemIndexingMessageConverter(Configuration configuration); RelatedItem[] convertFrom(RelatedItemIndexingMessage message); static RelatedItemInfo[][] relatedIds(RelatedItemInfo[] ids, int length); }
BasicRelatedItemIndexingMessageConverter implements RelatedItemIndexingMessageConverter { public RelatedItem[] convertFrom(RelatedItemIndexingMessage message) { RelatedItemSet items = message.getRelatedItems(); int numberOfRelatedItems = items.getNumberOfRelatedItems(); RelatedItem[] relatedItems = new RelatedItem[numberOfRelatedItems]; RelatedItemInfo[][] idLists = relatedIds(items.getListOfRelatedItemInfomation(), items.getNumberOfRelatedItems()); int length = numberOfRelatedItems-1; for(int i =0;i<numberOfRelatedItems;i++) { RelatedItemInfo id = idLists[i][length]; relatedItems[i] = createRelatedItem(message, id, idLists[i], message.getIndexingMessageProperties()); } return relatedItems; } BasicRelatedItemIndexingMessageConverter(Configuration configuration); RelatedItem[] convertFrom(RelatedItemIndexingMessage message); static RelatedItemInfo[][] relatedIds(RelatedItemInfo[] ids, int length);  }