MetadataSpecs { public static Specification<? extends AbstractMetadata> hasExtra(final String extra) { return new Specification<AbstractMetadata>() { @Override public Predicate toPredicate(Root<AbstractMetadata> root, CriteriaQuery<?> query, CriteriaBuilder cb) { return cb.equal(root.get(AbstractMetadata_.dataInfo).get(MetadataDataInfo_.extra), extra); } }; } private  MetadataSpecs(); static Specification<? extends AbstractMetadata> hasSchemaId(final String schemaId); static Specification<? extends AbstractMetadata> hasOwner(final int owner); static Specification<? extends AbstractMetadata> hasMetadataId(final int metadataId); static Specification<? extends AbstractMetadata> hasMetadataUuid(final String uuid); static Specification<? extends AbstractMetadata> hasHarvesterUuid(final String harvesterUuid); static Specification<? extends AbstractMetadata> isOwnedByUser(final int userId); static Specification<? extends AbstractMetadata> hasSource(final String sourceUuid); static Specification<? extends AbstractMetadata> isType(final MetadataType type); static Specification<? extends AbstractMetadata> isHarvested(final boolean isHarvested); static Specification<? extends AbstractMetadata> hasMetadataIdIn(final Collection<Integer> mdIds); static Specification<? extends AbstractMetadata> hasMetadataUuidIn(final Collection<String> uuids); static Specification<? extends AbstractMetadata> hasType(final MetadataType metadataType); static Specification<? extends AbstractMetadata> isOwnedByOneOfFollowingGroups(final List<Integer> groups); static Specification<? extends AbstractMetadata> hasCategory(final MetadataCategory category); static Specification<? extends AbstractMetadata> hasExtra(final String extra); static Specification<? extends AbstractMetadata> isIso19139Schema();  }
@Test public void testHasExtra() throws Exception { final Metadata entity = newMetadata(_inc); final String extra = "extra data"; entity.getDataInfo().setExtra(extra); Metadata md1 = _repository.save(entity); assertFindsCorrectMd(md1, (Specification<Metadata>)hasExtra(extra), true); assertEquals(0, _repository.count((Specification<Metadata>)hasExtra("wrong extra"))); }