### Question:
MysqlTransitionRepository implements TransitionRepository { @Override public Optional<Lock> tryLock(String stateMachineId, long timeout, TimeUnit timeUnit) { final Handle handle = jdbi.open(); final boolean lock = attachDao(handle).lock(stateMachineId, timeUnit.toSeconds(timeout)); if (lock) { return Optional.<Lock>of(new JdbiLock(handle, stateMachineId)); } else { handle.close(); } return Optional.<Lock>empty(); } MysqlTransitionRepository(DBI jdbi); @Override Transition get(String stateMachineId); @Override Set<String> getIds(); @Override String create(Object initialState, List<Object> initialContextData); @Override Optional<Lock> tryLock(String stateMachineId, long timeout, TimeUnit timeUnit);  }### Answer:
@Test public void shouldBeAbleToLock() throws Exception { final Optional<Lock> lock = repository.tryLock("2222", 1, SECONDS); assertThat(lock).isNotNull(); assertTrue(lock.isPresent()); }