ComponentEntityAdapter extends MetadataNodeEntityAdapter<Component> { @Override protected void defineType(final ODatabaseDocumentTx db, final OClass type) { super.defineType(type); type.createProperty(P_GROUP, OType.STRING); type.createProperty(P_NAME, OType.STRING) .setMandatory(true) .setNotNull(true); type.createProperty(P_VERSION, OType.STRING); type.createProperty(P_CI_NAME, OType.STRING) .setCollate(new OCaseInsensitiveCollate()) .setMandatory(true) .setNotNull(true); ODocument metadata = db.newInstance() .field("ignoreNullValues", false) .field("mergeKeys", false); type.createIndex(I_BUCKET_GROUP_NAME_VERSION, INDEX_TYPE.UNIQUE.name(), null, metadata, new String[]{P_BUCKET, P_GROUP, P_NAME, P_VERSION}); type.createIndex(I_BUCKET_NAME_VERSION, INDEX_TYPE.NOTUNIQUE.name(), null, metadata, new String[]{P_BUCKET, P_NAME, P_VERSION}); new OIndexBuilder(type, I_GROUP_NAME_VERSION_INSENSITIVE, INDEX_TYPE.NOTUNIQUE) .property(P_GROUP, OType.STRING) .property(P_NAME, OType.STRING) .property(P_VERSION, OType.STRING) .caseInsensitive() .build(db); new OIndexBuilder(type, I_CI_NAME_CASE_INSENSITIVE, INDEX_TYPE.NOTUNIQUE) .property(P_CI_NAME, OType.STRING) .caseInsensitive() .build(db); componentEntityAdapterExtensions.forEach(d -> d.defineType(db, type)); } @Inject  ComponentEntityAdapter(final BucketEntityAdapter bucketEntityAdapter,
                                final ComponentFactory componentFactory,
                                final Set<ComponentEntityAdapterExtension> componentEntityAdapterExtensions); Iterable<Component> browseByNameCaseInsensitive(final ODatabaseDocumentTx db,
                                                         final String name,
                                                         @Nullable final Iterable<Bucket> buckets,
                                                         @Nullable final String querySuffix); boolean exists(final ODatabaseDocumentTx db,
                        @Nullable final String group,
                        final String name,
                        @Nullable final String version,
                        final Bucket bucket); @Override boolean sendEvents(); @Override EntityEvent newEvent(final ODocument document, final EventKind eventKind); @Override String eventAffinity(final ODocument document); @Override boolean resolveConflicts(); static final String DB_CLASS; static final String P_GROUP; static final String P_VERSION; static final String P_CI_NAME; static final String I_BUCKET_GROUP_NAME_VERSION; static final String I_GROUP_NAME_VERSION_INSENSITIVE; }
@Test public void testRegister() { try (ODatabaseDocumentTx db = database.getInstance().connect()) { entityAdapter.register(db); OSchema schema = db.getMetadata().getSchema(); assertThat(schema.getClass(entityAdapter.getTypeName()), is(notNullValue())); verify(componentEntityAdapterExtension).defineType(any(ODatabaseDocumentTx.class), any(OClass.class)); } }