### Question:
MetadataSpecs { public static Specification<? extends AbstractMetadata> hasSource(final String sourceUuid) { return new Specification<AbstractMetadata>() { @Override public Predicate toPredicate(Root<AbstractMetadata> root, CriteriaQuery<?> query, CriteriaBuilder cb) { Path<String> sourceAttributePath = root.get(AbstractMetadata_.sourceInfo).get(MetadataSourceInfo_.sourceId); Predicate equalSourceIdPredicate = cb.equal(sourceAttributePath, cb.literal(sourceUuid)); return equalSourceIdPredicate; } }; } 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();  }### Answer:
@Test public void testHasSource() throws Exception { Metadata md1 = _repository.save(newMetadata(_inc)); Specification<Metadata> spec = (Specification<Metadata>)hasSource(md1.getSourceInfo().getSourceId()); assertFindsCorrectMd(md1, spec, true); }