Handle the case with no test data populators (#122)
Since there is no populator yet Spring fails when trying to inject since it does not support empty collections. Mark the dependency as optional until we have at least one populator at which point we can simply the code again. Reviewed-on: #122 Reviewed-by: Nico Athanassiadis <nico@dsv.su.se> Co-authored-by: Andreas Svanberg <andreass@dsv.su.se> Co-committed-by: Andreas Svanberg <andreass@dsv.su.se>
This commit is contained in:
parent
a76b317b1c
commit
17192f9eb9
@ -42,7 +42,7 @@ public class DataInitializer implements Lifecycle, BaseData, Factory {
|
||||
public static final long RESEARCH_AREA_ID = 12L;
|
||||
|
||||
@Inject
|
||||
private Collection<TestDataPopulator> testDataPopulators = new ArrayList<>();
|
||||
private Optional<Collection<TestDataPopulator>> testDataPopulators = Optional.empty();
|
||||
|
||||
@Inject
|
||||
private UserService userService;
|
||||
@ -123,7 +123,8 @@ public class DataInitializer implements Lifecycle, BaseData, Factory {
|
||||
createTarget();
|
||||
createStudentIdea();
|
||||
createRoughDraftApproval();
|
||||
for (TestDataPopulator testDataPopulator : testDataPopulators) {
|
||||
Collection<TestDataPopulator> availablePopulators = testDataPopulators.orElseGet(Collections::emptySet);
|
||||
for (TestDataPopulator testDataPopulator : availablePopulators) {
|
||||
testDataPopulator.populate(this, this);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user