Description
for fixture scripts, we can currently configure the MultipleExecutionStrategy as either IGNORE or EXECUTE, eg:
@Override public FixtureScriptsSpecification getSpecification() { return FixtureScriptsSpecification .builder(DomainAppFixtureScriptsSpecificationProvider.class) .with(FixtureScripts.MultipleExecutionStrategy.EXECUTE) .build(); }
The IGNORE is for using fixture scripts that combine both the "WHAT" and the "HOW" (a la Estatio):
ec.executeChild(this, new ImportEventsFromSpreadsheet()); ec.executeChild(this, new ImportPeopleFromSpreadsheet());
where:
static class ImportEventsFromSpreadsheet extends CreateUsingSpreadsheet<EventImport> { public ImportEventsFromSpreadsheet() { super(EventImport.class, "EventImport.xls"); } } static class ImportPeopleFromSpreadsheet extends CreateUsingSpreadsheet<PeopleImport> { public ImportPeopleFromSpreadsheet() { super(PeopleImport.class, "PeopleImportB.xls"); } }
The alternative is EXECUTE, which basically switches this behaviour off. That is appropriate for general purpose fixture scripts which take care of the "HOW", but where the "WHAT" is parameterized,
eg:
ec.executeChild(this, new CreateUsingSpreadsheet<>(EventImport.class, "EventImport.xls")); ec.executeChild(this, new CreateUsingSpreadsheet<>(PeopleImport.class, "PeopleImportB.xls"));
This ticket is to combine both approaches by using value-semantics rather than reference semantics, thus to ignore fixture scripts if invoked multiple times where "multiple times" is determine by invoking on equals(...) of the fixture script against all previously invoked fixture scripts.
thus, we would skip a fixture script if
ec.executeChild(this, new CreateUsingSpreadsheet<>(EventImport.class, "EventImport.xls")); // would invoke this: ec.executeChild(this, new CreateUsingSpreadsheet<>(SomethingElseImport.class, "SomethingElseImport.xls")); // but would skip this: ec.executeChild(this, new CreateUsingSpreadsheet<>(EventImport.class, "EventImport.xls"));