Package com.kenshoo.pl.simulation
Class DualRunSimulator<E extends EntityType<E>>
- java.lang.Object
-
- com.kenshoo.pl.simulation.DualRunSimulator<E>
-
- Type Parameters:
E- EntityType
public class DualRunSimulator<E extends EntityType<E>> extends java.lang.ObjectThis utility helps to migrate from an old mutation code to Persistence Layer by running them side-by-side and compare their results. Terminology + ActualMutator - This is the old code. + Simulated - The persistence layer commands. Implementation This simulator runs both the old mutator along with the simulated commands (PL). However, the simulated commands run without DbOutputGenerator, meaning, they don't really affect the database. PL simulated commands only run enrichers, validators, etc. After the real (old) mutator changed the DB, we fetch the final state of the entities to compare the actual modification with the content of the simulated commands. Limitations + One-to-many relations: Child commands are not supported.
-
-
Constructor Summary
Constructors Constructor Description DualRunSimulator(PLContext plContext, ChangeFlowConfig.Builder<E> flowToSimulate, java.util.Collection<EntityField<E,?>> inspectedFields)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<ComparisonMismatch<E>>runCreation(UniqueKey<E> uniqueKey, ActualDatabaseMutator<E> databaseMutator, java.util.Collection<? extends CreateEntityCommand<E>> commandsToSimulate)Runs the real mutator and compares the actual DB affect with the values in the simulated commands.<ID extends Identifier<E>>
java.util.List<ComparisonMismatch<E>>runUpdate(ActualDatabaseMutator<E> databaseMutator, java.util.Collection<? extends UpdateEntityCommand<E,ID>> commandsToSimulate)
-
-
-
Constructor Detail
-
DualRunSimulator
public DualRunSimulator(PLContext plContext, ChangeFlowConfig.Builder<E> flowToSimulate, java.util.Collection<EntityField<E,?>> inspectedFields)
-
-
Method Detail
-
runCreation
public java.util.List<ComparisonMismatch<E>> runCreation(UniqueKey<E> uniqueKey, ActualDatabaseMutator<E> databaseMutator, java.util.Collection<? extends CreateEntityCommand<E>> commandsToSimulate)
Runs the real mutator and compares the actual DB affect with the values in the simulated commands. Correlating each simulated command to an actual affect is done by a unique key. The key doesn't have to be the primary key. It could be whatever unique key you want. But it must be populated in the simulation commands.- Parameters:
uniqueKey-databaseMutator-commandsToSimulate- - must contain values for the unique key.- Returns:
-
runUpdate
public <ID extends Identifier<E>> java.util.List<ComparisonMismatch<E>> runUpdate(ActualDatabaseMutator<E> databaseMutator, java.util.Collection<? extends UpdateEntityCommand<E,ID>> commandsToSimulate)
-
-