ProviderBasedDataObjectService implements DataObjectService { @Override public <T> T save(T dataObject, PersistenceOption... options) { Set<PersistenceOption> optionSet = Sets.newHashSet(options); pushOneToOneKeysToChildObjects(dataObject); T saved = persistenceProviderForObject(dataObject).save(dataObject, options); if (optionSet.contains(PersistenceOption.LINK_KEYS)) { DataObjectWrapper<T> wrapper = wrap(saved); wrapper.linkForeignKeys(true); } return saved; }  @Override T find(Class<T> type, Object id); @Override QueryResults<T> findMatching(Class<T> type, QueryByCriteria queryByCriteria); @Override QueryResults<T> findAll(Class<T> type); @Override T findUnique(Class<T> type, QueryByCriteria queryByCriteria); @Override void delete(Object dataObject); @Override void deleteMatching(Class<T> type, QueryByCriteria queryByCriteria); @Override void deleteAll(Class<T> type); @Override T save(T dataObject, PersistenceOption... options); @Override MetadataRepository getMetadataRepository(); @Override T copyInstance(T dataObject, CopyOption... options); @Override DataObjectWrapper<T> wrap(T dataObject); @Override boolean supports(Class<T> type); @Override void flush(Class<?> type); @Required void setProviderRegistry(ProviderRegistry providerRegistry); @Required void setMetadataRepository(MetadataRepository metadataRepository); ReferenceLinker getReferenceLinker(); @Required void setReferenceLinker(ReferenceLinker referenceLinker);  }
@Test public void testSave() { Serializable dataObject = new Serializable() {}; service.save(dataObject); verify(mockProvider).save(eq(dataObject)); }