### Question:
JpaBaseEventDao extends JpaAbstractSearchTimeDao<EventEntity, Event> implements EventDao { @Override public Optional<Event> saveIfNotExists(Event event) { return save(new EventEntity(event), true); }  @Override Event save(TenantId tenantId, Event event); @Override ListenableFuture<Event> saveAsync(Event event); @Override Optional<Event> saveIfNotExists(Event event); @Override Event findEvent(UUID tenantId, EntityId entityId, String eventType, String eventUid); @Override List<Event> findEvents(UUID tenantId, EntityId entityId, TimePageLink pageLink); @Override List<Event> findEvents(UUID tenantId, EntityId entityId, String eventType, TimePageLink pageLink); @Override List<Event> findLatestEvents(UUID tenantId, EntityId entityId, String eventType, int limit); Optional<Event> save(EventEntity entity, boolean ifNotExists);  }### Answer:
@Test public void testSaveIfNotExists() { UUID eventId = UUIDs.timeBased(); UUID tenantId = UUIDs.timeBased(); UUID entityId = UUIDs.timeBased(); Event event = getEvent(eventId, tenantId, entityId); Optional<Event> optEvent1 = eventDao.saveIfNotExists(event); assertTrue("Optional is expected to be non-empty", optEvent1.isPresent()); assertEquals(event, optEvent1.get()); Optional<Event> optEvent2 = eventDao.saveIfNotExists(event); assertFalse("Optional is expected to be empty", optEvent2.isPresent()); }