|
2 | 2 |
|
3 | 3 | import com.github.nylle.javafixture.annotations.testcases.TestCase; |
4 | 4 | import com.github.nylle.javafixture.annotations.testcases.TestWithCases; |
| 5 | +import com.github.nylle.javafixture.testobjects.ClassWithBuilder; |
5 | 6 | import com.github.nylle.javafixture.testobjects.ITestGeneric; |
6 | 7 | import com.github.nylle.javafixture.testobjects.TestAbstractClass; |
7 | 8 | import com.github.nylle.javafixture.testobjects.TestEnum; |
|
58 | 59 | import java.util.concurrent.LinkedTransferQueue; |
59 | 60 | import java.util.concurrent.TransferQueue; |
60 | 61 |
|
| 62 | +import static com.github.nylle.javafixture.CustomizationContext.noContext; |
61 | 63 | import static org.assertj.core.api.Assertions.assertThat; |
62 | 64 | import static org.assertj.core.api.Assertions.assertThatExceptionOfType; |
63 | 65 |
|
@@ -368,6 +370,35 @@ void takesAValueMapper() { |
368 | 370 | } |
369 | 371 | } |
370 | 372 |
|
| 373 | + @Nested |
| 374 | + class FindBuilders { |
| 375 | + |
| 376 | + @Test |
| 377 | + void returnsListOfBuilders() { |
| 378 | + var specimenFactory = new SpecimenFactory(new Context(new Configuration())); |
| 379 | + |
| 380 | + var sut = new SpecimenType<ClassWithBuilder>(){}; |
| 381 | + |
| 382 | + var actual = sut.findBuilders(); |
| 383 | + |
| 384 | + assertThat(actual).hasSize(1); |
| 385 | + assertThat(actual.get(0).invoke(specimenFactory, noContext())).isInstanceOf(ClassWithBuilder.class); |
| 386 | + } |
| 387 | + |
| 388 | + @TestWithCases |
| 389 | + @TestCase(class1 = TestObject.class) |
| 390 | + @TestCase(class1 = ITestGeneric.class) |
| 391 | + @TestCase(class1 = TestEnum.class) |
| 392 | + @TestCase(class1 = String.class) |
| 393 | + void returnsEmptyListIfNoBuildersFound(Class<?> typeWithoutBuilder) { |
| 394 | + var sut = SpecimenType.fromClass(typeWithoutBuilder); |
| 395 | + |
| 396 | + var actual = sut.findBuilders(); |
| 397 | + |
| 398 | + assertThat(actual).isEmpty(); |
| 399 | + } |
| 400 | + } |
| 401 | + |
371 | 402 | @Test |
372 | 403 | void getComponentType() { |
373 | 404 | assertThat(new SpecimenType<int[]>() {}.getComponentType()).isEqualTo(int.class); |
|
0 commit comments