@Test(dataProvider = "ids") public void generateSchedule(String id) throws ParseException, UnknownHostException { DBObject query = (DBObject) JSON.parse("{_id:\"" + id + "\" }"); DBObject filter = (DBObject) JSON.parse( "{" + "\"FpML.trade.swap.swapStream.calculationPeriodDates.effectiveDate\":1," + "\"FpML.trade.swap.swapStream.calculationPeriodDates.terminationDate\":1," + "\"FpML.trade.swap.swapStream.calculationPeriodDates.calculationPeriodFrequency\":1," + "\"FpML.trade.swap.swapStream.calculationPeriodDates.calculationPeriodDatesAdjustments\":1," + "}"); DBCursor dbCursor = fpmls.find(query, filter); DBObject dates = dbCursor.next(); DBObject stream1 = get(dates, "FpML.trade.swap.swapStream.0.calculationPeriodDates"); List<org.jquantlib.time.Date> dates11 = generateCouponDates(stream1); List<Date> dates12 = (List<Date>) cashflows.findOne(query).get("P"); for (Date date : dates12) Assert.assertTrue(dates11.contains(new org.jquantlib.time.Date(date))); DBObject stream2 = get(dates, "FpML.trade.swap.swapStream.1.calculationPeriodDates"); List<org.jquantlib.time.Date> dates21 = generateCouponDates(stream2); List<Date> dates22 = (List<Date>) cashflows.findOne(query).get("R"); for (Date date : dates22) Assert.assertTrue(dates21.contains(new org.jquantlib.time.Date(date))); }
@DataProvider(name = "ids") public Object[][] generateTradeIds() { ArrayList<Object[]> objects = new ArrayList<Object[]>(); DBObject query = (DBObject) JSON.parse("{}"); DBObject filter = (DBObject) JSON.parse("{_id:1}"); DBCursor cursor = fpmls.find(query, filter); while (cursor.hasNext()) { DBObject id = cursor.next(); objects.add(new Object[] {id.get("_id")}); } return objects.toArray(new Object[][] {}); }