@Test
public void removeAnOrderFromTheSystemFailsIfNotPermitted() {
UUID key = UUID.randomUUID();
Order order = new Order(new Date()) {
@Override
public boolean canBeDeleted() {
return false;
}
};
when(mockOrdersMemoryRepository.findById(key)).thenReturn(order);
DeleteOrderEvent ev = new DeleteOrderEvent(key);
OrderDeletedEvent orderDeletedEvent = uut.deleteOrder(ev);
verify(mockOrdersMemoryRepository, never()).delete(ev.getKey());
assertTrue(orderDeletedEvent.isEntityFound());
assertFalse(orderDeletedEvent.isDeletionCompleted());
assertEquals(order.getDateTimeOfSubmission(), orderDeletedEvent.getDetails().getDateTimeOfSubmission());
}