|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.ninja_squad.dbsetup.DbSetup
public final class DbSetup
Allows executing a sequence of database operations. This object is reusable, and can thus be used several times to launch the same sequence of database operations. Here's a typical usage scenario in a unit test:
@Before
public void setUp() throws Exception {
Operation operation =
Operations.sequenceOf(
CommonOperations.DELETE_ALL,
CommonOperations.INSERT_REFERENCE_DATA,
Operations.insertInto("CLIENT")
.columns("CLIENT_ID", "FIRST_NAME", "LAST_NAME", "DATE_OF_BIRTH", "COUNTRY_ID")
.values(1L, "John", "Doe", "1975-07-19", 1L)
.values(2L, "Jack", "Smith", "1969-08-22", 2L)
.build());
DbSetup dbSetup = new DbSetup(new DataSourceDestination(dataSource), operation);
dbSetup.launch();
}
In the above code, CommonOperations.DELETE_ALL and CommonOperations.INSERT_REFERENCE_DATA
are operations shared by multiple test classes.
Note that, to speed up test executions, a DbSetupTracker can be used, at the price of a slightly
bigger complexity.
| Constructor Summary | |
|---|---|
DbSetup(Destination destination,
Operation operation)
Constructor which uses the default binder configuration. |
|
DbSetup(Destination destination,
Operation operation,
BinderConfiguration binderConfiguration)
Constructor allowing to use a custom BinderConfiguration. |
|
| Method Summary | |
|---|---|
boolean |
equals(java.lang.Object obj)
|
int |
hashCode()
|
void |
launch()
Executes the sequence of operations. |
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public DbSetup(@Nonnull
Destination destination,
@Nonnull
Operation operation)
default binder configuration.
destination - the destination of the sequence of database operationsoperation - the operation to execute (most of the time, an instance of
CompositeOperation
public DbSetup(@Nonnull
Destination destination,
@Nonnull
Operation operation,
@Nonnull
BinderConfiguration binderConfiguration)
BinderConfiguration.
destination - the destination of the sequence of database operationsoperation - the operation to execute (most of the time, an instance of
CompositeOperationbinderConfiguration - the binder configuration to use.| Method Detail |
|---|
public void launch()
public java.lang.String toString()
toString in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object obj)
equals in class java.lang.Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||