.bindToPrimaryKey() .usingBean(Key.class); consumer.addRefreshListener(uki);
@Test(expected = IllegalArgumentException.class) public void testNoPrimaryKey() { UniqueKeyIndex .from(consumer, DataModel.Consumer.References.class) .bindToPrimaryKey() .usingPath("values._int", int.class); } }
public <T> void test(Class<T> keyType, T key) { UniqueKeyIndex<DataModel.Consumer.TypeWithPrimaryKey, T> pki = UniqueKeyIndex .from(consumer, DataModel.Consumer.TypeWithPrimaryKey.class) .bindToPrimaryKey() .usingBean(keyType); DataModel.Consumer.TypeWithPrimaryKey match = pki.findMatch(key); Assert.assertNotNull(match); Assert.assertEquals(0, match.getOrdinal()); }