Skip to content

Commit 60296f3

Browse files
Polishing.
Original Pull Request: #3458
1 parent 66a86fa commit 60296f3

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/test/java/org/springframework/data/repository/aot/generate/AotRepositoryMethodBuilderUnitTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ void generatesMethodSkeletonBasedOnGenerationMetadata() throws NoSuchMethodExcep
6666
when(methodGenerationContext.getTargetMethodMetadata()).thenReturn(methodMetadata);
6767

6868
AotRepositoryMethodBuilder builder = new AotRepositoryMethodBuilder(methodGenerationContext);
69-
assertThat(builder.buildMethod().toString().replaceAll(System.lineSeparator(), " ")) //
70-
.containsPattern("findByFirstname\\(.*@.*Param\\(\"hello\"\\).*String firstname\\)");
69+
assertThat(builder.buildMethod().toString()) //
70+
.containsSubsequence("findByFirstname(", "@", "Param(\"hello\")", "String firstname)");
7171
}
7272

7373
@Test // GH-3279

src/test/java/org/springframework/data/repository/aot/generate/MethodMetadataUnitTests.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,18 @@
2222

2323
import org.junit.jupiter.api.Test;
2424
import org.mockito.Mockito;
25-
2625
import org.springframework.data.core.TypeInformation;
2726
import org.springframework.data.domain.Pageable;
2827
import org.springframework.data.repository.core.RepositoryInformation;
2928
import org.springframework.data.repository.query.Param;
29+
import org.springframework.data.web.SortDefault;
3030
import org.springframework.javapoet.ParameterSpec;
3131

3232
/**
3333
* Unit tests for {@link MethodMetadata}.
3434
*
3535
* @author Christoph Strobl
36+
* @author Mark Paluch
3637
*/
3738
class MethodMetadataUnitTests {
3839

@@ -51,8 +52,13 @@ void addsAnnotations() throws NoSuchMethodException {
5152

5253
MethodMetadata metadata = methodMetadataFor("threeArgsMethod");
5354

54-
ParameterSpec spec = metadata.getMethodArguments().get("arg2");
55-
assertThat(spec.annotations()).hasSize(1);
55+
ParameterSpec arg1 = metadata.getMethodArguments().get("arg1");
56+
assertThat(arg1.annotations()).extracting(annotationSpec -> annotationSpec.type().toString())
57+
.containsExactly(SortDefault.class.getTypeName());
58+
59+
ParameterSpec arg2 = metadata.getMethodArguments().get("arg2");
60+
assertThat(arg2.annotations()).extracting(annotationSpec -> annotationSpec.type().toString())
61+
.containsExactly(SortDefault.class.getTypeName(), Param.class.getTypeName());
5662
}
5763

5864
@Test // GH-3270
@@ -93,6 +99,6 @@ private interface DummyRepo {
9399

94100
String noArgsMethod();
95101

96-
String threeArgsMethod(Object arg0, Pageable arg1, @Param("foo") Object arg2);
102+
String threeArgsMethod(Object arg0, @SortDefault Pageable arg1, @SortDefault @Param("foo") Object arg2);
97103
}
98104
}

0 commit comments

Comments
 (0)