Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ private T populate(CustomizationContext customizationContext) {
.build(SpecimenType.fromClass(field.getGenericType()))
.create(customizationContext.newForField(field.getName()), reflector.getFieldAnnotations(field)))));
} catch (SpecimenException ex) {
return context.overwrite(type, instanceFactory.construct(type, customizationContext));
context.overwrite(type, instanceFactory.construct(type, customizationContext));
}
return context.remove(type);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,17 @@ void createHashSetFromSetInterface() {
assertThat(actual.size()).isEqualTo(2);
}

@Test
void createSetWhenObjectIsCreatedWithConstructor() {
var sut = new CollectionSpecimen<>(new SpecimenType<Set<Throwable>>() {}, context, specimenFactory);

var actual = sut.create(noContext(), new Annotation[0]);

assertThat(actual).isInstanceOf(HashSet.class);
assertThat(actual.stream().allMatch(x -> x.getClass().equals(Throwable.class))).isTrue();
assertThat(actual.size()).isEqualTo(2);
}

@Test
void createLinkedBlockingDequeFromBlockingDequeInterface() {
var sut = new CollectionSpecimen<>(new SpecimenType<BlockingDeque<String>>() {}, context, specimenFactory);
Expand Down