@Test
public void testLock() throws Exception {

    Flow flow = createFlow("blah");
    flowRepository.persist(flow);
    Long id = flow.getIdentifier();
    testTransactionManager.commitTransaction();
    testTransactionManager.beginTransaction();
    try {
        flowRepository.lock(0L);
        fail("found non-existing flow");
    } catch (FlowException e) {
        // expected
    }
    flow = flowRepository.lock(id);
    flow.setAckCountExpected(111);
    testTransactionManager.commitTransaction();
    testTransactionManager.beginTransaction();
    flow = flowRepository.find(id);
    assertEquals(111, flow.getAckCountExpected());
}