repo
stringclasses
1k values
file_url
stringlengths
96
373
file_path
stringlengths
11
294
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
6 values
commit_sha
stringclasses
1k values
retrieved_at
stringdate
2026-01-04 14:45:56
2026-01-04 18:30:23
truncated
bool
2 classes
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/domain/impl/matchers/IsLikeMatcherTest.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/domain/impl/matchers/IsLikeMatcherTest.java
package com.mmnaseri.utils.spring.data.domain.impl.matchers; import org.testng.annotations.Test; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (9/30/15) */ public class IsLikeMatcherTest { @Test public void testWhenSubjectIsNull() { assertThat(new IsLikeMatcher().matches(null, ""), is(false)); } @Test public void testWhenReferenceIsNull() { assertThat(new IsLikeMatcher().matches("", null), is(false)); } @Test public void testWhenTheyAreNotAlike() { assertThat(new IsLikeMatcher().matches("Hello World", "World"), is(false)); } @Test public void testWhenTheyAreAlike() { assertThat(new IsLikeMatcher().matches("Hello world!", "hello WORLD!"), is(true)); } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/domain/impl/matchers/IsLessThanMatcherTest.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/domain/impl/matchers/IsLessThanMatcherTest.java
package com.mmnaseri.utils.spring.data.domain.impl.matchers; import com.mmnaseri.utils.spring.data.domain.impl.ImmutableParameter; import com.mmnaseri.utils.spring.data.error.InvalidArgumentException; import org.testng.annotations.Test; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (9/30/15) */ public class IsLessThanMatcherTest { @Test( expectedExceptions = InvalidArgumentException.class, expectedExceptionsMessageRegExp = "Expected property to be comparable: xyz") public void testValueIsNotComparable() { new IsLessThanMatcher() .matches(new ImmutableParameter("xyz", null, null, null), new Object(), new Object()); } @Test public void testValuesAreEqual() { assertThat(new IsLessThanMatcher().matches(5, 5), is(false)); } @Test public void testActualIsLessThanPivot() { assertThat(new IsLessThanMatcher().matches(1, 5), is(true)); } @Test public void testActualIsGreaterThanPivot() { assertThat(new IsLessThanMatcher().matches(10, 5), is(false)); } @Test public void testActualIsNull() { assertThat(new IsLessThanMatcher().matches(null, 5), is(false)); } @Test public void testPivotIsNull() { assertThat(new IsLessThanMatcher().matches(5, null), is(false)); } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/domain/impl/matchers/IsNullMatcherTest.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/domain/impl/matchers/IsNullMatcherTest.java
package com.mmnaseri.utils.spring.data.domain.impl.matchers; import org.testng.annotations.Test; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (9/30/15) */ public class IsNullMatcherTest { @Test public void testSubjectIsNull() { assertThat(new IsNullMatcher().matches(null), is(true)); } @Test public void testSubjectIsNotNull() { assertThat(new IsNullMatcher().matches(new Object()), is(false)); } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/domain/impl/matchers/EndingWithMatcherTest.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/domain/impl/matchers/EndingWithMatcherTest.java
package com.mmnaseri.utils.spring.data.domain.impl.matchers; import org.testng.annotations.Test; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (9/29/15) */ public class EndingWithMatcherTest { @Test public void testWhenActualIsNull() { assertThat(new EndingWithMatcher().matches(null, ""), is(false)); } @Test public void testWhenParameterIsNull() { assertThat(new EndingWithMatcher().matches("", null), is(false)); } @Test public void testWhenBothAreNull() { assertThat(new EndingWithMatcher().matches(null, null), is(false)); } @Test public void testWhenActualDoesNotEndWithParameter() { assertThat(new EndingWithMatcher().matches("xyz", "abc"), is(false)); } @Test public void testWhenActualEndsWithParameter() { assertThat(new EndingWithMatcher().matches("HelloWorld", "WORLD"), is(true)); } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/domain/impl/matchers/IsBetweenMatcherTest.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/domain/impl/matchers/IsBetweenMatcherTest.java
package com.mmnaseri.utils.spring.data.domain.impl.matchers; import org.testng.annotations.Test; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (9/29/15) */ public class IsBetweenMatcherTest { @Test public void testWhenActualIsNull() { assertThat(new IsBetweenMatcher().matches(null, 1, 2), is(false)); } @Test public void testWhenLowerBoundIsNull() { assertThat(new IsBetweenMatcher().matches(1, null, 2), is(false)); } @Test public void testWhenUpperBoundIsNull() { assertThat(new IsBetweenMatcher().matches(1, 2, null), is(false)); } @Test public void testWhenRangeDoesNotContainValue() { assertThat(new IsBetweenMatcher().matches(1, 3, 6), is(false)); } @Test public void testWhenRangeContainsValueInclusive() { assertThat(new IsBetweenMatcher().matches(3, 3, 6), is(true)); assertThat(new IsBetweenMatcher().matches(6, 3, 6), is(true)); } @Test public void testWhenRangeContainsValueMidRange() { assertThat(new IsBetweenMatcher().matches(4, 3, 6), is(true)); } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/domain/impl/matchers/IsLessThanOrEqualToMatcherTest.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/domain/impl/matchers/IsLessThanOrEqualToMatcherTest.java
package com.mmnaseri.utils.spring.data.domain.impl.matchers; import com.mmnaseri.utils.spring.data.domain.impl.ImmutableParameter; import com.mmnaseri.utils.spring.data.error.InvalidArgumentException; import org.testng.annotations.Test; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (9/30/15) */ public class IsLessThanOrEqualToMatcherTest { @Test( expectedExceptions = InvalidArgumentException.class, expectedExceptionsMessageRegExp = "Expected property to be comparable: xyz") public void testValueIsNotComparable() { new IsLessThanOrEqualToMatcher() .matches(new ImmutableParameter("xyz", null, null, null), new Object(), new Object()); } @Test public void testValuesAreEqual() { assertThat(new IsLessThanOrEqualToMatcher().matches(5, 5), is(true)); } @Test public void testActualIsLessThanPivot() { assertThat(new IsLessThanOrEqualToMatcher().matches(1, 5), is(true)); } @Test public void testActualIsGreaterThanPivot() { assertThat(new IsLessThanOrEqualToMatcher().matches(10, 5), is(false)); } @Test public void testActualIsNull() { assertThat(new IsLessThanOrEqualToMatcher().matches(null, 5), is(false)); } @Test public void testPivotIsNull() { assertThat(new IsLessThanOrEqualToMatcher().matches(5, null), is(false)); } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/domain/impl/matchers/IsTrueMatcherTest.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/domain/impl/matchers/IsTrueMatcherTest.java
package com.mmnaseri.utils.spring.data.domain.impl.matchers; import org.testng.annotations.Test; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (9/30/15) */ public class IsTrueMatcherTest { @Test public void testWhenSubjectIsNull() { assertThat(new IsTrueMatcher().matches(null), is(false)); } @Test public void testSubjectIsNonBoolean() { assertThat(new IsTrueMatcher().matches(""), is(false)); } @Test public void testIsFalse() { assertThat(new IsTrueMatcher().matches(false), is(false)); } @Test public void testIsTrue() { assertThat(new IsTrueMatcher().matches(true), is(true)); } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/domain/impl/matchers/StartingWithMatcherTest.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/domain/impl/matchers/StartingWithMatcherTest.java
package com.mmnaseri.utils.spring.data.domain.impl.matchers; import org.testng.annotations.Test; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (9/29/15) */ public class StartingWithMatcherTest { @Test public void testWhenActualIsNull() { assertThat(new StartingWithMatcher().matches(null, ""), is(false)); } @Test public void testWhenParameterIsNull() { assertThat(new StartingWithMatcher().matches("", null), is(false)); } @Test public void testWhenBothAreNull() { assertThat(new StartingWithMatcher().matches(null, null), is(false)); } @Test public void testWhenActualDoesNotStartWithParameter() { assertThat(new StartingWithMatcher().matches("xyz", "abc"), is(false)); } @Test public void testWhenActualStartsWithParameter() { assertThat(new StartingWithMatcher().matches("HelloWorld", "HELLO"), is(true)); } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/domain/impl/matchers/AbstractUnaryMatcherTest.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/domain/impl/matchers/AbstractUnaryMatcherTest.java
package com.mmnaseri.utils.spring.data.domain.impl.matchers; import com.mmnaseri.utils.spring.data.domain.impl.ImmutableOperator; import com.mmnaseri.utils.spring.data.domain.impl.ImmutableParameter; import com.mmnaseri.utils.spring.data.error.InvalidArgumentException; import com.mmnaseri.utils.spring.data.sample.mocks.NotMatchingUnaryMatcher; import org.testng.annotations.Test; import static org.testng.Assert.assertFalse; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/10/16) */ public class AbstractUnaryMatcherTest { @Test( expectedExceptions = InvalidArgumentException.class, expectedExceptionsMessageRegExp = ".*x.y.z.*") public void testWhenHasParameters() { final NotMatchingUnaryMatcher matcher = new NotMatchingUnaryMatcher(); matcher.matches( new ImmutableParameter( "x.y.z", null, null, new ImmutableOperator("sample operator", 0, null)), new Object(), new Object()); } @Test public void testWhenHasNoParameters() { final NotMatchingUnaryMatcher matcher = new NotMatchingUnaryMatcher(); matcher.matches(new ImmutableParameter("x.y.z", null, null, null), new Object()); } @Test public void shouldNotApplyToNonEmptyListOfParameters() { final NotMatchingUnaryMatcher matcher = new NotMatchingUnaryMatcher(); assertFalse(matcher.isApplicableTo(String.class, String.class)); } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/domain/impl/matchers/AbstractBinaryComparableMatcherTest.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/domain/impl/matchers/AbstractBinaryComparableMatcherTest.java
package com.mmnaseri.utils.spring.data.domain.impl.matchers; import com.mmnaseri.utils.spring.data.domain.impl.ImmutableParameter; import com.mmnaseri.utils.spring.data.error.InvalidArgumentException; import com.mmnaseri.utils.spring.data.sample.mocks.NotMatchingBinaryComparableMatcher; import org.testng.annotations.Test; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/10/16) */ public class AbstractBinaryComparableMatcherTest { @Test( expectedExceptions = InvalidArgumentException.class, expectedExceptionsMessageRegExp = ".*x.y.z.*") public void testWhenValueIsNotComparable() { final NotMatchingBinaryComparableMatcher matcher = new NotMatchingBinaryComparableMatcher(); matcher.matches(new ImmutableParameter("x.y.z", null, null, null), new Object(), 1, 2); } @Test( expectedExceptions = InvalidArgumentException.class, expectedExceptionsMessageRegExp = ".*x.y.z.*") public void testWhenFirstParameterIsNotComparable() { final NotMatchingBinaryComparableMatcher matcher = new NotMatchingBinaryComparableMatcher(); matcher.matches(new ImmutableParameter("x.y.z", null, null, null), 1, new Object(), 2); } @Test( expectedExceptions = InvalidArgumentException.class, expectedExceptionsMessageRegExp = ".*x.y.z.*") public void testWhenSecondParameterIsNotComparable() { final NotMatchingBinaryComparableMatcher matcher = new NotMatchingBinaryComparableMatcher(); matcher.matches(new ImmutableParameter("x.y.z", null, null, null), 1, 2, new Object()); } @Test public void testWhenAllAreComparable() { final NotMatchingBinaryComparableMatcher matcher = new NotMatchingBinaryComparableMatcher(); matcher.matches(new ImmutableParameter("x.y.z", null, null, null), 1, 2, 3); } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/domain/impl/matchers/IsFalseMatcherTest.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/domain/impl/matchers/IsFalseMatcherTest.java
package com.mmnaseri.utils.spring.data.domain.impl.matchers; import org.testng.annotations.Test; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (9/30/15) */ public class IsFalseMatcherTest { @Test public void testWhenSubjectIsNull() { assertThat(new IsFalseMatcher().matches(null), is(false)); } @Test public void testSubjectIsNonBoolean() { assertThat(new IsFalseMatcher().matches(""), is(false)); } @Test public void testIsFalse() { assertThat(new IsFalseMatcher().matches(false), is(true)); } @Test public void testIsTrue() { assertThat(new IsFalseMatcher().matches(true), is(false)); } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/domain/impl/matchers/AbstractBinaryMatcherTest.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/domain/impl/matchers/AbstractBinaryMatcherTest.java
package com.mmnaseri.utils.spring.data.domain.impl.matchers; import com.mmnaseri.utils.spring.data.domain.impl.ImmutableOperator; import com.mmnaseri.utils.spring.data.domain.impl.ImmutableParameter; import com.mmnaseri.utils.spring.data.error.InvalidArgumentException; import com.mmnaseri.utils.spring.data.sample.mocks.NotMatchingBinaryMatcher; import org.testng.annotations.Test; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertTrue; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/10/16) */ public class AbstractBinaryMatcherTest { @Test( expectedExceptions = InvalidArgumentException.class, expectedExceptionsMessageRegExp = ".*x.y.z.*") public void testWhenHasLessThanTwoParameters() { final NotMatchingBinaryMatcher matcher = new NotMatchingBinaryMatcher(); matcher.matches( new ImmutableParameter("x.y.z", null, null, new ImmutableOperator("sample", 2, null)), new Object()); } @Test( expectedExceptions = InvalidArgumentException.class, expectedExceptionsMessageRegExp = ".*x.y.z.*") public void testWhenHasMoreThanTwoParameters() { final NotMatchingBinaryMatcher matcher = new NotMatchingBinaryMatcher(); matcher.matches( new ImmutableParameter("x.y.z", null, null, new ImmutableOperator("sample", 2, null)), new Object(), new Object(), new Object(), new Object()); } @Test public void testWhenHasTwoParameters() { final NotMatchingBinaryMatcher matcher = new NotMatchingBinaryMatcher(); // we are creating the varargs array explicitly to call to the proper method signature //noinspection RedundantArrayCreation matcher.matches( new ImmutableParameter("x.y.z", null, null, new ImmutableOperator("sample", 2, null)), new Object(), new Object[] {new Object(), new Object()}); } @Test public void testIsApplicableTo() { final NotMatchingBinaryMatcher matcher = new NotMatchingBinaryMatcher(); assertTrue(matcher.isApplicableTo(String.class, String.class, String.class)); } @Test public void shouldNotBeApplicableToOnlyOneArgument() { final NotMatchingBinaryMatcher matcher = new NotMatchingBinaryMatcher(); assertFalse(matcher.isApplicableTo(String.class, String.class)); } @Test public void shouldNotBeApplicableToIncompatibleFirstArgument() { final NotMatchingBinaryMatcher matcher = new NotMatchingBinaryMatcher(); assertFalse(matcher.isApplicableTo(String.class, Integer.class, String.class)); } @Test public void shouldNotBeApplicableToIncompatibleSecondArgument() { final NotMatchingBinaryMatcher matcher = new NotMatchingBinaryMatcher(); assertFalse(matcher.isApplicableTo(String.class, String.class, Integer.class)); } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/domain/impl/matchers/IsGreaterThanOrEqualToMatcherTest.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/domain/impl/matchers/IsGreaterThanOrEqualToMatcherTest.java
package com.mmnaseri.utils.spring.data.domain.impl.matchers; import com.mmnaseri.utils.spring.data.domain.impl.ImmutableParameter; import com.mmnaseri.utils.spring.data.error.InvalidArgumentException; import org.testng.annotations.Test; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (9/30/15) */ public class IsGreaterThanOrEqualToMatcherTest { @Test( expectedExceptions = InvalidArgumentException.class, expectedExceptionsMessageRegExp = "Expected property to be comparable: xyz") public void testValueIsNotComparable() { new IsGreaterThanOrEqualToMatcher() .matches(new ImmutableParameter("xyz", null, null, null), new Object(), new Object()); } @Test public void testValuesAreEqual() { assertThat(new IsGreaterThanOrEqualToMatcher().matches(5, 5), is(true)); } @Test public void testActualIsLessThanPivot() { assertThat(new IsGreaterThanOrEqualToMatcher().matches(1, 5), is(false)); } @Test public void testActualIsGreaterThanPivot() { assertThat(new IsGreaterThanOrEqualToMatcher().matches(10, 5), is(true)); } @Test public void testActualIsNull() { assertThat(new IsGreaterThanOrEqualToMatcher().matches(null, 5), is(false)); } @Test public void testPivotIsNull() { assertThat(new IsGreaterThanOrEqualToMatcher().matches(5, null), is(false)); } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/domain/impl/matchers/AbstractSimpleMatcherTest.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/domain/impl/matchers/AbstractSimpleMatcherTest.java
package com.mmnaseri.utils.spring.data.domain.impl.matchers; import com.mmnaseri.utils.spring.data.domain.impl.ImmutableParameter; import com.mmnaseri.utils.spring.data.error.InvalidArgumentException; import com.mmnaseri.utils.spring.data.sample.mocks.NotMatchingSimpleMatcher; import org.testng.annotations.Test; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertTrue; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/10/16) */ public class AbstractSimpleMatcherTest { @Test( expectedExceptions = InvalidArgumentException.class, expectedExceptionsMessageRegExp = ".*x.y.z.*") public void testWhenHasNoParameters() { final NotMatchingSimpleMatcher matcher = new NotMatchingSimpleMatcher(); matcher.matches(new ImmutableParameter("x.y.z", null, null, null), new Object()); } @Test( expectedExceptions = InvalidArgumentException.class, expectedExceptionsMessageRegExp = ".*x.y.z.*") public void testWhenHasMoreThanOneParameters() { final NotMatchingSimpleMatcher matcher = new NotMatchingSimpleMatcher(); matcher.matches(new ImmutableParameter("x.y.z", null, null, null), new Object(), 1, 2, 3); } @Test public void testWhenHasOneParameter() { final NotMatchingSimpleMatcher matcher = new NotMatchingSimpleMatcher(); matcher.matches(new ImmutableParameter("x.y.z", null, null, null), new Object(), 1); } @Test public void testApplicableToSameType() { final NotMatchingSimpleMatcher matcher = new NotMatchingSimpleMatcher(); assertTrue(matcher.isApplicableTo(String.class, String.class)); } @Test public void testApplicableToSubType() { final NotMatchingSimpleMatcher matcher = new NotMatchingSimpleMatcher(); assertTrue(matcher.isApplicableTo(Number.class, Integer.class)); } @Test public void testNonApplicableToDifferentType() { final NotMatchingSimpleMatcher matcher = new NotMatchingSimpleMatcher(); assertFalse(matcher.isApplicableTo(String.class, Integer.class)); } @Test public void shouldNotBeApplicableToDifferentNumberOfArguments() { final NotMatchingSimpleMatcher matcher = new NotMatchingSimpleMatcher(); assertFalse(matcher.isApplicableTo(String.class, String.class, String.class)); } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/domain/impl/matchers/IsEqualToMatcherTest.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/domain/impl/matchers/IsEqualToMatcherTest.java
package com.mmnaseri.utils.spring.data.domain.impl.matchers; import org.testng.annotations.Test; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (9/30/15) */ public class IsEqualToMatcherTest { @Test public void testWhenBothAreNull() { assertThat(new IsEqualToMatcher().matches(null, null, new Object[] {null}), is(true)); } @Test public void testWhenTheyAreTheSameInstance() { final Object obj = new Object(); assertThat(new IsEqualToMatcher().matches(null, obj, obj), is(true)); } @Test public void testWhenTheyHaveTheSameValue() { assertThat(new IsEqualToMatcher().matches(null, 1, 1), is(true)); } @Test public void testWhenTheyDiffer() { assertThat(new IsEqualToMatcher().matches(null, new Object(), new Object()), is(false)); } @Test public void testWhenTheyHaveDifferentValues() { assertThat(new IsEqualToMatcher().matches(null, 1, 2), is(false)); } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/domain/impl/matchers/IsNotNullMatcherTest.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/domain/impl/matchers/IsNotNullMatcherTest.java
package com.mmnaseri.utils.spring.data.domain.impl.matchers; import org.testng.annotations.Test; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (9/30/15) */ public class IsNotNullMatcherTest { @Test public void testSubjectIsNull() { assertThat(new IsNotNullMatcher().matches(null), is(false)); } @Test public void testSubjectIsNotNull() { assertThat(new IsNotNullMatcher().matches(new Object()), is(true)); } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/domain/impl/matchers/IsGreaterThanMatcherTest.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/domain/impl/matchers/IsGreaterThanMatcherTest.java
package com.mmnaseri.utils.spring.data.domain.impl.matchers; import com.mmnaseri.utils.spring.data.domain.impl.ImmutableParameter; import com.mmnaseri.utils.spring.data.error.InvalidArgumentException; import org.testng.annotations.Test; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (9/30/15) */ public class IsGreaterThanMatcherTest { @Test( expectedExceptions = InvalidArgumentException.class, expectedExceptionsMessageRegExp = "Expected property to be comparable: xyz") public void testValueIsNotComparable() { new IsGreaterThanMatcher() .matches(new ImmutableParameter("xyz", null, null, null), new Object(), new Object()); } @Test public void testValuesAreEqual() { assertThat(new IsGreaterThanMatcher().matches(5, 5), is(false)); } @Test public void testActualIsLessThanPivot() { assertThat(new IsGreaterThanMatcher().matches(1, 5), is(false)); } @Test public void testActualIsGreaterThanPivot() { assertThat(new IsGreaterThanMatcher().matches(10, 5), is(true)); } @Test public void testActualIsNull() { assertThat(new IsGreaterThanMatcher().matches(null, 5), is(false)); } @Test public void testPivotIsNull() { assertThat(new IsGreaterThanMatcher().matches(5, null), is(false)); } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/domain/impl/matchers/IsInMatcherTest.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/domain/impl/matchers/IsInMatcherTest.java
package com.mmnaseri.utils.spring.data.domain.impl.matchers; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Iterator; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertTrue; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (9/30/15) */ public class IsInMatcherTest { @Test public void testWhenItemIsNull() { assertThat(new IsInMatcher().matches(null, Collections.emptyList()), is(false)); } @Test public void testWhenItemIsInCollection() { assertThat(new IsInMatcher().matches(1, Arrays.asList(1, 2, 3, 4)), is(true)); } @Test public void testWhenItemIsNotInCollection() { assertThat(new IsInMatcher().matches(1, Arrays.asList(3, 4, 5, 6)), is(false)); } @DataProvider public Object[][] allowedTypes() { return new Object[][] {{Collection.class}, {Iterable.class}, {Iterator.class}}; } @Test(dataProvider = "allowedTypes") public void testAllowedParameterType(Class<?> parameterType) { assertTrue(new IsInMatcher().isApplicableTo(String.class, parameterType)); } @Test public void testInvalidParameterType() { assertFalse(new IsInMatcher().isApplicableTo(String.class, String.class)); } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/domain/impl/matchers/ContainingMatcherTest.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/domain/impl/matchers/ContainingMatcherTest.java
package com.mmnaseri.utils.spring.data.domain.impl.matchers; import org.testng.annotations.Test; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (9/29/15) */ public class ContainingMatcherTest { @Test public void testMatchingWhenActualIsNull() { assertThat(new ContainingMatcher().matches(null, ""), is(false)); } @Test public void testMatchingWhenParameterIsNull() { assertThat(new ContainingMatcher().matches("", null), is(false)); } @Test public void testMatchingWhenParameterDoesNotContainActual() { assertThat(new ContainingMatcher().matches("xyz", "abc"), is(false)); } @Test public void testMatchingWhenParameterContainsActual() { assertThat(new ContainingMatcher().matches("HelloWorld", "owo"), is(true)); } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/domain/impl/id/IdPropertyResolverUtilsTest.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/domain/impl/id/IdPropertyResolverUtilsTest.java
package com.mmnaseri.utils.spring.data.domain.impl.id; import com.mmnaseri.utils.spring.data.error.PropertyTypeMismatchException; import com.mmnaseri.utils.spring.data.sample.models.EntityWithAnnotatedEmbeddedIdField; import com.mmnaseri.utils.spring.data.sample.models.EntityWithAnnotatedEmbeddedIdFieldFromJPA; import com.mmnaseri.utils.spring.data.sample.models.EntityWithAnnotatedEmbeddedIdGetter; import com.mmnaseri.utils.spring.data.sample.models.EntityWithAnnotatedEmbeddedIdGetterFromJPA; import com.mmnaseri.utils.spring.data.sample.models.EntityWithAnnotatedIdField; import com.mmnaseri.utils.spring.data.sample.models.EntityWithAnnotatedIdFieldFromJPA; import com.mmnaseri.utils.spring.data.sample.models.EntityWithAnnotatedIdGetter; import com.mmnaseri.utils.spring.data.sample.models.EntityWithAnnotatedIdGetterFromJPA; import com.mmnaseri.utils.spring.data.tools.AbstractUtilityClassTest; import org.testng.annotations.Test; import java.lang.reflect.Field; import java.util.List; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.notNullValue; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (6/8/16, 1:49 AM) */ public class IdPropertyResolverUtilsTest extends AbstractUtilityClassTest { @Override protected Class<?> getUtilityClass() { return IdPropertyResolverUtils.class; } @Test public void testReadingAnnotationFromField() throws Exception { assertThat( IdPropertyResolverUtils.isAnnotated( EntityWithAnnotatedIdFieldFromJPA.class.getDeclaredField("customIdProperty")), is(true)); assertThat( IdPropertyResolverUtils.isAnnotated( EntityWithAnnotatedEmbeddedIdFieldFromJPA.class.getDeclaredField("customIdProperty")), is(true)); assertThat( IdPropertyResolverUtils.isAnnotated( EntityWithAnnotatedIdField.class.getDeclaredField("id")), is(true)); assertThat( IdPropertyResolverUtils.isAnnotated( EntityWithAnnotatedEmbeddedIdField.class.getDeclaredField("id")), is(true)); } @Test public void testReadingAnnotationFromMethod() throws Exception { assertThat( IdPropertyResolverUtils.isAnnotated( EntityWithAnnotatedIdGetterFromJPA.class.getDeclaredMethod("getMyCustomId")), is(true)); assertThat( IdPropertyResolverUtils.isAnnotated( EntityWithAnnotatedEmbeddedIdGetterFromJPA.class.getDeclaredMethod("getMyCustomId")), is(true)); assertThat( IdPropertyResolverUtils.isAnnotated( EntityWithAnnotatedIdGetter.class.getDeclaredMethod("getId")), is(true)); assertThat( IdPropertyResolverUtils.isAnnotated( EntityWithAnnotatedEmbeddedIdGetter.class.getDeclaredMethod("getId")), is(true)); } @Test(expectedExceptions = PropertyTypeMismatchException.class) public void testPropertyNameFromMethodWhenIdTypeIsInvalid() throws Exception { IdPropertyResolverUtils.getPropertyNameFromAnnotatedMethod( EntityWithAnnotatedIdGetterFromJPA.class, Long.class, EntityWithAnnotatedIdGetterFromJPA.class.getDeclaredMethod("getMyCustomId")); } @Test public void testPropertyNameFromMethod() throws Exception { final String propertyName = IdPropertyResolverUtils.getPropertyNameFromAnnotatedMethod( EntityWithAnnotatedIdGetterFromJPA.class, Integer.class, EntityWithAnnotatedIdGetterFromJPA.class.getDeclaredMethod("getMyCustomId")); assertThat(propertyName, is(notNullValue())); assertThat(propertyName, is("myCustomId")); } @Test public void testPropertyNameFromMethodWithEmbeddedId() throws Exception { final String propertyName = IdPropertyResolverUtils.getPropertyNameFromAnnotatedMethod( EntityWithAnnotatedEmbeddedIdGetterFromJPA.class, Integer.class, EntityWithAnnotatedIdGetterFromJPA.class.getDeclaredMethod("getMyCustomId")); assertThat(propertyName, is(notNullValue())); assertThat(propertyName, is("myCustomId")); } @Test public void testDeclaringAnnotationsThatAreNotPresent() throws Exception { final Field idAnnotations = IdPropertyResolverUtils.class.getDeclaredField("ID_ANNOTATIONS"); idAnnotations.setAccessible(true); final List list = (List) idAnnotations.get(null); //noinspection unchecked list.add("random class name"); final String propertyName = IdPropertyResolverUtils.getPropertyNameFromAnnotatedMethod( EntityWithAnnotatedIdGetterFromJPA.class, Integer.class, EntityWithAnnotatedIdGetterFromJPA.class.getDeclaredMethod("getMyCustomId")); assertThat(propertyName, is(notNullValue())); } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/domain/impl/id/EntityIdPropertyResolverTest.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/domain/impl/id/EntityIdPropertyResolverTest.java
package com.mmnaseri.utils.spring.data.domain.impl.id; import com.mmnaseri.utils.spring.data.error.NoIdPropertyException; import com.mmnaseri.utils.spring.data.error.PrimitiveIdTypeException; import com.mmnaseri.utils.spring.data.sample.models.EntityWithAnnotationOnIdFieldAndGetterAndAnIdField; import com.mmnaseri.utils.spring.data.sample.models.EntityWithIdFieldAndAnAnnotatedIdField; import com.mmnaseri.utils.spring.data.sample.models.EntityWithIdFieldHiddenBehindDifferentlyNamedAccessors; import com.mmnaseri.utils.spring.data.sample.models.EntityWithNoImmediatelyResolvableIdProperty; import com.mmnaseri.utils.spring.data.sample.models.EntityWithPrimitiveIdProperty; import com.mmnaseri.utils.spring.data.sample.models.EntityWithUnderscorePrecedingIdField; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.notNullValue; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (9/29/15) */ public class EntityIdPropertyResolverTest { private EntityIdPropertyResolver resolver; @BeforeMethod public void setUp() { resolver = new EntityIdPropertyResolver(); } @Test public void testThatAnnotatedGetterHasPrecedence() { final String resolved = resolver.resolve(EntityWithAnnotationOnIdFieldAndGetterAndAnIdField.class, Object.class); assertThat(resolved, is(notNullValue())); assertThat(resolved, is("unannotatedId")); } @Test public void testThatAnnotatedPropertyIsSecond() { final String resolved = resolver.resolve(EntityWithIdFieldAndAnAnnotatedIdField.class, Object.class); assertThat(resolved, is(notNullValue())); assertThat(resolved, is("annotatedId")); } @Test public void testThatNamedGetterIsThird() { final String resolved = resolver.resolve(EntityWithUnderscorePrecedingIdField.class, Object.class); assertThat(resolved, is(notNullValue())); assertThat(resolved, is("id")); } @Test public void testThatNamedFieldIsFourth() { final String resolved = resolver.resolve( EntityWithIdFieldHiddenBehindDifferentlyNamedAccessors.class, Object.class); assertThat(resolved, is(notNullValue())); assertThat(resolved, is("id")); } @Test(expectedExceptions = NoIdPropertyException.class) public void testThatNoOtherValueIsHonored() { resolver.resolve(EntityWithNoImmediatelyResolvableIdProperty.class, Object.class); } /** see https://github.com/mmnaseri/spring-data-mock/issues/83 */ @Test(expectedExceptions = PrimitiveIdTypeException.class) public void testPrimitiveIdTypeDoesNotWork() { resolver.resolve(EntityWithPrimitiveIdProperty.class, Long.class); } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/domain/impl/id/BaseRepeatableIdPropertyResolverTest.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/domain/impl/id/BaseRepeatableIdPropertyResolverTest.java
package com.mmnaseri.utils.spring.data.domain.impl.id; import com.mmnaseri.utils.spring.data.domain.IdPropertyResolver; import com.mmnaseri.utils.spring.data.error.MultipleIdPropertiesException; import org.testng.annotations.Test; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (9/29/15) */ public abstract class BaseRepeatableIdPropertyResolverTest extends BaseIdPropertyResolverTest { protected abstract Class<?> entityWithMultipleProperties(); @Test(expectedExceptions = MultipleIdPropertiesException.class) public void testFindingTheIdFieldOnEntityWithMultipleAnnotatedFields() { final IdPropertyResolver resolver = getIdPropertyResolver(); resolver.resolve(entityWithMultipleProperties(), Object.class); } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/domain/impl/id/NamedGetterIdPropertyResolverTest.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/domain/impl/id/NamedGetterIdPropertyResolverTest.java
package com.mmnaseri.utils.spring.data.domain.impl.id; import com.mmnaseri.utils.spring.data.domain.IdPropertyResolver; import com.mmnaseri.utils.spring.data.sample.models.EmptyEntity; import com.mmnaseri.utils.spring.data.sample.models.EntityWithoutAnnotatedIdGetter; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (9/29/15) */ @SuppressWarnings("unused") public class NamedGetterIdPropertyResolverTest extends BaseIdPropertyResolverTest { @Override protected IdPropertyResolver getIdPropertyResolver() { return new NamedGetterIdPropertyResolver(); } @Override protected Class<?> properEntity() { return EntityWithoutAnnotatedIdGetter.class; } @Override protected Class<?> entityWithNoProperty() { return EmptyEntity.class; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/domain/impl/id/BaseIdPropertyResolverTest.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/domain/impl/id/BaseIdPropertyResolverTest.java
package com.mmnaseri.utils.spring.data.domain.impl.id; import com.mmnaseri.utils.spring.data.domain.IdPropertyResolver; import com.mmnaseri.utils.spring.data.error.PropertyTypeMismatchException; import org.testng.annotations.Test; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.notNullValue; import static org.hamcrest.Matchers.nullValue; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (9/29/15) */ public abstract class BaseIdPropertyResolverTest { protected abstract IdPropertyResolver getIdPropertyResolver(); protected abstract Class<?> properEntity(); protected abstract Class<?> entityWithNoProperty(); @Test(expectedExceptions = PropertyTypeMismatchException.class) public void testFindingTheIdFieldWithWrongType() { final IdPropertyResolver resolver = getIdPropertyResolver(); resolver.resolve(properEntity(), Long.class); } @Test public void testFindingTheIdFieldWithSuperType() { final IdPropertyResolver resolver = getIdPropertyResolver(); final String resolved = resolver.resolve(properEntity(), Object.class); assertThat(resolved, is(notNullValue())); assertThat(resolved, is("id")); } @Test public void testFindingTheIdFieldWithCorrectType() { final IdPropertyResolver resolver = getIdPropertyResolver(); final String resolved = resolver.resolve(properEntity(), String.class); assertThat(resolved, is(notNullValue())); assertThat(resolved, is("id")); } @Test public void testFindingTheIdFieldOnEntityWithoutAnnotations() { final IdPropertyResolver resolver = getIdPropertyResolver(); final String resolved = resolver.resolve(entityWithNoProperty(), Object.class); assertThat(resolved, is(nullValue())); } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/domain/impl/id/AnnotatedGetterIdPropertyResolverTest.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/domain/impl/id/AnnotatedGetterIdPropertyResolverTest.java
package com.mmnaseri.utils.spring.data.domain.impl.id; import com.mmnaseri.utils.spring.data.domain.IdPropertyResolver; import com.mmnaseri.utils.spring.data.sample.models.EmbeddableId; import com.mmnaseri.utils.spring.data.sample.models.EntityWithAnnotatedEmbeddedIdGetterFromJPA; import com.mmnaseri.utils.spring.data.sample.models.EntityWithAnnotatedIdGetter; import com.mmnaseri.utils.spring.data.sample.models.EntityWithAnnotatedIdGetterFromJPA; import com.mmnaseri.utils.spring.data.sample.models.EntityWithMultipleAnnotatedIdGetters; import com.mmnaseri.utils.spring.data.sample.models.EntityWithoutAnnotatedIdGetter; import org.testng.annotations.Test; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.notNullValue; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (9/29/15) */ @SuppressWarnings("unused") public class AnnotatedGetterIdPropertyResolverTest extends BaseRepeatableIdPropertyResolverTest { @Override protected IdPropertyResolver getIdPropertyResolver() { return new AnnotatedGetterIdPropertyResolver(); } @Override protected Class<?> properEntity() { return EntityWithAnnotatedIdGetter.class; } @Override protected Class<?> entityWithNoProperty() { return EntityWithoutAnnotatedIdGetter.class; } @Override protected Class<?> entityWithMultipleProperties() { return EntityWithMultipleAnnotatedIdGetters.class; } /** Regression test for https://github.com/mmnaseri/spring-data-mock/issues/55 */ @Test public void testResolvingIdPropertyWhenIdAnnotationOnGetterIsFromJPA() { final String property = getIdPropertyResolver().resolve(EntityWithAnnotatedIdGetterFromJPA.class, Integer.class); assertThat(property, is(notNullValue())); assertThat(property, is("myCustomId")); } @Test public void testResolvingIdPropertyWhenEmbeddedIdAnnotationOnGetterIsFromJPA() { final String property = getIdPropertyResolver() .resolve(EntityWithAnnotatedEmbeddedIdGetterFromJPA.class, EmbeddableId.class); assertThat(property, is(notNullValue())); assertThat(property, is("myCustomId")); } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/domain/impl/id/NamedFieldIdPropertyResolverTest.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/domain/impl/id/NamedFieldIdPropertyResolverTest.java
package com.mmnaseri.utils.spring.data.domain.impl.id; import com.mmnaseri.utils.spring.data.domain.IdPropertyResolver; import com.mmnaseri.utils.spring.data.sample.models.EmptyEntity; import com.mmnaseri.utils.spring.data.sample.models.EntityWithIdField; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (9/29/15) */ public class NamedFieldIdPropertyResolverTest extends BaseIdPropertyResolverTest { @Override protected IdPropertyResolver getIdPropertyResolver() { return new NamedFieldIdPropertyResolver(); } @Override protected Class<?> properEntity() { return EntityWithIdField.class; } @Override protected Class<?> entityWithNoProperty() { return EmptyEntity.class; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/domain/impl/id/AnnotatedFieldIdPropertyResolverTest.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/domain/impl/id/AnnotatedFieldIdPropertyResolverTest.java
package com.mmnaseri.utils.spring.data.domain.impl.id; import com.mmnaseri.utils.spring.data.domain.IdPropertyResolver; import com.mmnaseri.utils.spring.data.sample.models.EmbeddableId; import com.mmnaseri.utils.spring.data.sample.models.EntityWithAnnotatedEmbeddedIdFieldFromJPA; import com.mmnaseri.utils.spring.data.sample.models.EntityWithAnnotatedIdField; import com.mmnaseri.utils.spring.data.sample.models.EntityWithAnnotatedIdFieldFromJPA; import com.mmnaseri.utils.spring.data.sample.models.EntityWithMultipleAnnotatedFields; import com.mmnaseri.utils.spring.data.sample.models.EntityWithoutAnnotatedFields; import org.testng.annotations.Test; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.notNullValue; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (9/29/15) */ @SuppressWarnings("unused") public class AnnotatedFieldIdPropertyResolverTest extends BaseRepeatableIdPropertyResolverTest { @Override protected IdPropertyResolver getIdPropertyResolver() { return new AnnotatedFieldIdPropertyResolver(); } @Override protected Class<?> properEntity() { return EntityWithAnnotatedIdField.class; } @Override protected Class<?> entityWithNoProperty() { return EntityWithoutAnnotatedFields.class; } @Override protected Class<?> entityWithMultipleProperties() { return EntityWithMultipleAnnotatedFields.class; } /** Regression test for https://github.com/mmnaseri/spring-data-mock/issues/55 */ @Test public void testResolvingIdPropertyWhenIdAnnotationOnFieldIsFromJPA() { final String property = getIdPropertyResolver().resolve(EntityWithAnnotatedIdFieldFromJPA.class, Long.class); assertThat(property, is(notNullValue())); assertThat(property, is("customIdProperty")); } @Test public void testResolvingEmbeddedIdPropertyWhenIdAnnotationOnFieldIsFromJPA() { final String property = getIdPropertyResolver() .resolve(EntityWithAnnotatedEmbeddedIdFieldFromJPA.class, EmbeddableId.class); assertThat(property, is(notNullValue())); assertThat(property, is("customIdProperty")); } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/utils/TestUtils.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/utils/TestUtils.java
package com.mmnaseri.utils.spring.data.utils; import java.util.ArrayList; import java.util.List; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 6:51 PM) */ public class TestUtils { public static <E> List<E> iterableToList(Iterable<E> iterable) { final List<E> list = new ArrayList<>(); for (E item : iterable) { list.add(item); } return list; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/repository/PagingAndSortingUtilsTest.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/repository/PagingAndSortingUtilsTest.java
package com.mmnaseri.utils.spring.data.repository; import com.mmnaseri.utils.spring.data.tools.AbstractUtilityClassTest; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (6/9/16, 4:06 AM) */ public class PagingAndSortingUtilsTest extends AbstractUtilityClassTest { @Override protected Class<?> getUtilityClass() { return PagingAndSortingUtils.class; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/repository/DefaultPagingAndSortingRepositoryTest.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/repository/DefaultPagingAndSortingRepositoryTest.java
package com.mmnaseri.utils.spring.data.repository; import com.mmnaseri.utils.spring.data.sample.models.Address; import com.mmnaseri.utils.spring.data.sample.models.Person; import com.mmnaseri.utils.spring.data.sample.models.State; import com.mmnaseri.utils.spring.data.sample.models.Zip; import com.mmnaseri.utils.spring.data.store.DataStore; import com.mmnaseri.utils.spring.data.store.impl.MemoryDataStore; import org.hamcrest.Matchers; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Sort; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import java.util.List; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/11/16, 1:58 PM) */ public class DefaultPagingAndSortingRepositoryTest { private DefaultPagingAndSortingRepository repository; private DataStore<String, Person> dataStore; @BeforeMethod public void setUp() { dataStore = new MemoryDataStore<>(Person.class); repository = new DefaultPagingAndSortingRepository(); repository.setDataStore(dataStore); dataStore.save("1", new Person().setId("1").setAddress(new Address().setZip(new Zip().setArea("A1")) .setCity("Seattle").setState( new State().setName("Washington").setAbbreviation("WA")))); dataStore.save("2", new Person().setId("2").setAddress(new Address().setZip(new Zip().setArea("A2")) .setCity("Edmonds").setState( new State().setName("Washington").setAbbreviation("WA")))); dataStore.save("3", new Person().setId("3").setAddress(new Address().setZip(new Zip().setArea("A3")) .setCity("Seattle").setState( new State().setName("Washington").setAbbreviation("WA")))); dataStore.save("4", new Person().setId("4").setAddress(new Address().setZip(new Zip().setArea("A1")) .setCity("Kirkland").setState( new State().setName("Washington").setAbbreviation("WA")))); dataStore.save("5", new Person().setId("5").setAddress(new Address().setZip(new Zip().setArea("A2")) .setCity("Portland").setState( new State().setName("Oregon").setAbbreviation("OR")))); dataStore.save("6", new Person().setId("6").setAddress(new Address().setZip(new Zip().setArea("A3")) .setCity("Portland").setState( new State().setName("Oregon").setAbbreviation("OR")))); dataStore.save("7", new Person().setId("7").setAddress(new Address().setZip(new Zip().setArea("A1")) .setCity("Spokane").setState( new State().setName("Washington").setAbbreviation("WA")))); dataStore.save("8", new Person().setId("8").setAddress(new Address().setZip(new Zip().setArea("A2")) .setCity("Seattle").setState( new State().setName("Washington").setAbbreviation("WA")))); } @Test public void testFindAllWithNullSort() { final List<?> found = repository.findAll(((Sort) null)); assertThat(found, is(notNullValue())); assertThat(found, hasSize(dataStore.retrieveAll().size())); } @Test public void testFindAllWithSort() { final List<?> found = repository.findAll(Sort.by(new Sort.Order(Sort.Direction.ASC, "address.city"), new Sort.Order(Sort.Direction.DESC, "address.zip.area"))); assertThat(found, hasSize(dataStore.retrieveAll().size())); assertThat(found.get(0), Matchers.is(dataStore.retrieve("2"))); assertThat(found.get(1), Matchers.is(dataStore.retrieve("4"))); assertThat(found.get(2), Matchers.is(dataStore.retrieve("6"))); assertThat(found.get(3), Matchers.is(dataStore.retrieve("5"))); assertThat(found.get(4), Matchers.is(dataStore.retrieve("3"))); assertThat(found.get(5), Matchers.is(dataStore.retrieve("8"))); assertThat(found.get(6), Matchers.is(dataStore.retrieve("1"))); assertThat(found.get(7), Matchers.is(dataStore.retrieve("7"))); } @Test public void testFindAllWithPagingAndNoSorting() { final Page page = repository.findAll(PageRequest.of(2, 3)); assertThat(page.getTotalElements(), is(8L)); assertThat(page.getTotalPages(), is(3)); assertThat(page.getNumber(), is(2)); assertThat(page.getSize(), is(3)); assertThat(page.getNumberOfElements(), is(2)); } @Test public void testFindAllWithPagingAndSorting() { final Page page = repository.findAll(PageRequest.of(2, 3, Sort.by(new Sort.Order(Sort.Direction.ASC, "address.city"), new Sort.Order(Sort.Direction.DESC, "address.zip.area")))); assertThat(page.getTotalElements(), is(8L)); assertThat(page.getTotalPages(), is(3)); assertThat(page.getNumber(), is(2)); assertThat(page.getSize(), is(3)); assertThat(page.getNumberOfElements(), is(2)); final List<?> found = page.getContent(); assertThat(found.get(0), Matchers.is(dataStore.retrieve("1"))); assertThat(found.get(1), Matchers.is(dataStore.retrieve("7"))); } @Test public void testWithNullsFirst() { dataStore.save("9", new Person().setId("9").setAddress(new Address().setZip(new Zip().setArea(null)) .setCity("Spokane").setState( new State().setName("Washington").setAbbreviation("WA")))); final List<?> found = repository.findAll(Sort.by(new Sort.Order(Sort.Direction.ASC, "address.city"), new Sort.Order(Sort.Direction.DESC, "address.zip.area", Sort.NullHandling.NULLS_FIRST))); assertThat(found, hasSize(dataStore.retrieveAll().size())); assertThat(found.get(0), Matchers.is(dataStore.retrieve("2"))); assertThat(found.get(1), Matchers.is(dataStore.retrieve("4"))); assertThat(found.get(2), Matchers.is(dataStore.retrieve("6"))); assertThat(found.get(3), Matchers.is(dataStore.retrieve("5"))); assertThat(found.get(4), Matchers.is(dataStore.retrieve("3"))); assertThat(found.get(5), Matchers.is(dataStore.retrieve("8"))); assertThat(found.get(6), Matchers.is(dataStore.retrieve("1"))); assertThat(found.get(7), Matchers.is(dataStore.retrieve("7"))); assertThat(found.get(8), Matchers.is(dataStore.retrieve("9"))); } @Test public void testWithNullsLast() { dataStore.save("9", new Person().setId("9").setAddress(new Address().setZip(new Zip().setArea(null)) .setCity("Spokane").setState( new State().setName("Washington").setAbbreviation("WA")))); final List<?> found = repository.findAll(Sort.by(new Sort.Order(Sort.Direction.ASC, "address.city"), new Sort.Order(Sort.Direction.DESC, "address.zip.area", Sort.NullHandling.NULLS_LAST))); assertThat(found, hasSize(dataStore.retrieveAll().size())); assertThat(found.get(0), Matchers.is(dataStore.retrieve("2"))); assertThat(found.get(1), Matchers.is(dataStore.retrieve("4"))); assertThat(found.get(2), Matchers.is(dataStore.retrieve("6"))); assertThat(found.get(3), Matchers.is(dataStore.retrieve("5"))); assertThat(found.get(4), Matchers.is(dataStore.retrieve("3"))); assertThat(found.get(5), Matchers.is(dataStore.retrieve("8"))); assertThat(found.get(6), Matchers.is(dataStore.retrieve("1"))); assertThat(found.get(7), Matchers.is(dataStore.retrieve("9"))); assertThat(found.get(8), Matchers.is(dataStore.retrieve("7"))); } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/repository/DefaultQueryByExampleExecutorTest.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/repository/DefaultQueryByExampleExecutorTest.java
package com.mmnaseri.utils.spring.data.repository; import com.mmnaseri.utils.spring.data.domain.RepositoryMetadata; import com.mmnaseri.utils.spring.data.domain.impl.DefaultOperatorContext; import com.mmnaseri.utils.spring.data.domain.impl.DefaultRepositoryMetadataResolver; import com.mmnaseri.utils.spring.data.domain.impl.MethodQueryDescriptionExtractor; import com.mmnaseri.utils.spring.data.error.InvalidArgumentException; import com.mmnaseri.utils.spring.data.proxy.impl.DefaultRepositoryFactoryConfiguration; import com.mmnaseri.utils.spring.data.proxy.impl.ImmutableRepositoryConfiguration; import com.mmnaseri.utils.spring.data.sample.models.Address; import com.mmnaseri.utils.spring.data.sample.models.Person; import com.mmnaseri.utils.spring.data.sample.models.State; import com.mmnaseri.utils.spring.data.sample.models.Zip; import com.mmnaseri.utils.spring.data.sample.repositories.SimplePersonRepository; import com.mmnaseri.utils.spring.data.store.DataStore; import com.mmnaseri.utils.spring.data.store.impl.MemoryDataStore; import com.mmnaseri.utils.spring.data.utils.TestUtils; import org.springframework.data.domain.Example; import org.springframework.data.domain.ExampleMatcher; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Sort; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import java.util.List; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (6/8/16, 12:12 PM) */ public class DefaultQueryByExampleExecutorTest { private DefaultQueryByExampleExecutor executor; private DataStore<Object, Person> dataStore; @BeforeMethod public void setUp() { dataStore = new MemoryDataStore<>(Person.class); dataStore.save("1", new Person() .setId("1") .setFirstName("Milad") .setLastName("Naseri") .setAge(28) .setAddressZip(new Zip()) .setAddress( new Address() .setCity("Tehran") .setState( new State() .setName("Teheran") ) ) ); dataStore.save("2", new Person() .setId("2") .setFirstName("Zohreh") .setLastName("Sadeghi") .setAge(26) .setAddressZip(new Zip()) .setAddress( new Address() .setCity("Edmonds") .setState( new State() .setName("WA") ) ) ); dataStore.save("3", new Person() .setId("3") .setFirstName("Ramin") .setLastName("Farhanian") .setAge(40) .setAddressZip(null) .setAddress( new Address() .setCity("Kirkland") .setState( new State() .setName("WA") ) ) ); dataStore.save("4", new Person() .setId("4") .setFirstName("Niloufar") .setLastName("Poursultani") .setAge(53) .setAddressZip(new Zip()) .setAddress( new Address() .setCity("Tehran") .setState( new State() .setName("Teheran") ) ) ); executor = new DefaultQueryByExampleExecutor(); executor.setDataStore(dataStore); final RepositoryMetadata metadata = new DefaultRepositoryMetadataResolver().resolve( SimplePersonRepository.class); executor.setRepositoryMetadata(metadata); executor.setRepositoryConfiguration(new ImmutableRepositoryConfiguration(metadata, null, null)); final DefaultRepositoryFactoryConfiguration configuration = new DefaultRepositoryFactoryConfiguration(); configuration.setDescriptionExtractor(new MethodQueryDescriptionExtractor(new DefaultOperatorContext())); executor.setRepositoryFactoryConfiguration(configuration); } @Test public void testFindOneWhenThereIsNoMatch() { final Object result = executor.findOne(Example.of(new Person().setFirstName("Gigili").setLastName("Magooli"))); assertThat(result, is(nullValue())); } @Test(expectedExceptions = InvalidArgumentException.class) public void testFindOneWhenThereIsMoreThanOneMatch() { executor.findOne(Example.of(new Person().setAddress(new Address().setCity("Tehran")))); } @Test public void testFindOne() { final Object found = executor.findOne( Example.of(new Person().setAddress(new Address().setCity("Tehran")).setFirstName("Milad"))); assertThat(found, is(notNullValue())); assertThat(found, is(dataStore.retrieve("1"))); } @Test public void testFindByExampleUsingEndingWithMatcher() { final Person probe = new Person().setAddress(new Address().setState(new State().setName("ran"))); final ExampleMatcher matching = ExampleMatcher.matching().withMatcher("address.state.name", ExampleMatcher.GenericPropertyMatchers .endsWith()).withIgnoreCase(); final Example<Person> example = Example.of(probe, matching); final Iterable found = executor.findAll(example); assertThat(found, is(notNullValue())); final List<?> list = TestUtils.iterableToList(found); assertThat(list, hasSize(2)); } @Test public void testFindByExampleUsingStartingWithMatcher() { final Person probe = new Person().setAddress(new Address().setState(new State().setName("Teh"))); final ExampleMatcher matching = ExampleMatcher.matching().withMatcher("address.state.name", ExampleMatcher.GenericPropertyMatchers .startsWith()).withIgnoreCase(); final Example<Person> example = Example.of(probe, matching); final Iterable found = executor.findAll(example); assertThat(found, is(notNullValue())); final List<?> list = TestUtils.iterableToList(found); assertThat(list, hasSize(2)); } @Test public void testFindByExampleUsingContainingMatcher() { final Person probe = new Person().setAddress(new Address().setState(new State().setName("ehe"))); final ExampleMatcher matching = ExampleMatcher.matching().withMatcher("address.state.name", ExampleMatcher.GenericPropertyMatchers .contains()).withIgnoreCase(); final Example<Person> example = Example.of(probe, matching); final Iterable found = executor.findAll(example); assertThat(found, is(notNullValue())); final List<?> list = TestUtils.iterableToList(found); assertThat(list, hasSize(2)); } @Test public void testFindByExampleUsingRegexMatcher() { final Person probe = new Person().setAddress(new Address().setState(new State().setName("(WA|Teheran)"))); final ExampleMatcher matching = ExampleMatcher.matching().withMatcher("address.state.name", ExampleMatcher.GenericPropertyMatchers .regex()).withIgnoreCase(); final Example<Person> example = Example.of(probe, matching); final Iterable found = executor.findAll(example); assertThat(found, is(notNullValue())); final List<?> list = TestUtils.iterableToList(found); assertThat(list, hasSize(4)); } @Test public void testFindByExampleWithSorting() { final Person probe = new Person().setAddress(new Address().setState(new State().setName("(WA|Teheran)"))); final ExampleMatcher matching = ExampleMatcher.matching().withMatcher("address.state.name", ExampleMatcher.GenericPropertyMatchers .regex()).withIgnoreCase(); final Example<Person> example = Example.of(probe, matching); final Iterable found = executor.findAll(example, Sort.by(Sort.Direction.ASC, "firstName", "lastName", "address.state.name")); assertThat(found, is(notNullValue())); final List<?> list = TestUtils.iterableToList(found); assertThat(list, hasSize(4)); assertThat(list.get(0), is(dataStore.retrieve("1"))); assertThat(list.get(1), is(dataStore.retrieve("4"))); assertThat(list.get(2), is(dataStore.retrieve("3"))); assertThat(list.get(3), is(dataStore.retrieve("2"))); } @Test public void testFindByExampleWithSortingAndPaging() { final Person probe = new Person().setAddress(new Address().setState(new State().setName("Teheran"))); final ExampleMatcher matching = ExampleMatcher.matching().withMatcher("address.state.name", ExampleMatcher.GenericPropertyMatchers .regex()).withIgnoreCase() .withIgnorePaths("address.state.name"); final Example<Person> example = Example.of(probe, matching); final Iterable found = executor.findAll(example, PageRequest .of(2, 1, Sort.by(Sort.Direction.ASC, "firstName", "lastName", "address.state.name"))); assertThat(found, is(notNullValue())); final List<?> list = TestUtils.iterableToList(found); assertThat(list, hasSize(1)); assertThat(list.get(0), is(dataStore.retrieve("3"))); } @Test public void testCount() { final Person probe = new Person().setAddress(new Address().setState(new State().setName("ehe"))); final ExampleMatcher matching = ExampleMatcher.matching().withMatcher("address.state.name", ExampleMatcher.GenericPropertyMatchers .contains()).withIgnoreCase(); final Example<Person> example = Example.of(probe, matching); final long count = executor.count(example); assertThat(count, is(2L)); } @Test public void testExists() { final Person probe = new Person().setAddress(new Address().setState(new State().setName("ehe"))); final ExampleMatcher matching = ExampleMatcher.matching() .withMatcher("address.state.name", ExampleMatcher.GenericPropertyMatchers.contains()); final Example<Person> example = Example.of(probe, matching); final boolean exists = executor.exists(example); assertThat(exists, is(true)); } @Test public void testWithNullsKept() { final Person probe = new Person().setAddress(new Address().setState(new State().setName("ehe"))); final ExampleMatcher matching = ExampleMatcher.matching() .withMatcher("address.state.name", ExampleMatcher.GenericPropertyMatchers.contains()) .withIncludeNullValues(); final Example<Person> example = Example.of(probe, matching); final boolean exists = executor.exists(example); assertThat(exists, is(false)); } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/repository/DefaultCrudRepositoryTest.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/repository/DefaultCrudRepositoryTest.java
package com.mmnaseri.utils.spring.data.repository; import com.mmnaseri.utils.spring.data.domain.impl.ImmutableRepositoryMetadata; import com.mmnaseri.utils.spring.data.domain.impl.key.UUIDKeyGenerator; import com.mmnaseri.utils.spring.data.error.EntityMissingKeyException; import com.mmnaseri.utils.spring.data.sample.models.Person; import com.mmnaseri.utils.spring.data.sample.repositories.SimplePersonRepository; import com.mmnaseri.utils.spring.data.store.DataStore; import com.mmnaseri.utils.spring.data.store.impl.MemoryDataStore; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Optional; import java.util.stream.StreamSupport; import static com.mmnaseri.utils.spring.data.utils.TestUtils.iterableToList; import static java.util.stream.Collectors.toList; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.empty; import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.instanceOf; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.isIn; import static org.hamcrest.Matchers.notNullValue; import static org.hamcrest.Matchers.nullValue; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/11/16, 10:15 AM) */ public class DefaultCrudRepositoryTest { private DefaultCrudRepository repository; private DataStore<String, Person> dataStore; @BeforeMethod public void setUp() { dataStore = new MemoryDataStore<>(Person.class); repository = new DefaultCrudRepository(); repository.setRepositoryMetadata( new ImmutableRepositoryMetadata(String.class, Person.class, SimplePersonRepository.class, "id")); repository.setDataStore(dataStore); repository.setKeyGenerator(new UUIDKeyGenerator()); } @Test public void testSave() { final List<Person> entities = Arrays.asList(new Person(), new Person(), new Person()); final Iterable<Object> inserted = repository.saveAll(entities); assertThat(inserted, is(notNullValue())); final List<Object> insertedList = StreamSupport.stream(inserted.spliterator(), /* parallel= */ false).collect(toList()); assertThat(insertedList, hasSize(3)); for (Object item : insertedList) { assertThat(item, is(instanceOf(Person.class))); assertThat((Person) item, isIn(entities)); assertThat(((Person) item).getId(), is(notNullValue())); } assertThat(dataStore.retrieveAll(), hasSize(entities.size())); final Iterable<Object> updated = repository.saveAll(entities); assertThat(updated, is(notNullValue())); final List<Object> updatedList = StreamSupport.stream(updated.spliterator(), /* parallel= */ false).collect(toList()); assertThat(updatedList, hasSize(3)); for (Object item : updatedList) { assertThat(item, is(instanceOf(Person.class))); assertThat((Person) item, isIn(entities)); } assertThat(dataStore.retrieveAll(), hasSize(entities.size())); } @Test public void testFindOne() { final String key = "1234"; assertThat(repository.findById(key), is(Optional.empty())); final Person person = new Person(); dataStore.save("1234", person); assertThat(repository.findById(key).isPresent(), is(true)); assertThat(repository.findById(key).get(), is(person)); } @Test public void testExists() { final String key = "1234"; assertThat(repository.existsById(key), is(false)); dataStore.save("1234", new Person()); assertThat(repository.existsById(key), is(true)); } @Test public void testFindAllById() { dataStore.save("1", new Person()); dataStore.save("2", new Person()); dataStore.save("3", new Person()); dataStore.save("4", new Person()); final List<String> existingIds = Arrays.asList("2", "3"); final List<String> missingIds = Arrays.asList("5", "6"); final List<String> request = new ArrayList<>(); request.addAll(existingIds); request.addAll(missingIds); final List<Person> expected = new ArrayList<>(); for (String id : existingIds) { expected.add(dataStore.retrieve(id)); } final List<?> list = StreamSupport.stream(((Iterable<Object>) repository.findAllById(request)).spliterator(), /* parallel= */ false).collect(toList()); assertThat(list, hasSize(existingIds.size())); for (Object found : list) { assertThat(found, is(instanceOf(Person.class))); assertThat((Person) found, isIn(expected)); } } @Test public void testDeleteByKey() { final Object deleted = repository.deleteById("1"); assertThat(deleted, is(nullValue())); } @Test public void testDeleteByEntityWhenEntityHasKey() { final Person original = new Person(); dataStore.save("1", original); assertThat(dataStore.hasKey("1"), is(true)); final Object deleted = repository.deleteById(new Person().setId("1")); assertThat(dataStore.hasKey("1"), is(false)); assertThat(deleted, is(notNullValue())); assertThat(deleted, is(original)); } @Test(expectedExceptions = EntityMissingKeyException.class) public void testDeleteByEntityWhenEntityHasNoKey() { repository.delete(new Person()); } @Test public void testDeleteMany() { dataStore.save("1", new Person()); dataStore.save("2", new Person()); dataStore.save("3", new Person()); dataStore.save("4", new Person()); final List<String> existingIds = Arrays.asList("2", "3"); final List<String> missingIds = Arrays.asList("5", "6"); final List<Person> request = new ArrayList<>(); for (String id : existingIds) { request.add(new Person().setId(id)); } for (String id : missingIds) { request.add(new Person().setId(id)); } final List<Person> expected = new ArrayList<>(); for (String id : existingIds) { expected.add(dataStore.retrieve(id)); } for (String existingId : existingIds) { assertThat(dataStore.hasKey(existingId), is(true)); } final List<?> deleted = iterableToList(repository.delete(request)); assertThat(deleted, hasSize(existingIds.size())); for (Object item : deleted) { assertThat(item, is(instanceOf(Person.class))); assertThat((Person) item, isIn(expected)); } } @Test public void testDeleteAll() { dataStore.save("1", new Person()); dataStore.save("2", new Person()); dataStore.save("3", new Person()); dataStore.save("4", new Person()); assertThat(dataStore.keys(), hasSize(4)); repository.deleteAll(); assertThat(dataStore.keys(), is(empty())); } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/repository/DefaultGemfireRepositoryTest.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/repository/DefaultGemfireRepositoryTest.java
package com.mmnaseri.utils.spring.data.repository; import com.mmnaseri.utils.spring.data.domain.impl.ImmutableRepositoryMetadata; import com.mmnaseri.utils.spring.data.sample.models.Person; import com.mmnaseri.utils.spring.data.sample.repositories.SimplePersonRepository; import com.mmnaseri.utils.spring.data.store.impl.MemoryDataStore; import org.springframework.data.gemfire.repository.Wrapper; import org.testng.annotations.Test; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/11/16, 1:13 PM) */ public class DefaultGemfireRepositoryTest { @Test public void testSave() { final MemoryDataStore<Object, Person> dataStore = new MemoryDataStore<>(Person.class); final ImmutableRepositoryMetadata repositoryMetadata = new ImmutableRepositoryMetadata(String.class, Person.class, SimplePersonRepository.class, "id"); final DefaultGemfireRepository repository = new DefaultGemfireRepository(); repository.setDataStore(dataStore); repository.setRepositoryMetadata(repositoryMetadata); final String id = "12345"; final Wrapper<?, ?> wrapper = new Wrapper<>(new Person(), id); //noinspection unchecked final Object saved = repository.save((Wrapper<Object, Object>) wrapper); assertThat(saved, is(notNullValue())); assertThat(saved, is(instanceOf(Person.class))); assertThat(((Person) saved).getId(), is(notNullValue())); assertThat(((Person) saved).getId(), is(id)); } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/repository/DefaultJpaRepositoryTest.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/repository/DefaultJpaRepositoryTest.java
package com.mmnaseri.utils.spring.data.repository; import com.mmnaseri.utils.spring.data.domain.RepositoryMetadata; import com.mmnaseri.utils.spring.data.domain.impl.ImmutableRepositoryMetadata; import com.mmnaseri.utils.spring.data.domain.impl.key.UUIDKeyGenerator; import com.mmnaseri.utils.spring.data.error.EntityMissingKeyException; import com.mmnaseri.utils.spring.data.sample.mocks.Operation; import com.mmnaseri.utils.spring.data.sample.mocks.SpyingDataStore; import com.mmnaseri.utils.spring.data.sample.models.Person; import com.mmnaseri.utils.spring.data.sample.repositories.SimplePersonRepository; import com.mmnaseri.utils.spring.data.store.DataStore; import com.mmnaseri.utils.spring.data.store.impl.MemoryDataStore; import org.hamcrest.Matchers; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.concurrent.atomic.AtomicLong; import static com.mmnaseri.utils.spring.data.utils.TestUtils.iterableToList; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/11/16, 1:16 PM) */ public class DefaultJpaRepositoryTest { private RepositoryMetadata repositoryMetadata; private DefaultJpaRepository repository; private DataStore<String, Person> dataStore; @BeforeMethod public void setUp() { repositoryMetadata = new ImmutableRepositoryMetadata(String.class, Person.class, SimplePersonRepository.class, "id"); dataStore = new MemoryDataStore<>(Person.class); repository = new DefaultJpaRepository(); repository.setDataStore(dataStore); repository.setRepositoryMetadata(repositoryMetadata); repository.setKeyGenerator(new UUIDKeyGenerator()); } @Test public void testFlushing() { final DefaultJpaRepository repository = new DefaultJpaRepository(); repository.setKeyGenerator(new UUIDKeyGenerator()); repository.setRepositoryMetadata(repositoryMetadata); final SpyingDataStore<Object, Object> dataStore = new SpyingDataStore<>(null, new AtomicLong()); repository.setDataStore(dataStore); repository.flush(); assertThat(dataStore.getRequests(), hasSize(1)); assertThat(dataStore.getRequests().get(0).getOperation(), is(Operation.FLUSH)); } @Test public void testDeleteInBatch() { dataStore.save("1", new Person()); dataStore.save("2", new Person()); dataStore.save("3", new Person()); dataStore.save("4", new Person()); final List<String> existingIds = Arrays.asList("2", "3"); final List<String> missingIds = Arrays.asList("5", "6"); final List<Person> request = new ArrayList<>(); for (String id : existingIds) { request.add(new Person().setId(id)); } for (String id : missingIds) { request.add(new Person().setId(id)); } final List<Person> expected = new ArrayList<>(); for (String id : existingIds) { expected.add(dataStore.retrieve(id)); } for (String existingId : existingIds) { assertThat(dataStore.hasKey(existingId), is(true)); } final List<?> deleted = iterableToList(repository.deleteInBatch(request)); assertThat(deleted, hasSize(existingIds.size())); for (Object item : deleted) { assertThat(item, is(instanceOf(Person.class))); assertThat((Person) item, isIn(expected)); } } @Test(expectedExceptions = EntityMissingKeyException.class) public void testDeleteInBatchWhenIdIsNull() { repository.deleteInBatch(Collections.singleton(new Person())); } @Test public void testDeleteAllInBatch() { dataStore.save("1", new Person()); dataStore.save("2", new Person()); dataStore.save("3", new Person()); dataStore.save("4", new Person()); assertThat(dataStore.keys(), hasSize(4)); repository.deleteAllInBatch(); assertThat(dataStore.keys(), is(empty())); } @Test public void testDeleteInBatchWithQueueing() { final SpyingDataStore<String, Person> dataStore = new SpyingDataStore<>( new MemoryDataStore<>(Person.class), new AtomicLong()); dataStore.save("1", new Person()); dataStore.save("2", new Person()); dataStore.save("3", new Person()); dataStore.save("4", new Person()); repository.setDataStore(dataStore); assertThat(dataStore.keys(), hasSize(4)); repository.deleteAllInBatch(); assertThat(dataStore.keys(), is(empty())); } @Test public void testGetOne() { final String key = "1234"; assertThat(repository.getOne(key), is(nullValue())); final Person person = new Person(); dataStore.save("1234", person); assertThat(repository.getOne(key), Matchers.is(person)); } @Test public void testSaveAndFlush() { final DefaultJpaRepository repository = new DefaultJpaRepository(); repository.setKeyGenerator(new UUIDKeyGenerator()); repository.setRepositoryMetadata(repositoryMetadata); final SpyingDataStore<String, Person> dataStore = new SpyingDataStore<>(this.dataStore, new AtomicLong()); repository.setDataStore(dataStore); final Person entity = new Person().setId("1"); repository.saveAndFlush(entity); assertThat(dataStore.getRequests().get(dataStore.getRequests().size() - 1).getOperation(), is(Operation.FLUSH)); assertThat(dataStore.retrieve("1"), is(entity)); } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/repository/DefaultCrudRepositoryWithSerializedTest.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/repository/DefaultCrudRepositoryWithSerializedTest.java
package com.mmnaseri.utils.spring.data.repository; import com.mmnaseri.utils.spring.data.domain.impl.ImmutableRepositoryMetadata; import com.mmnaseri.utils.spring.data.domain.impl.key.UUIDKeyGenerator; import com.mmnaseri.utils.spring.data.sample.models.PersonSerializable; import com.mmnaseri.utils.spring.data.sample.repositories.SimplePersonSerializableRepository; import com.mmnaseri.utils.spring.data.store.DataStore; import com.mmnaseri.utils.spring.data.store.impl.MemoryDataStore; import org.hamcrest.Matchers; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.notNullValue; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/11/16, 10:15 AM) */ public class DefaultCrudRepositoryWithSerializedTest { private DefaultCrudRepository repository; private DataStore<String, PersonSerializable> dataStore; @BeforeMethod public void setUp() { dataStore = new MemoryDataStore<>(PersonSerializable.class); repository = new DefaultCrudRepository(); repository.setRepositoryMetadata(new ImmutableRepositoryMetadata(String.class, PersonSerializable.class, SimplePersonSerializableRepository.class, "id")); repository.setDataStore(dataStore); repository.setKeyGenerator(new UUIDKeyGenerator()); } @Test public void testDeleteByEntityWhenEntityHasKey() { final PersonSerializable original = new PersonSerializable(); dataStore.save("1", original); assertThat(dataStore.hasKey("1"), is(true)); final PersonSerializable personToDelete = new PersonSerializable(); personToDelete.setId("1"); final Object deleted = repository.delete(personToDelete); assertThat(dataStore.hasKey("1"), is(false)); assertThat(deleted, is(notNullValue())); assertThat(deleted, Matchers.is(original)); } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/repository/DefaultQueryDslPredicateExecutorTest.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/repository/DefaultQueryDslPredicateExecutorTest.java
package com.mmnaseri.utils.spring.data.repository; import com.mmnaseri.utils.spring.data.sample.models.Person; import com.mmnaseri.utils.spring.data.store.impl.MemoryDataStore; import com.mmnaseri.utils.spring.data.utils.TestUtils; import com.querydsl.core.NonUniqueResultException; import com.querydsl.core.types.dsl.BooleanExpression; import org.hamcrest.Matchers; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Sort; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Ignore; import org.testng.annotations.Test; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import static com.querydsl.core.alias.Alias.$; import static com.querydsl.core.alias.Alias.alias; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/28/16) */ public class DefaultQueryDslPredicateExecutorTest { private MemoryDataStore<Object, Person> dataStore; private DefaultQueryDslPredicateExecutor executor; @BeforeMethod public void setUp() { dataStore = new MemoryDataStore<>(Person.class); executor = new DefaultQueryDslPredicateExecutor(); executor.setDataStore(dataStore); } @Test public void testFindOne() { final Person saved = new Person().setId("1").setAge(10); dataStore.save("1", saved); dataStore.save("2", new Person().setId("2")); final Person person = alias(Person.class); final BooleanExpression predicate = $(person.getId()).eq("1"); final Object one = executor.findOne(predicate); assertThat(one, is(notNullValue())); assertThat(one, Matchers.is(saved)); } @Test public void testFindOneWhenNoneExists() { final Person person = alias(Person.class); final BooleanExpression predicate = $(person.getId()).eq("1"); final Object one = executor.findOne(predicate); assertThat(one, is(nullValue())); } @Test(expectedExceptions = NonUniqueResultException.class) public void testFindOneWhenMoreThanOneMatches() { dataStore.save("1", new Person().setId("1").setFirstName("Milad").setLastName("Naseri")); dataStore.save("2", new Person().setId("2").setFirstName("Hassan").setLastName("Naseri")); final Person person = alias(Person.class); final BooleanExpression predicate = $(person.getLastName()).eq("Naseri"); final Object one = executor.findOne(predicate); assertThat(one, is(nullValue())); } @Test public void testFindAllUsingAPredicate() { dataStore.save("1", new Person().setId("1").setAge(10)); dataStore.save("2", new Person().setId("2").setAge(15)); dataStore.save("3", new Person().setId("3").setAge(20)); dataStore.save("4", new Person().setId("4").setAge(25)); dataStore.save("5", new Person().setId("5").setAge(30)); final Person person = alias(Person.class); final Iterable result = executor.findAll($(person.getAge()).gt(20).or($(person.getAge()).eq(20))); assertThat(result, is(notNullValue())); final List<?> list = TestUtils.iterableToList(result); assertThat(list, hasSize(3)); final List<String> ids = new ArrayList<>(Arrays.asList("3", "4", "5")); for (Object obj : list) { assertThat(obj, is(instanceOf(Person.class))); final Person loaded = (Person) obj; assertThat(loaded.getId(), isIn(ids)); ids.remove(loaded.getId()); } assertThat(ids, is(Matchers.empty())); } @Test public void testFindAllWithSort() { dataStore.save("1", new Person().setId("1").setAge(30)); dataStore.save("2", new Person().setId("2").setAge(25)); dataStore.save("3", new Person().setId("3").setAge(20)); dataStore.save("4", new Person().setId("4").setAge(15)); dataStore.save("5", new Person().setId("5").setAge(10)); final Person person = alias(Person.class); final Iterable result = executor.findAll($(person.getAge()).gt(20).or($(person.getAge()).eq(20)), Sort.by(Sort.Direction.ASC, "age")); assertThat(result, is(notNullValue())); final List<?> list = TestUtils.iterableToList(result); assertThat(list, hasSize(3)); assertThat(list.get(0), Matchers.is(dataStore.retrieve("3"))); assertThat(list.get(1), Matchers.is(dataStore.retrieve("2"))); assertThat(list.get(2), Matchers.is(dataStore.retrieve("1"))); } @Test public void testFindAllWithPagingAndSorting() { dataStore.save("1", new Person().setId("1").setAge(30)); dataStore.save("2", new Person().setId("2").setAge(25)); dataStore.save("3", new Person().setId("3").setAge(20)); dataStore.save("4", new Person().setId("4").setAge(15)); dataStore.save("5", new Person().setId("5").setAge(10)); final Person person = alias(Person.class); final Iterable result = executor.findAll($(person.getAge()).gt(20).or($(person.getAge()).eq(20)), PageRequest.of(0, 2, Sort.by(Sort.Direction.ASC, "age"))); assertThat(result, is(notNullValue())); final List<?> list = TestUtils.iterableToList(result); assertThat(list, hasSize(2)); assertThat(list.get(0), Matchers.is(dataStore.retrieve("3"))); assertThat(list.get(1), Matchers.is(dataStore.retrieve("2"))); } @Test public void testFindAllWithPaging() { dataStore.save("1", new Person().setId("1").setAge(30)); dataStore.save("2", new Person().setId("2").setAge(25)); dataStore.save("3", new Person().setId("3").setAge(20)); dataStore.save("4", new Person().setId("4").setAge(15)); dataStore.save("5", new Person().setId("5").setAge(10)); final Person person = alias(Person.class); final Iterable result = executor.findAll($(person.getAge()).gt(20).or($(person.getAge()).eq(20)), PageRequest.of(0, 2)); assertThat(result, is(notNullValue())); final List<?> list = TestUtils.iterableToList(result); assertThat(list, hasSize(2)); for (Object obj : list) { assertThat(obj, is(instanceOf(Person.class))); final Person loaded = (Person) obj; assertThat(loaded, is(dataStore.retrieve(loaded.getId()))); } } @Test public void testCount() { dataStore.save("1", new Person().setId("1").setAge(30)); dataStore.save("2", new Person().setId("2").setAge(25)); dataStore.save("3", new Person().setId("3").setAge(20)); dataStore.save("4", new Person().setId("4").setAge(15)); dataStore.save("5", new Person().setId("5").setAge(10)); final Person person = alias(Person.class); final long count = executor.count($(person.getAge()).gt(20).or($(person.getAge()).eq(20))); assertThat(count, is((long) 3)); } @Test public void testExists() { dataStore.save("1", new Person().setId("1").setAge(30)); dataStore.save("2", new Person().setId("2").setAge(25)); dataStore.save("3", new Person().setId("3").setAge(20)); dataStore.save("4", new Person().setId("4").setAge(15)); dataStore.save("5", new Person().setId("5").setAge(10)); final Person person = alias(Person.class); assertThat(executor.exists($(person.getAge()).gt(20).or($(person.getAge()).eq(20))), is(true)); assertThat(executor.exists($(person.getAge()).lt(20).or($(person.getAge()).eq(20))), is(true)); assertThat(executor.exists($(person.getAge()).lt(10).or($(person.getAge()).eq(10))), is(true)); assertThat(executor.exists($(person.getAge()).lt(5).or($(person.getAge()).eq(5))), is(false)); } @Test public void testFindAllWithExplicitOrdering() { dataStore.save("1", new Person().setId("1").setAge(30)); dataStore.save("2", new Person().setId("2").setAge(25)); dataStore.save("3", new Person().setId("3").setAge(20)); dataStore.save("4", new Person().setId("4").setAge(15)); dataStore.save("5", new Person().setId("5").setAge(10)); final Person person = alias(Person.class); final Iterable all = executor.findAll($(person.getAge()).asc()); assertThat(all, is(notNullValue())); final List<?> list = TestUtils.iterableToList(all); assertThat(list, hasSize(5)); assertThat(list.get(0), Matchers.is(dataStore.retrieve("5"))); assertThat(list.get(1), Matchers.is(dataStore.retrieve("4"))); assertThat(list.get(2), Matchers.is(dataStore.retrieve("3"))); assertThat(list.get(3), Matchers.is(dataStore.retrieve("2"))); assertThat(list.get(4), Matchers.is(dataStore.retrieve("1"))); } @Test public void testFindAllWithPredicateAndExplicitOrdering() { dataStore.save("1", new Person().setId("1").setAge(30)); dataStore.save("2", new Person().setId("2").setAge(25)); dataStore.save("3", new Person().setId("3").setAge(20)); dataStore.save("4", new Person().setId("4").setAge(15)); dataStore.save("5", new Person().setId("5").setAge(10)); final Person person = alias(Person.class); final Iterable all = executor.findAll($(person.getAge()).gt(20), $(person.getAge()).asc()); assertThat(all, is(notNullValue())); final List<?> list = TestUtils.iterableToList(all); assertThat(list, hasSize(2)); assertThat(list.get(0), Matchers.is(dataStore.retrieve("2"))); assertThat(list.get(1), Matchers.is(dataStore.retrieve("1"))); } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/repository/CrudRepositorySupportTest.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/repository/CrudRepositorySupportTest.java
package com.mmnaseri.utils.spring.data.repository; import com.mmnaseri.utils.spring.data.domain.KeyGenerator; import com.mmnaseri.utils.spring.data.domain.impl.ImmutableRepositoryMetadata; import com.mmnaseri.utils.spring.data.domain.impl.key.UUIDKeyGenerator; import com.mmnaseri.utils.spring.data.error.DataStoreException; import com.mmnaseri.utils.spring.data.sample.mocks.Operation; import com.mmnaseri.utils.spring.data.sample.mocks.SpyingDataStore; import com.mmnaseri.utils.spring.data.sample.models.Person; import com.mmnaseri.utils.spring.data.sample.repositories.SimplePersonRepository; import com.mmnaseri.utils.spring.data.store.DataStore; import com.mmnaseri.utils.spring.data.store.impl.MemoryDataStore; import org.hamcrest.Matchers; import org.testng.annotations.Test; import java.util.Arrays; import java.util.concurrent.atomic.AtomicLong; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/11/16, 10:15 AM) */ public class CrudRepositorySupportTest { @Test public void testIntegrity() { final CrudRepositorySupport support = new CrudRepositorySupport(); final MemoryDataStore<Object, Object> dataStore = new MemoryDataStore<>(Object.class); support.setDataStore(dataStore); final ImmutableRepositoryMetadata repositoryMetadata = new ImmutableRepositoryMetadata(String.class, Person.class, SimplePersonRepository.class, "id"); support.setRepositoryMetadata(repositoryMetadata); final UUIDKeyGenerator keyGenerator = new UUIDKeyGenerator(); support.setKeyGenerator(keyGenerator); assertThat(support.getDataStore(), Matchers.is(dataStore)); assertThat(support.getKeyGenerator(), Matchers.<KeyGenerator>is(keyGenerator)); assertThat(support.getRepositoryMetadata(), Matchers.is(repositoryMetadata)); } @Test public void testPerformingUpdates() { final CrudRepositorySupport support = new CrudRepositorySupport(); final SpyingDataStore<Object, Object> dataStore = new SpyingDataStore<>(null, new AtomicLong()); support.setDataStore(dataStore); support.setRepositoryMetadata( new ImmutableRepositoryMetadata(String.class, Person.class, SimplePersonRepository.class, "id")); final Person entity = new Person(); entity.setId("k1"); final Object saved = support.save(entity); assertThat(saved, Matchers.is(entity)); assertThat(dataStore.getRequests(), hasSize(1)); assertThat(dataStore.getRequests().get(0).getEntity(), Matchers.is(entity)); assertThat(dataStore.getRequests().get(0).getOperation(), is(Operation.SAVE)); assertThat(dataStore.getRequests().get(0).getKey(), Matchers.is(entity.getId())); } @Test(expectedExceptions = DataStoreException.class) public void testPerformingInsertsWhenNoKeyGeneratorIsPresent() { final CrudRepositorySupport support = new CrudRepositorySupport(); final DataStore<String, Person> dataStore = new MemoryDataStore<>(Person.class); support.setDataStore(dataStore); support.setRepositoryMetadata( new ImmutableRepositoryMetadata(String.class, Person.class, SimplePersonRepository.class, "id")); support.save(new Person()); } @Test public void testPerformingInsertsWhenAKeyGeneratorIsPresent() { final CrudRepositorySupport support = new CrudRepositorySupport(); final MemoryDataStore<String, Person> actualDataStore = new MemoryDataStore<>(Person.class); final SpyingDataStore<String, Person> dataStore = new SpyingDataStore<>(actualDataStore, new AtomicLong()); support.setDataStore(dataStore); support.setRepositoryMetadata( new ImmutableRepositoryMetadata(String.class, Person.class, SimplePersonRepository.class, "id")); support.setKeyGenerator(new UUIDKeyGenerator()); final Person entity = new Person(); final Object saved = support.save(entity); assertThat(saved, Matchers.is(entity)); assertThat(dataStore.getRequests(), hasSize(1)); assertThat(dataStore.getRequests().get(0).getEntity(), Matchers.is(entity)); assertThat(dataStore.getRequests().get(0).getOperation(), is(Operation.SAVE)); assertThat(dataStore.getRequests().get(0).getKey(), is(notNullValue())); } @Test public void testInsertingMultipleEntities() { final CrudRepositorySupport support = new CrudRepositorySupport(); final MemoryDataStore<String, Person> actualDataStore = new MemoryDataStore<>(Person.class); final SpyingDataStore<String, Person> dataStore = new SpyingDataStore<>(actualDataStore, new AtomicLong()); support.setDataStore(dataStore); support.setRepositoryMetadata( new ImmutableRepositoryMetadata(String.class, Person.class, SimplePersonRepository.class, "id")); support.setKeyGenerator(new UUIDKeyGenerator()); final Person first = new Person(); final Person second = new Person(); final Person third = new Person(); support.insert(Arrays.asList(first, second, third)); assertThat(dataStore.getRequests(), hasSize(3)); assertThat(dataStore.getRequests().get(0).getOperation(), is(Operation.SAVE)); assertThat(dataStore.getRequests().get(0).getEntity(), is(first)); assertThat(dataStore.getRequests().get(1).getOperation(), is(Operation.SAVE)); assertThat(dataStore.getRequests().get(1).getEntity(), is(second)); assertThat(dataStore.getRequests().get(2).getOperation(), is(Operation.SAVE)); assertThat(dataStore.getRequests().get(2).getEntity(), is(third)); } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/mocks/NotMatchingBinaryMatcher.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/mocks/NotMatchingBinaryMatcher.java
package com.mmnaseri.utils.spring.data.sample.mocks; import com.mmnaseri.utils.spring.data.domain.Parameter; import com.mmnaseri.utils.spring.data.domain.impl.matchers.AbstractBinaryMatcher; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 6:59 PM) */ public class NotMatchingBinaryMatcher extends AbstractBinaryMatcher { @Override protected boolean matches(Parameter parameter, Object value, Object first, Object second) { return false; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/mocks/SpyingResultAdapter.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/mocks/SpyingResultAdapter.java
package com.mmnaseri.utils.spring.data.sample.mocks; import com.mmnaseri.utils.spring.data.domain.Invocation; import com.mmnaseri.utils.spring.data.proxy.impl.adapters.AbstractResultAdapter; import java.util.concurrent.atomic.AtomicLong; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 6:48 PM) */ public class SpyingResultAdapter extends AbstractResultAdapter { private final AtomicLong counter; private Long check; private Long request; private final boolean accepts; private final Object result; public SpyingResultAdapter(int priority, AtomicLong counter, boolean accepts, Object result) { super(priority); this.counter = counter; this.accepts = accepts; this.result = result; } @Override public boolean accepts(Invocation invocation, Object originalValue) { check = counter.incrementAndGet(); return accepts; } @Override public Object adapt(Invocation invocation, Object originalValue) { request = counter.incrementAndGet(); return result; } public Long getCheck() { return check; } public Long getRequest() { return request; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/mocks/DataFunctionInvocation.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/mocks/DataFunctionInvocation.java
package com.mmnaseri.utils.spring.data.sample.mocks; import com.mmnaseri.utils.spring.data.proxy.RepositoryConfiguration; import com.mmnaseri.utils.spring.data.query.QueryDescriptor; import com.mmnaseri.utils.spring.data.store.DataStore; import java.util.List; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/10/16) */ @SuppressWarnings("unused") public class DataFunctionInvocation<K, E> { private final DataStore<K, E> dataStore; private final QueryDescriptor query; private final RepositoryConfiguration repositoryConfiguration; private final List<E> selection; public DataFunctionInvocation(DataStore<K, E> dataStore, QueryDescriptor query, RepositoryConfiguration repositoryConfiguration, List<E> selection) { this.dataStore = dataStore; this.query = query; this.repositoryConfiguration = repositoryConfiguration; this.selection = selection; } public DataStore<K, E> getDataStore() { return dataStore; } public QueryDescriptor getQuery() { return query; } public RepositoryConfiguration getRepositoryConfiguration() { return repositoryConfiguration; } public List<E> getSelection() { return selection; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/mocks/NotMatchingBinaryComparableMatcher.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/mocks/NotMatchingBinaryComparableMatcher.java
package com.mmnaseri.utils.spring.data.sample.mocks; import com.mmnaseri.utils.spring.data.domain.impl.matchers.AbstractBinaryComparableMatcher; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 6:59 PM) */ public class NotMatchingBinaryComparableMatcher extends AbstractBinaryComparableMatcher { @Override protected boolean matches(Comparable value, Comparable first, Comparable second) { return false; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/mocks/NotMatchingSimpleComparableMatcher.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/mocks/NotMatchingSimpleComparableMatcher.java
package com.mmnaseri.utils.spring.data.sample.mocks; import com.mmnaseri.utils.spring.data.domain.impl.matchers.AbstractSimpleComparableMatcher; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 7:00 PM) */ public class NotMatchingSimpleComparableMatcher extends AbstractSimpleComparableMatcher { @Override protected boolean matches(Comparable actual, Comparable pivot) { return false; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/mocks/NotMatchingSimpleMatcher.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/mocks/NotMatchingSimpleMatcher.java
package com.mmnaseri.utils.spring.data.sample.mocks; import com.mmnaseri.utils.spring.data.domain.Parameter; import com.mmnaseri.utils.spring.data.domain.impl.matchers.AbstractSimpleMatcher; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 7:00 PM) */ public class NotMatchingSimpleMatcher extends AbstractSimpleMatcher { @Override protected boolean matches(Parameter parameter, Object actual, Object expected) { return false; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/mocks/SpyingListenerContext.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/mocks/SpyingListenerContext.java
package com.mmnaseri.utils.spring.data.sample.mocks; import com.mmnaseri.utils.spring.data.store.DataStoreEvent; import com.mmnaseri.utils.spring.data.store.DataStoreEventListener; import com.mmnaseri.utils.spring.data.store.DataStoreEventListenerContext; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.concurrent.atomic.AtomicLong; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/10/16) */ public class SpyingListenerContext implements DataStoreEventListenerContext { private final List<EventTrigger> events = new ArrayList<>(); private final AtomicLong counter; public SpyingListenerContext(AtomicLong counter) { this.counter = counter; } @Override public <E extends DataStoreEvent> void register(DataStoreEventListener<E> listener) { throw new UnsupportedOperationException(); } @Override public void trigger(DataStoreEvent event) { events.add(new EventTrigger(counter.incrementAndGet(), event)); } @Override public <E extends DataStoreEvent> List<DataStoreEventListener<? extends E>> getListeners(Class<E> eventType) { throw new UnsupportedOperationException(); } public List<EventTrigger> getEvents() { return Collections.unmodifiableList(events); } public void reset() { events.clear(); } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/mocks/SpyingCollectionMatcher.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/mocks/SpyingCollectionMatcher.java
package com.mmnaseri.utils.spring.data.sample.mocks; import com.mmnaseri.utils.spring.data.domain.impl.matchers.AbstractCollectionMatcher; import java.util.Collection; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 6:59 PM) */ public class SpyingCollectionMatcher extends AbstractCollectionMatcher { private Collection collection; @Override protected boolean matches(Object actual, Collection collection) { this.collection = collection; return false; } public Collection<?> getCollection() { return collection; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/mocks/NullReturningRepositoryMetadataResolver.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/mocks/NullReturningRepositoryMetadataResolver.java
package com.mmnaseri.utils.spring.data.sample.mocks; import com.mmnaseri.utils.spring.data.domain.RepositoryMetadata; import com.mmnaseri.utils.spring.data.domain.impl.AbstractRepositoryMetadataResolver; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 7:03 PM) */ public class NullReturningRepositoryMetadataResolver extends AbstractRepositoryMetadataResolver { private Class<?> repositoryInterface; @Override protected RepositoryMetadata resolveFromInterface(Class<?> repositoryInterface) { this.repositoryInterface = repositoryInterface; return null; } public Class<?> getRepositoryInterface() { return repositoryInterface; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/mocks/AllCatchingEventListener.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/mocks/AllCatchingEventListener.java
package com.mmnaseri.utils.spring.data.sample.mocks; import com.mmnaseri.utils.spring.data.store.DataStoreEvent; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 1:03 PM) */ public class AllCatchingEventListener extends SpyingEventListener<DataStoreEvent> { }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/mocks/SpyingEventListener.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/mocks/SpyingEventListener.java
package com.mmnaseri.utils.spring.data.sample.mocks; import com.mmnaseri.utils.spring.data.store.DataStoreEvent; import com.mmnaseri.utils.spring.data.store.DataStoreEventListener; import java.util.ArrayList; import java.util.List; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 1:03 PM) */ public class SpyingEventListener<E extends DataStoreEvent> implements DataStoreEventListener<E> { private final List<E> events = new ArrayList<>(); @Override public void onEvent(E event) { events.add(event); } public List<E> getEvents() { return events; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/mocks/OperationRequest.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/mocks/OperationRequest.java
package com.mmnaseri.utils.spring.data.sample.mocks; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/10/16) */ public class OperationRequest<K, E> { private final Long timestamp; private final Operation operation; private final K key; private final E entity; public OperationRequest(Long timestamp, Operation operation, K key, E entity) { this.timestamp = timestamp; this.operation = operation; this.key = key; this.entity = entity; } public Long getTimestamp() { return timestamp; } public Operation getOperation() { return operation; } public K getKey() { return key; } public E getEntity() { return entity; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/mocks/StringifiableDataStoreOperation.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/mocks/StringifiableDataStoreOperation.java
package com.mmnaseri.utils.spring.data.sample.mocks; import com.mmnaseri.utils.spring.data.domain.Invocation; import com.mmnaseri.utils.spring.data.proxy.RepositoryConfiguration; import com.mmnaseri.utils.spring.data.store.DataStore; import com.mmnaseri.utils.spring.data.store.DataStoreOperation; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 6:50 PM) */ public class StringifiableDataStoreOperation<R, K, E> implements DataStoreOperation<R, K, E> { private final String string; public StringifiableDataStoreOperation(String string) { this.string = string; } @Override public R execute(DataStore store, RepositoryConfiguration configuration, Invocation invocation) { return null; } @Override public String toString() { return string; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/mocks/NotMatchingStringMatcher.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/mocks/NotMatchingStringMatcher.java
package com.mmnaseri.utils.spring.data.sample.mocks; import com.mmnaseri.utils.spring.data.domain.impl.matchers.AbstractSimpleStringMatcher; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 7:01 PM) */ public class NotMatchingStringMatcher extends AbstractSimpleStringMatcher { private String actual; private String argument; @Override protected boolean matches(String actual, String argument) { this.actual = actual; this.argument = argument; return false; } public String getActual() { return actual; } public String getArgument() { return argument; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/mocks/Operation.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/mocks/Operation.java
package com.mmnaseri.utils.spring.data.sample.mocks; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/10/16) */ public enum Operation { SAVE, DELETE, READ, FLUSH, CHECK }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/mocks/CustomStringKeyGenerator.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/mocks/CustomStringKeyGenerator.java
package com.mmnaseri.utils.spring.data.sample.mocks; import com.mmnaseri.utils.spring.data.domain.KeyGenerator; import java.util.concurrent.atomic.AtomicLong; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 7:16 PM) */ public class CustomStringKeyGenerator implements KeyGenerator<String> { private final AtomicLong counter = new AtomicLong(0); @Override public String generate() { return String.valueOf(counter.incrementAndGet()); } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/mocks/SpyingSelectDataStoreOperation.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/mocks/SpyingSelectDataStoreOperation.java
package com.mmnaseri.utils.spring.data.sample.mocks; import com.mmnaseri.utils.spring.data.domain.Invocation; import com.mmnaseri.utils.spring.data.domain.impl.SelectDataStoreOperation; import com.mmnaseri.utils.spring.data.proxy.RepositoryConfiguration; import com.mmnaseri.utils.spring.data.query.QueryDescriptor; import com.mmnaseri.utils.spring.data.store.DataStore; import java.util.List; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 6:38 PM) */ public class SpyingSelectDataStoreOperation<K, E> extends SelectDataStoreOperation<K, E> { private boolean called = false; private final List<E> list; public SpyingSelectDataStoreOperation(QueryDescriptor descriptor, List<E> list) { super(descriptor); this.list = list; } @Override public List<E> execute(DataStore<K, E> store, RepositoryConfiguration configuration, Invocation invocation) { called = true; return list; } public boolean isCalled() { return called; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/mocks/SpyingHandler.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/mocks/SpyingHandler.java
package com.mmnaseri.utils.spring.data.sample.mocks; import com.mmnaseri.utils.spring.data.proxy.NonDataOperationHandler; import java.lang.reflect.Method; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 1:30 PM) */ public class SpyingHandler implements NonDataOperationHandler { private boolean called; public SpyingHandler() { called = false; } @Override public boolean handles(Object proxy, Method method, Object... args) { return method.getName().equals("wait"); } @Override public Object invoke(Object proxy, Method method, Object... args) { called = true; return null; } public boolean isCalled() { return called; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/mocks/DuplicatingKeyGenerator.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/mocks/DuplicatingKeyGenerator.java
package com.mmnaseri.utils.spring.data.sample.mocks; import com.mmnaseri.utils.spring.data.domain.impl.AbstractRandomKeyGenerator; import java.util.concurrent.atomic.AtomicInteger; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 7:02 PM) */ public class DuplicatingKeyGenerator extends AbstractRandomKeyGenerator<Integer> { private boolean repeat = false; private final AtomicInteger counter = new AtomicInteger(0); @Override protected Integer getNext() { if (!repeat) { counter.incrementAndGet(); repeat = true; } else { repeat = false; } return counter.get(); } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/mocks/NotMatchingUnaryMatcher.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/mocks/NotMatchingUnaryMatcher.java
package com.mmnaseri.utils.spring.data.sample.mocks; import com.mmnaseri.utils.spring.data.domain.impl.matchers.AbstractUnaryMatcher; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 7:01 PM) */ public class NotMatchingUnaryMatcher extends AbstractUnaryMatcher { @Override protected boolean matches(Object value) { return false; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/mocks/AfterInsertEventListener.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/mocks/AfterInsertEventListener.java
package com.mmnaseri.utils.spring.data.sample.mocks; import com.mmnaseri.utils.spring.data.store.impl.AfterInsertDataStoreEvent; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 1:03 PM) */ public class AfterInsertEventListener extends SpyingEventListener<AfterInsertDataStoreEvent> { }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/mocks/SpyingDataStore.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/mocks/SpyingDataStore.java
package com.mmnaseri.utils.spring.data.sample.mocks; import com.mmnaseri.utils.spring.data.store.DataStore; import com.mmnaseri.utils.spring.data.store.QueueingDataStore; import java.util.*; import java.util.concurrent.atomic.AtomicLong; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/10/16) */ @SuppressWarnings("unused") public class SpyingDataStore<K, E> implements QueueingDataStore<K, E, Object> { private final DataStore<K, E> delegate; private final List<OperationRequest> requests; private final AtomicLong counter; private final Stack<Object> batches = new Stack<>(); public SpyingDataStore(DataStore<K, E> delegate, AtomicLong counter) { this.delegate = delegate; this.counter = counter; requests = new ArrayList<>(); } @Override public boolean hasKey(K key) { requests.add(new OperationRequest<>(counter.incrementAndGet(), Operation.CHECK, key, null)); return delegate.hasKey(key); } @Override public boolean save(K key, E entity) { requests.add(new OperationRequest<>(counter.incrementAndGet(), Operation.SAVE, key, entity)); return delegate != null && delegate.save(key, entity); } @Override public boolean delete(K key) { requests.add(new OperationRequest<>(counter.incrementAndGet(), Operation.DELETE, key, null)); return delegate != null && delegate.delete(key); } @Override public E retrieve(K key) { requests.add(new OperationRequest<>(counter.incrementAndGet(), Operation.READ, key, null)); if (delegate == null) { return null; } return delegate.retrieve(key); } @Override public Collection<K> keys() { requests.add(new OperationRequest<>(counter.incrementAndGet(), Operation.CHECK, null, null)); if (delegate == null) { return Collections.emptySet(); } return delegate.keys(); } @Override public Collection<E> retrieveAll() { requests.add(new OperationRequest<>(counter.incrementAndGet(), Operation.READ, null, null)); if (delegate == null) { return Collections.emptySet(); } return delegate.retrieveAll(); } @Override public Class<E> getEntityType() { if (delegate == null) { return null; } return delegate.getEntityType(); } @Override public void truncate() { if (delegate != null) { delegate.truncate(); } } public List<OperationRequest> getRequests() { return Collections.unmodifiableList(requests); } public void reset() { requests.clear(); } public DataStore<K, E> getDelegate() { return delegate; } @Override public void flush() { requests.add(new OperationRequest<>(counter.incrementAndGet(), Operation.FLUSH, null, null)); } @Override public Object startBatch() { final Object batch = new Object(); batches.add(batch); return batch; } @Override public void endBatch(Object batch) { assertThat(batches, is(not(empty()))); final Object lastBatch = batches.pop(); assertThat(batch, is(lastBatch)); } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/mocks/SpyingDataFunction.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/mocks/SpyingDataFunction.java
package com.mmnaseri.utils.spring.data.sample.mocks; import com.mmnaseri.utils.spring.data.proxy.RepositoryConfiguration; import com.mmnaseri.utils.spring.data.query.DataFunction; import com.mmnaseri.utils.spring.data.query.QueryDescriptor; import com.mmnaseri.utils.spring.data.store.DataStore; import java.util.ArrayList; import java.util.List; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/10/16) */ @SuppressWarnings("unused") public class SpyingDataFunction<R> implements DataFunction<R> { private final List<DataFunctionInvocation<?, ?>> invocations = new ArrayList<>(); private final DataFunction<R> delegate; public SpyingDataFunction(DataFunction<R> delegate) { this.delegate = delegate; } @Override public <K, E> R apply(DataStore<K, E> dataStore, QueryDescriptor query, RepositoryConfiguration configuration, List<E> selection) { invocations.add(new DataFunctionInvocation<>(dataStore, query, configuration, selection)); if (delegate != null) { return delegate.apply(dataStore, query, configuration, selection); } return null; } public List<DataFunctionInvocation<?, ?>> getInvocations() { return invocations; } public DataFunction<R> getDelegate() { return delegate; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/mocks/SpyingOperation.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/mocks/SpyingOperation.java
package com.mmnaseri.utils.spring.data.sample.mocks; import com.mmnaseri.utils.spring.data.domain.Invocation; import com.mmnaseri.utils.spring.data.proxy.RepositoryConfiguration; import com.mmnaseri.utils.spring.data.sample.models.Person; import com.mmnaseri.utils.spring.data.store.DataStore; import com.mmnaseri.utils.spring.data.store.DataStoreOperation; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 6:37 PM) */ @SuppressWarnings("unused") public class SpyingOperation implements DataStoreOperation<Object, String, Person> { private DataStore<String, Person> store; private RepositoryConfiguration configuration; private Invocation invocation; private final Object result; public SpyingOperation(Object result) { this.result = result; } @Override public Object execute(DataStore<String, Person> store, RepositoryConfiguration configuration, Invocation invocation) { this.store = store; this.configuration = configuration; this.invocation = invocation; return result; } public DataStore<String, Person> getStore() { return store; } public RepositoryConfiguration getConfiguration() { return configuration; } public Invocation getInvocation() { return invocation; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/mocks/EventTrigger.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/mocks/EventTrigger.java
package com.mmnaseri.utils.spring.data.sample.mocks; import com.mmnaseri.utils.spring.data.store.DataStoreEvent; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/10/16) */ public class EventTrigger { private final Long timestamp; private final DataStoreEvent event; public EventTrigger(Long timestamp, DataStoreEvent event) { this.timestamp = timestamp; this.event = event; } public Long getTimestamp() { return timestamp; } public DataStoreEvent getEvent() { return event; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/Zip.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/Zip.java
package com.mmnaseri.utils.spring.data.sample.models; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (9/21/15) */ @SuppressWarnings("unused") public class Zip implements Comparable<Zip> { private String prefix; private Long region; private String area; public String getPrefix() { return prefix; } public Zip setPrefix(String prefix) { this.prefix = prefix; return this; } public Long getRegion() { return region; } public Zip setRegion(Long region) { this.region = region; return this; } public String getArea() { return area; } public Zip setArea(String area) { this.area = area; return this; } @Override public int compareTo(Zip o) { return prefix.compareTo(o.prefix); } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/EntityWithUtilDateLastModifiedDate.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/EntityWithUtilDateLastModifiedDate.java
package com.mmnaseri.utils.spring.data.sample.models; import org.springframework.data.annotation.LastModifiedDate; import java.util.Date; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 5:20 PM) */ @SuppressWarnings("unused") public class EntityWithUtilDateLastModifiedDate { private String id; @LastModifiedDate private Date lastModifiedDate; public String getId() { return id; } public void setId(String id) { this.id = id; } public Date getLastModifiedDate() { return lastModifiedDate; } public void setLastModifiedDate(Date lastModifiedDate) { this.lastModifiedDate = lastModifiedDate; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/SampleEntity.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/SampleEntity.java
package com.mmnaseri.utils.spring.data.sample.models; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (10/26/15) */ @SuppressWarnings("unused") public class SampleEntity extends BaseEntity { private String model; public SampleEntity() { } public SampleEntity(String model) { this.model = model; } public SampleEntity(String id, String model) { super(id); this.model = model; } public String getModel() { return model; } public void setModel(String model) { this.model = model; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/EntityWithAnnotationOnIdFieldAndGetterAndAnIdField.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/EntityWithAnnotationOnIdFieldAndGetterAndAnIdField.java
package com.mmnaseri.utils.spring.data.sample.models; import org.springframework.data.annotation.Id; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 6:53 PM) */ @SuppressWarnings("unused") public class EntityWithAnnotationOnIdFieldAndGetterAndAnIdField { private String id; @Id private String annotatedId; private String unannotatedId; public String getId() { return id; } public void setId(String id) { this.id = id; } public String getAnnotatedId() { return annotatedId; } public void setAnnotatedId(String annotatedId) { this.annotatedId = annotatedId; } @Id public String getUnannotatedId() { return unannotatedId; } public void setUnannotatedId(String unannotatedId) { this.unannotatedId = unannotatedId; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/EntityWithIdField.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/EntityWithIdField.java
package com.mmnaseri.utils.spring.data.sample.models; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 6:57 PM) */ @SuppressWarnings("unused") public class EntityWithIdField { private String id; }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/AuditedPerson.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/AuditedPerson.java
package com.mmnaseri.utils.spring.data.sample.models; import org.springframework.data.annotation.CreatedBy; import org.springframework.data.annotation.CreatedDate; import org.springframework.data.annotation.LastModifiedBy; import org.springframework.data.annotation.LastModifiedDate; import java.util.Date; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 11:43 AM) */ @SuppressWarnings("unused") public class AuditedPerson extends Person { @LastModifiedBy private String modifiedBy; @CreatedBy private String createdBy; @LastModifiedDate private Date modifiedDate; @CreatedDate private Date createdDate; public String getModifiedBy() { return modifiedBy; } public AuditedPerson setModifiedBy(String modifiedBy) { this.modifiedBy = modifiedBy; return this; } public String getCreatedBy() { return createdBy; } public AuditedPerson setCreatedBy(String createdBy) { this.createdBy = createdBy; return this; } public Date getModifiedDate() { return modifiedDate; } public AuditedPerson setModifiedDate(Date modifiedDate) { this.modifiedDate = modifiedDate; return this; } public Date getCreatedDate() { return createdDate; } public AuditedPerson setCreatedDate(Date createdDate) { this.createdDate = createdDate; return this; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/PersonSerializable.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/PersonSerializable.java
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package com.mmnaseri.utils.spring.data.sample.models; /** * @author blackleg */ @SuppressWarnings({"unused", "EmptyMethod"}) public class PersonSerializable extends Person { @Override public String getId() { return super.getId(); //To change body of generated methods, choose Tools | Templates. } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/EmptyEntity.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/EmptyEntity.java
package com.mmnaseri.utils.spring.data.sample.models; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 6:57 PM) */ @SuppressWarnings("unused") public class EmptyEntity { }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/EntityWithTimestampDateLastModifiedDate.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/EntityWithTimestampDateLastModifiedDate.java
package com.mmnaseri.utils.spring.data.sample.models; import org.springframework.data.annotation.LastModifiedDate; import java.sql.Timestamp; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 5:20 PM) */ @SuppressWarnings("unused") public class EntityWithTimestampDateLastModifiedDate { private String id; @LastModifiedDate private Timestamp lastModifiedDate; public String getId() { return id; } public void setId(String id) { this.id = id; } public Timestamp getLastModifiedDate() { return lastModifiedDate; } public void setLastModifiedDate(Timestamp lastModifiedDate) { this.lastModifiedDate = lastModifiedDate; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/EntityWithAnnotatedEmbeddedIdFieldFromJPA.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/EntityWithAnnotatedEmbeddedIdFieldFromJPA.java
package com.mmnaseri.utils.spring.data.sample.models; import javax.persistence.EmbeddedId; /** * @author Balthasar Biedermann */ @SuppressWarnings("unused") public class EntityWithAnnotatedEmbeddedIdFieldFromJPA { @EmbeddedId private EmbeddableId customIdProperty; public EmbeddableId getCustomIdProperty() { return customIdProperty; } public void setCustomIdProperty(EmbeddableId customIdProperty) { this.customIdProperty = customIdProperty; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/EntityWithoutAnnotatedFields.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/EntityWithoutAnnotatedFields.java
package com.mmnaseri.utils.spring.data.sample.models; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 6:52 PM) */ @SuppressWarnings("unused") public class EntityWithoutAnnotatedFields { }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/EntityWithAnnotatedIdGetterFromJPA.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/EntityWithAnnotatedIdGetterFromJPA.java
package com.mmnaseri.utils.spring.data.sample.models; import javax.persistence.Id; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (6/8/16, 1:37 AM) */ @SuppressWarnings("unused") public class EntityWithAnnotatedIdGetterFromJPA { private Integer myCustomId; @Id public Integer getMyCustomId() { return myCustomId; } public void setMyCustomId(Integer myCustomId) { this.myCustomId = myCustomId; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/EntityWithSqlDateLastModifiedDate.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/EntityWithSqlDateLastModifiedDate.java
package com.mmnaseri.utils.spring.data.sample.models; import org.springframework.data.annotation.LastModifiedDate; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 5:20 PM) */ @SuppressWarnings("unused") public class EntityWithSqlDateLastModifiedDate { private String id; @LastModifiedDate private java.sql.Date lastModifiedDate; public String getId() { return id; } public void setId(String id) { this.id = id; } public java.sql.Date getLastModifiedDate() { return lastModifiedDate; } public void setLastModifiedDate(java.sql.Date lastModifiedDate) { this.lastModifiedDate = lastModifiedDate; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/ChildZip.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/ChildZip.java
package com.mmnaseri.utils.spring.data.sample.models; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 7:06 PM) */ @SuppressWarnings("unused") public class ChildZip extends Zip { }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/EntityWithWriteOnlyCreatedBy.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/EntityWithWriteOnlyCreatedBy.java
package com.mmnaseri.utils.spring.data.sample.models; import org.springframework.data.annotation.CreatedBy; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 5:21 PM) */ @SuppressWarnings("unused") public class EntityWithWriteOnlyCreatedBy { private String id; @SuppressWarnings("FieldCanBeLocal") // This is used in test. @CreatedBy private String createdBy; public String getId() { return id; } public void setId(String id) { this.id = id; } public void setCreatedBy(String createdBy) { this.createdBy = createdBy; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/EntityWithNoImmediatelyResolvableIdProperty.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/EntityWithNoImmediatelyResolvableIdProperty.java
package com.mmnaseri.utils.spring.data.sample.models; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 6:56 PM) */ @SuppressWarnings("unused") public class EntityWithNoImmediatelyResolvableIdProperty { private String identifier; public String getIdentifier() { return identifier; } public void setIdentifier(String identifier) { this.identifier = identifier; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/EntityWithCreatedBy.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/EntityWithCreatedBy.java
package com.mmnaseri.utils.spring.data.sample.models; import org.springframework.data.annotation.CreatedBy; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 5:20 PM) */ @SuppressWarnings("unused") public class EntityWithCreatedBy { private String id; @CreatedBy private String createdBy; public String getId() { return id; } public void setId(String id) { this.id = id; } public String getCreatedBy() { return createdBy; } public void setCreatedBy(String createdBy) { this.createdBy = createdBy; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/EntityWithDateTimeLastModifiedDate.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/EntityWithDateTimeLastModifiedDate.java
package com.mmnaseri.utils.spring.data.sample.models; import org.springframework.data.annotation.LastModifiedDate; import java.time.Instant; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 5:21 PM) */ @SuppressWarnings("unused") public class EntityWithDateTimeLastModifiedDate { private String id; @LastModifiedDate private Instant lastModifiedDate; public String getId() { return id; } public void setId(String id) { this.id = id; } public Instant getLastModifiedDate() { return lastModifiedDate; } public void setLastModifiedDate(Instant lastModifiedDate) { this.lastModifiedDate = lastModifiedDate; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/EntityWithTimeLastModifiedDate.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/EntityWithTimeLastModifiedDate.java
package com.mmnaseri.utils.spring.data.sample.models; import org.springframework.data.annotation.LastModifiedDate; import java.sql.Time; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 5:20 PM) */ @SuppressWarnings("unused") public class EntityWithTimeLastModifiedDate { private String id; @LastModifiedDate private Time lastModifiedDate; public String getId() { return id; } public void setId(String id) { this.id = id; } public Time getLastModifiedDate() { return lastModifiedDate; } public void setLastModifiedDate(Time lastModifiedDate) { this.lastModifiedDate = lastModifiedDate; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/EntityWithAnnotatedIdField.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/EntityWithAnnotatedIdField.java
package com.mmnaseri.utils.spring.data.sample.models; import org.springframework.data.annotation.Id; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 6:52 PM) */ @SuppressWarnings("unused") public class EntityWithAnnotatedIdField { @Id private String id; }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/EmbeddableId.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/EmbeddableId.java
package com.mmnaseri.utils.spring.data.sample.models; import javax.persistence.Embeddable; import java.io.Serializable; /** * @author Balthasar Biedermann */ @Embeddable @SuppressWarnings("unused") public class EmbeddableId implements Serializable { private String str; private Integer integer; }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/Person.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/Person.java
package com.mmnaseri.utils.spring.data.sample.models; import java.util.Objects; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (9/21/15) */ @SuppressWarnings("unused") public class Person { private String id; private String firstName; private String lastName; private Zip addressZip; private Address address; private Integer age; public String getId() { return id; } public Person setId(String id) { this.id = id; return this; } public String getFirstName() { return firstName; } public Person setFirstName(String firstName) { this.firstName = firstName; return this; } public String getLastName() { return lastName; } public Person setLastName(String lastName) { this.lastName = lastName; return this; } public Zip getAddressZip() { return addressZip; } public Person setAddressZip(Zip addressZip) { this.addressZip = addressZip; return this; } public Address getAddress() { return address; } public Person setAddress(Address address) { this.address = address; return this; } public Integer getAge() { return age; } public Person setAge(Integer age) { this.age = age; return this; } @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } Person person = (Person) o; return Objects.equals(id, person.id); } @Override public int hashCode() { return id != null ? id.hashCode() : 0; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/EntityWithAnnotatedEmbeddedIdField.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/EntityWithAnnotatedEmbeddedIdField.java
package com.mmnaseri.utils.spring.data.sample.models; import javax.persistence.EmbeddedId; /** * @author Balthasar Biedermann */ @SuppressWarnings("unused") public class EntityWithAnnotatedEmbeddedIdField { @EmbeddedId private EmbeddableId id; }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/EntityWithIdFieldHiddenBehindDifferentlyNamedAccessors.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/EntityWithIdFieldHiddenBehindDifferentlyNamedAccessors.java
package com.mmnaseri.utils.spring.data.sample.models; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 6:56 PM) */ @SuppressWarnings("unused") public class EntityWithIdFieldHiddenBehindDifferentlyNamedAccessors { private String id; public String getIdentifier() { return id; } public void setIdentifier(String id) { this.id = id; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/EntityWithUnderscorePrecedingIdField.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/EntityWithUnderscorePrecedingIdField.java
package com.mmnaseri.utils.spring.data.sample.models; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 6:54 PM) */ @SuppressWarnings("unused") public class EntityWithUnderscorePrecedingIdField { private String _id; public String getId() { return _id; } public void setId(String id) { this._id = id; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/EntityWithPrimitiveIdProperty.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/EntityWithPrimitiveIdProperty.java
package com.mmnaseri.utils.spring.data.sample.models; import javax.persistence.Id; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (6/12/16, 6:14 PM) */ @SuppressWarnings("unused") public class EntityWithPrimitiveIdProperty { @Id private long id; }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/NoAccessorPerson.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/NoAccessorPerson.java
package com.mmnaseri.utils.spring.data.sample.models; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 5:18 PM) */ @SuppressWarnings("unused") public class NoAccessorPerson { private String id; private String firstName; private String lastName; private Zip addressZip; private Address address; }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/State.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/State.java
package com.mmnaseri.utils.spring.data.sample.models; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (9/21/15) */ @SuppressWarnings("unused") public class State implements Comparable<State> { private String name; private String abbreviation; public String getName() { return name; } public State setName(String name) { this.name = name; return this; } public String getAbbreviation() { return abbreviation; } public State setAbbreviation(String abbreviation) { this.abbreviation = abbreviation; return this; } @Override public int compareTo(State that) { return this.abbreviation.compareTo(that.abbreviation); } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/EntityWithAnnotatedEmbeddedIdGetterFromJPA.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/EntityWithAnnotatedEmbeddedIdGetterFromJPA.java
package com.mmnaseri.utils.spring.data.sample.models; import javax.persistence.EmbeddedId; /** * @author Balthasar Biedermann */ @SuppressWarnings("unused") public class EntityWithAnnotatedEmbeddedIdGetterFromJPA { private EmbeddableId myCustomId; @EmbeddedId private EmbeddableId getMyCustomId() { return myCustomId; } public void setMyCustomId(EmbeddableId myCustomId) { this.myCustomId = myCustomId; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/EntityWithAnnotatedEmbeddedIdGetter.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/EntityWithAnnotatedEmbeddedIdGetter.java
package com.mmnaseri.utils.spring.data.sample.models; import javax.persistence.EmbeddedId; /** * @author Balthasar Biedermann */ @SuppressWarnings("unused") public class EntityWithAnnotatedEmbeddedIdGetter { private EmbeddableId id; @EmbeddedId private EmbeddableId getId() { return id; } public void setId(EmbeddableId id) { this.id = id; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/EntityWithAnnotatedIdGetter.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/EntityWithAnnotatedIdGetter.java
package com.mmnaseri.utils.spring.data.sample.models; import org.springframework.data.annotation.Id; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 6:52 PM) */ @SuppressWarnings("unused") public class EntityWithAnnotatedIdGetter { private String id; @Id public String getId() { return id; } public void setId(String id) { this.id = id; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/AuditableEntity.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/AuditableEntity.java
package com.mmnaseri.utils.spring.data.sample.models; import org.springframework.data.domain.Auditable; import javax.annotation.Nonnull; import java.time.Instant; import java.util.Optional; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 5:23 PM) */ @SuppressWarnings("unused") public class AuditableEntity implements Auditable<String, String, Instant> { private String id; private String createdBy; private String lastModifiedBy; private Instant createdDate; private Instant lastModifiedDate; public void setId(String id) { this.id = id; } @Override @Nonnull public Optional<String> getCreatedBy() { return Optional.ofNullable(createdBy); } @Override public void setCreatedBy(@Nonnull String createdBy) { this.createdBy = createdBy; } @Override @Nonnull public Optional<String> getLastModifiedBy() { return Optional.ofNullable(lastModifiedBy); } @Override public void setLastModifiedBy(@Nonnull String lastModifiedBy) { this.lastModifiedBy = lastModifiedBy; } @Override @Nonnull public Optional<Instant> getCreatedDate() { return Optional.ofNullable(createdDate); } @Override public void setCreatedDate(@Nonnull Instant createdDate) { this.createdDate = createdDate; } @Override @Nonnull public Optional<Instant> getLastModifiedDate() { return Optional.ofNullable(lastModifiedDate); } @Override public void setLastModifiedDate(@Nonnull Instant lastModifiedDate) { this.lastModifiedDate = lastModifiedDate; } @Override public String getId() { return id; } @Override public boolean isNew() { return getId() == null; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/EntityWithFinalCreatedBy.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/EntityWithFinalCreatedBy.java
package com.mmnaseri.utils.spring.data.sample.models; import org.springframework.data.annotation.CreatedBy; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 5:21 PM) */ @SuppressWarnings("unused") public class EntityWithFinalCreatedBy { private String id; @CreatedBy private final String createdBy = null; public String getId() { return id; } public void setId(String id) { this.id = id; } public String getCreatedBy() { //noinspection ConstantConditions return createdBy; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/DummyEvent.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/DummyEvent.java
package com.mmnaseri.utils.spring.data.sample.models; import com.mmnaseri.utils.spring.data.domain.RepositoryMetadata; import com.mmnaseri.utils.spring.data.store.DataStore; import com.mmnaseri.utils.spring.data.store.DataStoreEvent; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 5:24 PM) */ @SuppressWarnings("unused") public class DummyEvent implements DataStoreEvent { @Override public RepositoryMetadata getRepositoryMetadata() { return null; } @Override public DataStore<?, ?> getDataStore() { return null; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/EntityWithoutAnnotatedIdGetter.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/EntityWithoutAnnotatedIdGetter.java
package com.mmnaseri.utils.spring.data.sample.models; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 6:52 PM) */ @SuppressWarnings("unused") public class EntityWithoutAnnotatedIdGetter { private String id; public String getId() { return id; } public void setId(String id) { this.id = id; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/Address.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/Address.java
package com.mmnaseri.utils.spring.data.sample.models; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (9/21/15) */ @SuppressWarnings("unused") public class Address { private String city; private String street; private State state; private Zip zip; public String getCity() { return city; } public Address setCity(String city) { this.city = city; return this; } public String getStreet() { return street; } public Address setStreet(String street) { this.street = street; return this; } public State getState() { return state; } public Address setState(State state) { this.state = state; return this; } public Zip getZip() { return zip; } public Address setZip(Zip zip) { this.zip = zip; return this; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/OtherChildZip.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/OtherChildZip.java
package com.mmnaseri.utils.spring.data.sample.models; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 7:07 PM) */ @SuppressWarnings("unused") public class OtherChildZip extends Zip { }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/ImplicitlyAuditableEntity.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/ImplicitlyAuditableEntity.java
package com.mmnaseri.utils.spring.data.sample.models; import org.springframework.data.annotation.CreatedBy; import org.springframework.data.annotation.CreatedDate; import org.springframework.data.annotation.LastModifiedBy; import org.springframework.data.annotation.LastModifiedDate; import java.util.Date; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 5:23 PM) */ @SuppressWarnings("unused") public class ImplicitlyAuditableEntity { private String id; @CreatedBy private String createdBy; @LastModifiedBy private String lastModifiedBy; @CreatedDate private Date createdDate; @LastModifiedDate private Date lastModifiedDate; public String getId() { return id; } public void setId(String id) { this.id = id; } public String getCreatedBy() { return createdBy; } public void setCreatedBy(String createdBy) { this.createdBy = createdBy; } public String getLastModifiedBy() { return lastModifiedBy; } public void setLastModifiedBy(String lastModifiedBy) { this.lastModifiedBy = lastModifiedBy; } public Date getCreatedDate() { return createdDate; } public void setCreatedDate(Date createdDate) { this.createdDate = createdDate; } public Date getLastModifiedDate() { return lastModifiedDate; } public void setLastModifiedDate(Date lastModifiedDate) { this.lastModifiedDate = lastModifiedDate; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false