@Test public void tryLock() { String preparationId = "preparation id"; PersistentPreparation preparationMock = mock(PersistentPreparation.class); when(preparationRepository.get(preparationId, PersistentPreparation.class)).thenReturn(preparationMock); PersistentPreparation preparation = noOpLockedResourceRepository.tryLock(preparationId, "Toto", "toto de Charleville-Mézières"); assertEquals(preparationMock, preparation); verify(preparationRepository).get(preparationId, PersistentPreparation.class); }
@Override public PersistentPreparation tryLock(String preparationId, String userId, String displayName) { PersistentPreparation preparation = preparationRepository.get(preparationId, PersistentPreparation.class); if (preparation == null) { throw new TDPException(PREPARATION_DOES_NOT_EXIST, build().put("id", preparationId)); } return preparation; }
NoOpLockedResourceRepository implements LockedResourceRepository { @Override public PersistentPreparation tryLock(String preparationId, String userId, String displayName) { PersistentPreparation preparation = preparationRepository.get(preparationId, PersistentPreparation.class); if (preparation == null) { throw new TDPException(PREPARATION_DOES_NOT_EXIST, build().put("id", preparationId)); } return preparation; } }
NoOpLockedResourceRepository implements LockedResourceRepository { @Override public PersistentPreparation tryLock(String preparationId, String userId, String displayName) { PersistentPreparation preparation = preparationRepository.get(preparationId, PersistentPreparation.class); if (preparation == null) { throw new TDPException(PREPARATION_DOES_NOT_EXIST, build().put("id", preparationId)); } return preparation; } NoOpLockedResourceRepository(); }
NoOpLockedResourceRepository implements LockedResourceRepository { @Override public PersistentPreparation tryLock(String preparationId, String userId, String displayName) { PersistentPreparation preparation = preparationRepository.get(preparationId, PersistentPreparation.class); if (preparation == null) { throw new TDPException(PREPARATION_DOES_NOT_EXIST, build().put("id", preparationId)); } return preparation; } NoOpLockedResourceRepository(); @Override PersistentPreparation tryLock(String preparationId, String userId, String displayName); @Override void unlock(String preparationId, String userId); }
NoOpLockedResourceRepository implements LockedResourceRepository { @Override public PersistentPreparation tryLock(String preparationId, String userId, String displayName) { PersistentPreparation preparation = preparationRepository.get(preparationId, PersistentPreparation.class); if (preparation == null) { throw new TDPException(PREPARATION_DOES_NOT_EXIST, build().put("id", preparationId)); } return preparation; } NoOpLockedResourceRepository(); @Override PersistentPreparation tryLock(String preparationId, String userId, String displayName); @Override void unlock(String preparationId, String userId);  }