{"id":25776467,"url":"https://github.com/mmnaseri/spring-data-mock","last_synced_at":"2026-01-17T16:28:12.713Z","repository":{"id":27633102,"uuid":"31117630","full_name":"mmnaseri/spring-data-mock","owner":"mmnaseri","description":"Mock facility for Spring Data repositories","archived":false,"fork":false,"pushed_at":"2023-05-09T18:47:11.000Z","size":2460,"stargazers_count":139,"open_issues_count":13,"forks_count":43,"subscribers_count":11,"default_branch":"development","last_synced_at":"2025-08-15T23:15:35.889Z","etag":null,"topics":["database","java","mocking","repository","spring-data","testing","unit-testing"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mmnaseri.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"custom":["https://paypal.me/mmnaseri"]}},"created_at":"2015-02-21T06:38:19.000Z","updated_at":"2025-08-13T11:12:59.000Z","dependencies_parsed_at":"2022-08-31T20:00:56.973Z","dependency_job_id":null,"html_url":"https://github.com/mmnaseri/spring-data-mock","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/mmnaseri/spring-data-mock","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmnaseri%2Fspring-data-mock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmnaseri%2Fspring-data-mock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmnaseri%2Fspring-data-mock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmnaseri%2Fspring-data-mock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mmnaseri","download_url":"https://codeload.github.com/mmnaseri/spring-data-mock/tar.gz/refs/heads/development","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmnaseri%2Fspring-data-mock/sbom","scorecard":{"id":654557,"data":{"date":"2025-08-11","repo":{"name":"github.com/mmnaseri/spring-data-mock","commit":"e8547729050c9454872a1038c23bb9b1288c8654"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.8,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/10 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE.md:0","Info: FSF or OSI recognized license: MIT License: LICENSE.md:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: containerImage not pinned by hash: Dockerfile:1: pin your Docker image by updating ubuntu:xenial to ubuntu:xenial@sha256:1f1a2d56de1d604801a9671f301190704c25d604a416f59e03c04f5c6ffee0d6","Info:   0 out of   1 containerImage dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during GetBranch(master): error during branchesHandler.query: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 30 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"13 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-36p3-wjmg-h94x","Warn: Project is vulnerable to: GHSA-hh26-6xwr-ggv7","Warn: Project is vulnerable to: GHSA-4gc7-5j7h-4qph","Warn: Project is vulnerable to: GHSA-4wp7-92pw-q264","Warn: Project is vulnerable to: GHSA-g5mm-vmx4-3rg7","Warn: Project is vulnerable to: GHSA-6gf2-pvqw-37ph","Warn: Project is vulnerable to: GHSA-rfmp-97jj-h8m6","Warn: Project is vulnerable to: GHSA-558x-2xjg-6232","Warn: Project is vulnerable to: GHSA-564r-hj7v-mcr5","Warn: Project is vulnerable to: GHSA-9cmq-m9j5-mvww","Warn: Project is vulnerable to: GHSA-wxqc-pxw9-g2p8","Warn: Project is vulnerable to: GHSA-rghw-6px2-fgwc","Warn: Project is vulnerable to: GHSA-w24x-87mr-4r23"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-21T14:18:48.962Z","repository_id":27633102,"created_at":"2025-08-21T14:18:48.962Z","updated_at":"2025-08-21T14:18:48.962Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28511864,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T13:38:16.342Z","status":"ssl_error","status_checked_at":"2026-01-17T13:37:44.060Z","response_time":85,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database","java","mocking","repository","spring-data","testing","unit-testing"],"created_at":"2025-02-27T06:01:24.731Z","updated_at":"2026-01-17T16:28:12.689Z","avatar_url":"https://github.com/mmnaseri.png","language":"Java","funding_links":["https://paypal.me/mmnaseri"],"categories":["测试"],"sub_categories":[],"readme":"\n# Spring Data Mock\n\n[![Donae](https://img.shields.io/badge/paypal-donate-yellow.svg)](https://paypal.me/mmnaseri)\n[![MIT license](http://img.shields.io/badge/license-MIT-brightgreen.svg)](http://opensource.org/licenses/MIT)\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.mmnaseri.utils/spring-data-mock/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.mmnaseri.utils/spring-data-mock)\n[![Build Status](https://travis-ci.org/mmnaseri/spring-data-mock.svg?branch=master)](https://travis-ci.org/mmnaseri/spring-data-mock)\n[![Codacy Badge](https://api.codacy.com/project/badge/grade/ad9f174fa0654a2b8c925b86973f272d)](https://www.codacy.com/app/mmnaseri/spring-data-mock)\n[![Coverage Status](https://coveralls.io/repos/github/mmnaseri/spring-data-mock/badge.svg?branch=master)](https://coveralls.io/github/mmnaseri/spring-data-mock?branch=master)\n\n-----------\n\nThis is a fairly flexible, versatile framework for mocking Spring Data repositories. Spring Data provides a very good\nfoundation for separating the concerns of managing a database and its subsequently resulting queries from those of the\nbusiness layer.\n\nThis is great for writing services. They only need to depend upon Spring Data repositories and manage their data through\nthis level of indirection. This, however, means that for testing purposes, you will either have to write lots of boilerplate\ncode for your Spring powered application, or you will have to start up a full blown application context with a backing\ndatabase.\n\nFor most test cases, this is entirely unnecessary and, moreover, creates time burdens and takes away valuable time from\nproductive tasks. This is why I decided to write this framework: to avoid the unnecessary effort, and to have a reliable\ninfrastructure replicating what Spring would do with an actual database, only in-memory. This will allow for mocking the\nrepository with actual data. Thus, you can test your services *without* having to start up the application context, and\nwith the highest level of isolation -- with actual data.\n\n## Downloading\n\nYou can either clone this project and start using it:\n\n    $ git clone https://github.com/mmnaseri/spring-data-mock.git\n\nor you can add a maven dependency since it is now available in Maven central:\n\n    \u003cdependency\u003e\n        \u003cgroupId\u003ecom.mmnaseri.utils\u003c/groupId\u003e\n        \u003cartifactId\u003espring-data-mock\u003c/artifactId\u003e\n        \u003cversion\u003e${spring-data-mock.version}\u003c/version\u003e\n        \u003cscope\u003etest\u003c/scope\u003e\n    \u003c/dependency\u003e\n\n#### Note on Dependencies\n\n*Spring Data Mock* depends on [Apache Commons Logging](https://commons.apache.org/proper/commons-logging/) to log\nall the interactions with the framework. If you need to, you can exclude this dependency from the framework by\nusing [Maven exclusions](https://maven.apache.org/guides/introduction/introduction-to-optional-and-excludes-dependencies.html#Dependency_Exclusions):\n\n```xml\n    \u003cdependency\u003e\n        \u003cgroupId\u003ecom.mmnaseri.utils\u003c/groupId\u003e\n        \u003cartifactId\u003espring-data-mock\u003c/artifactId\u003e\n        \u003cversion\u003e${spring-data-mock.version}\u003c/version\u003e\n        \u003cscope\u003etest\u003c/scope\u003e\n        \u003cexclusions\u003e\n            \u003cexclusion\u003e\n                \u003cgroupId\u003ecommons-logging\u003c/groupId\u003e\n                \u003cartifactId\u003ecommons-logging\u003c/artifactId\u003e\n            \u003c/exclusion\u003e\n        \u003c/exclusions\u003e\n    \u003c/dependency\u003e\n```\n\n## Quick Start\n\nRegardless of how you add the necessary dependency to your project, mocking a repository can be as simple as:\n\n    final UserRepository repository = builder().mock(UserRepository.class);\n    \nwhere `builder()` is a static method of the `RepositoryFactoryBuilder` class under package `com.mmnaseri.utils.spring.data.dsl.factory`.\n\nExample:\n\n```java\nimport com.mmnaseri.utils.spring.data.dsl.factory.RepositoryFactoryBuilder;\n\npublic class CustomerRepositoryTest {\n\n    @Test\n    public void testDemo() {\n\n        final CustomerRepository repository = RepositoryFactoryBuilder.builder().mock(CustomerRepository.class);\n        repository.save(new Customer());\n```\n\nAn alternate way of mocking a repository would be by using the `RepositoryMockBuilder` class under the `com.mmnaseri.utils.spring.data.dsl.mock`\npackage:\n\n    final RepositoryFactoryConfiguration configuration = ... ;\n    final UserRepository repository = new RepositoryMockBuilder().useConfiguration(configuration).mock(UserRepository.class);\n    \nDocumentation\n-------------\n\nFor a complete documentation check out [the website](https://mmnaseri.github.io/spring-data-mock).\n\nThere you can get more information on how to download the framework, as well as how you can\nincorporate it in your project to have hassle-free data store mocking capabilities added to\nyour shiny applications.\n\n## Breaking Changes since v2.0\n\n`v2.0` introduces compatibility with Spring Boot 2.0, but also creates some incompatibilities with prior versions.\n\n- As well it should, it is now adopting all the new method signatures for the new Spring Data, meaning that those\nare now automatic breaking changes.\n- The library now runs on Java 8+, meaning we do not support JDK 7 anymore.\n\n## History\n\n- 2.0 Upgrade to Spring Boot 2.0 (many thanks to binakot@). This is a major release and breaks some stuff.\n\n- 1.1 Add QueryDSL and findByExample support\n\nsee [site changelog](https://mmnaseri.github.io/spring-data-mock/site/#/changelog)\n\n\nFAQ\n-------------\n\n  1. Why did you write this?\n\n  \u003e I was testing some pretty complicated services that relied on Spring Data to provide data. It was a lot of\n  hassle to keep the test environment up-to-date with the test requirements as well as the real world situation.\n  Also, it was pretty darn slow to run the tests, given database connection latency and all. I wanted to be able\n  to isolate my services and test them regardless of the database features. To make it short, I wrote this\n  framework to be able to separate integration/acceptance tests and unit tests.\n\n  2. Why did you make this open source?\n\n  \u003e Because everything I use (or nearly so) in my line of work is open source. It was time I gave something back.\n  Also, the people behind Spring rock. I felt like I was selling tickets to the concert of rockstars by releasing\n  this.\n\n  3. What is the main design principle behind this framework?\n\n  \u003e Make you do as little as possible.\n\n  4. When should I use this?\n\n  \u003e You should only use this to write your *unit* tests. For anything else, you would want the whole application to\n  come alive and work. Using mocks for that is a bad idea.\n\n  5. This is going to be used at the level of code testing. Is it really well written?\n\n  \u003e It is. According to Cobertura, it has **100% code coverage**, and according to Codacy, it has **0 code issues**.\n  It is maintained by myself the best I can. The rest is up to you.\n\nSome Numbers and Facts\n----------------------\n\n  * This project has *1000+* individual unit tests.\n\n  * This project has effective **100%** (deprecated code is not tested) [code coverage](https://coveralls.io/github/mmnaseri/spring-data-mock)\n\n  * This project has **95%** branch coverage rate.\n\n  * The project issue response turn around is an average of 2 days.\n\n  * It covers *all* the repository specifications in Spring Data Commons (except predicates -- support is planned).\n\n  * It has more than 6k lines of code, a lot of which is unit tests.\n\n  * Every public class or method has JavaDoc\n\n  * There is a dedicated documentation website for this project at https://mmnaseri.github.io/spring-data-mock/\n\nContribution\n------------\n\nSince this project aims to help you in the testing phase of your code, it is paramount that it is\nwritten with the best of qualities and that it maintains the highest standard.\n\nContributors are more than welcome. In fact, I flag most of the issues I receive as `help wanted` and\nthere are really generous people out there who do take care of some issues.\n\nIf you see a piece of code that you don't like for whatever reason -- so long as that reason can be backed\nby pioneers and standards -- feel free to dig in and change the code to your heart's content and create a\npull request.\n\n### Building the Code\n\nTo make the code builds universal and canonical, I have a Docker configuration attached to this project\nwhich installs OpenJDK 8 on Ubuntu Xenial. This is the build environment I will be using to test and release\nthe code.\n\n```bash\ndocker build -t spring-data-mock:jdk8 .\ndocker run -it --rm -v $(pwd):/src spring-data-mock:jdk8\n```\n\nDonation\n--------\n\nThis software is written without any expectations. I developed this originally to solve a business need at\nthe company I was working at at the time, and then rewrote it for the purpose of open-sourcing it.\n\nAfter it received some attention, I decided that I should sit down and redo it.\n\nThat is why I did a marathon development on it, and got it to a point where I could say it was safe for\npublic use.\n\nIt still has a lot of room for improvement and enhancements. Even though I will continue to develop and\nmaintain this framework, receiving donations would make it feel so much more real.\n\nIf you feel generous and want to buy me a cup of coffee, you can use my PayPal link: https://paypal.me/mmnaseri\n\nThank you in advance if you choose to donate! And if not, I hope you have some time to explore this framework\nand give me feedback so that I can make it better.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmmnaseri%2Fspring-data-mock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmmnaseri%2Fspring-data-mock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmmnaseri%2Fspring-data-mock/lists"}