@Test
public void testMergeBeans()  {

    try {
        admin.merge(Bean.create(BeanId.create("bogus", "bogus")));
    } catch (AbortRuntimeException e) {
        // don't know if schema or instances were invalid from
        // a HTTP 404 response, hence CFG090 and not CFG101/CDG304
        assertThat(e.getEvent().getCode(), is(CFG090));
    }
    admin.create(grandfathersBeans);
    // assert successful create
    Optional<Bean> optional = admin.get(BeanId.create("g1", GRANDFATHER_SCHEMA_NAME));
    assertTrue(optional.isPresent());
    String prop9 = optional.get().getSingleValue("prop9");
    String prop2 = optional.get().getSingleValue("prop2");
    Grandfather g1 = new Grandfather("g1");
    g1.setProp1("testMergeBean1");
    Grandfather g2 = new Grandfather("g2");
    g2.setProp1("testMergeBean2");
    Collection<Bean> beans = toBeans(g1, g2);
    admin.merge(beans);
    // test g1
    optional = admin.get(BeanId.create("g1", GRANDFATHER_SCHEMA_NAME));
    assertTrue(optional.isPresent());
    // assert that new value have been set
    assertThat(optional.get().getSingleValue("prop1"), is("testMergeBean1"));
    // assert that previous values are untouched
    assertThat(optional.get().getSingleValue("prop9"), is("0"));
    assertThat(optional.get().getSingleValue("prop2"), is(prop2));
    // test g2
    optional = admin.get(BeanId.create("g2", GRANDFATHER_SCHEMA_NAME));
    assertTrue(optional.isPresent());
    // assert that new value have been set
    assertThat(optional.get().getSingleValue("prop1"), is("testMergeBean2"));
    // assert that previous values are untouched
    assertThat(optional.get().getSingleValue("prop9"), is("0"));
    assertThat(optional.get().getSingleValue("prop2"), is(prop2));
}