@Test public void testExceptionIsNotThrownWhenJsonContainsTooManyProducts() { System.setProperty(ConfigurationConstants.PROPNAME_DISCARD_INDEXING_REQUESTS_WITH_TOO_MANY_ITEMS,"false"); System.setProperty(ConfigurationConstants.PROPNAME_MAX_NO_OF_RELATED_ITEMS_PER_INDEX_REQUEST,"2"); String json = "{" + " \"channel\" : \"uk\"," + " \"site\" : \"amazon\"," + " \"date\" : \"2013-05-02T15:31:31\"," + " \"items\" : [ \"B009S4IJCK\", \"B0076UICIO\" ,\"B0096TJCXW\" ]"+ "}"; try { IndexingRequestConverter converter = createConverter(ByteBuffer.wrap(json.getBytes())); RelatedItemIndexingMessage message = new RelatedItemIndexingMessage(new SystemPropertiesConfiguration()); converter.translateTo(message,1); assertEquals(2, message.getRelatedItems().getNumberOfRelatedItems()); if(message.getRelatedItems().getRelatedItemAtIndex(0).getId().toString().equals("B009S4IJCK")) { assertEquals("B0076UICIO",message.getRelatedItems().getRelatedItemAtIndex(1).getId().toString()); } else if(message.getRelatedItems().getRelatedItemAtIndex(0).getId().toString().equals("B0076UICIO")) { assertEquals("B009S4IJCK",message.getRelatedItems().getRelatedItemAtIndex(1).getId().toString()); } else { fail("Json message should have thrown away the last id."); } } catch(InvalidIndexingRequestException e) { fail("Should be able to parse json, just that some related items are not stored"); } }
@Override public void translateTo(RelatedItemIndexingMessage convertedTo, long sequence) { convertedTo.setValidMessage(true); convertedTo.setUTCFormattedDate(date); parseProductArray(convertedTo,maxNumberOfAdditionalProperties); parseAdditionalProperties(convertedTo.getIndexingMessageProperties(), object, maxNumberOfAdditionalProperties); }
JsonSmartIndexingRequestConverter implements IndexingRequestConverter { @Override public void translateTo(RelatedItemIndexingMessage convertedTo, long sequence) { convertedTo.setValidMessage(true); convertedTo.setUTCFormattedDate(date); parseProductArray(convertedTo,maxNumberOfAdditionalProperties); parseAdditionalProperties(convertedTo.getIndexingMessageProperties(), object, maxNumberOfAdditionalProperties); } }
JsonSmartIndexingRequestConverter implements IndexingRequestConverter { @Override public void translateTo(RelatedItemIndexingMessage convertedTo, long sequence) { convertedTo.setValidMessage(true); convertedTo.setUTCFormattedDate(date); parseProductArray(convertedTo,maxNumberOfAdditionalProperties); parseAdditionalProperties(convertedTo.getIndexingMessageProperties(), object, maxNumberOfAdditionalProperties); } JsonSmartIndexingRequestConverter(Configuration config, ISO8601UTCCurrentDateAndTimeFormatter dateCreator, ByteBuffer requestData);  JsonSmartIndexingRequestConverter(Configuration config, ISO8601UTCCurrentDateAndTimeFormatter dateCreator, ByteBuffer requestData,
        int maxNumberOfAllowedProperties,int maxNumberOfRelatedItems); }
JsonSmartIndexingRequestConverter implements IndexingRequestConverter { @Override public void translateTo(RelatedItemIndexingMessage convertedTo, long sequence) { convertedTo.setValidMessage(true); convertedTo.setUTCFormattedDate(date); parseProductArray(convertedTo,maxNumberOfAdditionalProperties); parseAdditionalProperties(convertedTo.getIndexingMessageProperties(), object, maxNumberOfAdditionalProperties); } JsonSmartIndexingRequestConverter(Configuration config, ISO8601UTCCurrentDateAndTimeFormatter dateCreator, ByteBuffer requestData);  JsonSmartIndexingRequestConverter(Configuration config, ISO8601UTCCurrentDateAndTimeFormatter dateCreator, ByteBuffer requestData,
        int maxNumberOfAllowedProperties,int maxNumberOfRelatedItems); @Override void translateTo(RelatedItemIndexingMessage convertedTo,
                            long sequence); }
JsonSmartIndexingRequestConverter implements IndexingRequestConverter { @Override public void translateTo(RelatedItemIndexingMessage convertedTo, long sequence) { convertedTo.setValidMessage(true); convertedTo.setUTCFormattedDate(date); parseProductArray(convertedTo,maxNumberOfAdditionalProperties); parseAdditionalProperties(convertedTo.getIndexingMessageProperties(), object, maxNumberOfAdditionalProperties); } JsonSmartIndexingRequestConverter(Configuration config, ISO8601UTCCurrentDateAndTimeFormatter dateCreator, ByteBuffer requestData);  JsonSmartIndexingRequestConverter(Configuration config, ISO8601UTCCurrentDateAndTimeFormatter dateCreator, ByteBuffer requestData,
        int maxNumberOfAllowedProperties,int maxNumberOfRelatedItems); @Override void translateTo(RelatedItemIndexingMessage convertedTo,
                            long sequence);  }