### Question:
ProductExecutorContext { public void useFirstFormerResultHavingMetaData(String key, URI uri) { useFirstFormerResultHavingMetaData(key, ""+uri); } ProductExecutorContext(List<ProductResult> formerResults, ProductExecutorCallback callback); AdapterMetaDataCallback getCallBack(); void useFirstFormerResult(); void useFirstFormerResultHavingMetaData(String key, URI uri); void useFirstFormerResultHavingMetaData(String key, String value); ProductResult getCurrentProductResult(); AdapterMetaData getCurrentMetaDataOrNull(); void persist(ProductResult productResult);  }### Answer:
@Test public void useFirstFormerResultHavingMetaData_finds_product_by_metadata() { ProductResult result1 = new ProductResult(); ProductResult result2 = new ProductResult(); ProductResult result3 = new ProductResult(); formerResults.add(result1); formerResults.add(result2); formerResults.add(null); formerResults.add(result3); AdapterMetaData metaData1 = new AdapterMetaData(); metaData1.setValue("test.key", "xyz"); AdapterMetaData metaData2 = new AdapterMetaData(); metaData2.setValue("test.key", "abc"); result1.setMetaData(converter.convertToJSONOrNull(metaData1)); result2.setMetaData(null); result3.setMetaData(converter.convertToJSONOrNull(metaData2)); contextToTest = new ProductExecutorContext(formerResults, callback); verify(callback,times(1)).setCurrentProductResult(result3); contextToTest.useFirstFormerResultHavingMetaData("test.key", "abc"); verify(callback,times(2)).setCurrentProductResult(result3); }