ExternalIdBundle bundle1 = ExternalIdBundle.of(ExternalId.of("sch1", "123"), ExternalId.of("sch1", "234"));
ExternalIdBundle bundle2 = ExternalIdBundle.of(ExternalId.of("sch1", "345"));
List<BondFutureDeliverable> basket = Lists.newArrayList(
new BondFutureDeliverable(bundle1, 111),
new BondFutureDeliverable(bundle2, 222));
BondFutureSecurity security = new BondFutureSecurity(new Expiry(expiryDate), "exch", "settExch", Currency.GBP, 1234,
basket, firstDeliveryDate, lastDeliveryDate, "category");
security.setName("a bond future");
// TODO this isn't converting ExternalIdBundle properly
JsonDataSink sink = new JsonDataSink(BlotterUtils.getJsonBuildingConverters());
BeanTraverser traverser = new BeanTraverser(s_propertyFilter);
BeanVisitor<JSONObject> writingVisitor = new BuildingBeanVisitor<>(security, sink);
JSONObject json = (JSONObject) traverser.traverse(BondFutureSecurity.meta(), writingVisitor);
assertNotNull(json);
// System.out.println(json);
JsonBeanDataSource dataSource = new JsonBeanDataSource(new JSONObject(json.toString()));
MetaBeanFactory metaBeanFactory = new MapMetaBeanFactory(ImmutableSet.<MetaBean>of(
BondFutureSecurity.meta(),
BondFutureDeliverable.meta()));
BeanVisitor<BeanBuilder<BondFutureSecurity>> readingVisitor =
new BeanBuildingVisitor<>(dataSource, metaBeanFactory, BlotterUtils.getBeanBuildingConverters());
BeanBuilder<BondFutureSecurity> beanBuilder =
(BeanBuilder<BondFutureSecurity>) traverser.traverse(BondFutureSecurity.meta(), readingVisitor);
BondFutureSecurity security2 = beanBuilder.build();
assertEquals(security, security2);
}