@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()); }
@Override public Optional<Event> saveIfNotExists(Event event) { return save(new EventEntity(event), true); }
JpaBaseEventDao extends JpaAbstractDao<EventEntity, Event> implements EventDao { @Override public Optional<Event> saveIfNotExists(Event event) { return save(new EventEntity(event), true); } }
JpaBaseEventDao extends JpaAbstractDao<EventEntity, Event> implements EventDao { @Override public Optional<Event> saveIfNotExists(Event event) { return save(new EventEntity(event), true); }  }
JpaBaseEventDao extends JpaAbstractDao<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 PageData<Event> findEvents(UUID tenantId, EntityId entityId, TimePageLink pageLink); @Override PageData<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); }
JpaBaseEventDao extends JpaAbstractDao<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 PageData<Event> findEvents(UUID tenantId, EntityId entityId, TimePageLink pageLink); @Override PageData<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);  }