OrientKeyStoreDataEntityAdapter extends IterableEntityAdapter<OrientKeyStoreData> { public void save(final ODatabaseDocumentTx db, final OrientKeyStoreData entity) { ODocument document = findDocument(db, entity.getName()); if (document != null) { writeEntity(document, entity); } else { addEntity(db, entity); } } OrientKeyStoreDataEntityAdapter(); @Nullable OrientKeyStoreData load(final ODatabaseDocumentTx db, final String name); void save(final ODatabaseDocumentTx db, final OrientKeyStoreData entity); @Override boolean sendEvents(); @Nullable @Override EntityEvent newEvent(final ODocument document, final EventKind eventKind);  }
@Test(expected = ORecordDuplicatedException.class) public void testIndex_EnforceUniqueName() { try (ODatabaseDocumentTx db = database.getInstance().connect()) { entityAdapter.register(db); OrientKeyStoreData entity = new OrientKeyStoreData(); entity.setName(KEY_STORE_NAME); entity.setBytes(KEY_STORE_DATA); entityAdapter.save(db, entity); entity = new OrientKeyStoreData(); entity.setName(KEY_STORE_NAME); entity.setBytes(KEY_STORE_DATA); entityAdapter.addEntity(db, entity); } }