@DefaultNonNull public class TestDataContextMock extends TestDataContextStub
| Modifier and Type | Class and Description |
|---|---|
static interface |
TestDataContextMock.ISavedObjectDecorator
Adds custom data decoration for objects that are being 'saved' inside mock context.
|
| Constructor and Description |
|---|
TestDataContextMock(TestDataContextMock.ISavedObjectDecorator onSaveCallback) |
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Clears accumulated list of inserted/deleted objects.
|
void |
delete(Object o)
Cause the object to be deleted from the database.
|
<T> T |
find(Class<T> clz,
Object pk)
Load the persistent object with the specified type and primary key from the database.
|
<T> T |
get(Class<T> clz,
Object pk)
Load the persistent object with the specified type and primary key from the database.
|
<T> List<T> |
getDeleted(Class<T> type) |
<T> List<T> |
getInserted(Class<T> type) |
<T> T |
getInstance(Class<T> clz,
Object pk)
Load the persistent object with the specified type and primary key from the database.
|
protected <T> T |
processQueryOneTestId(String testId) |
protected <T> List<T> |
processQueryTestId(String testId) |
protected Object[] |
processSelectionOneTestId(String testId) |
protected List<Object[]> |
processSelectionTestId(String testId) |
<T> List<T> |
query(QCriteria<T> q)
Execute the query specified by q and return a list of results.
|
List<Object[]> |
query(QSelection<?> sel)
Issue a selection query, where multiple fields or projections on fields are selected from a base class.
|
<T> T |
queryOne(QCriteria<T> q)
Execute the query specified by q, and expect and return at most 1 result.
|
Object[] |
queryOne(QSelection<?> sel)
Execute the selection query specified by q, and expect and return at most 1 result.
|
void |
registerQuery(boolean override,
String testId,
List<?> criteriaResult)
Enables specifying fallback testId mocks, only in case when previously it is not defined.
|
void |
registerQuery(String testId,
List<?> criteriaResult) |
void |
registerQueryOne(boolean override,
String testId,
Object queryOneResult)
Enables specifying fallback testId mocks, only in case when previously it is not defined.
|
void |
registerQueryOne(String testId,
Object queryOneResult) |
void |
registerSelection(boolean override,
String testId,
List<Object[]> selectionResult)
Enables specifying fallback testId mocks, only in case when previously it is not defined.
|
void |
registerSelection(String testId,
List<Object[]> selectionResult) |
void |
registerSelectionOne(boolean override,
String testId,
Object... selectionResult)
Enables specifying fallback testId mocks, only in case when previously it is not defined.
|
void |
registerSelectionOne(String testId,
Object... selectionResult) |
void |
save(Object o)
Cause the object to be inserted in the database.
|
addCommitAction, addListener, attach, close, commit, decrement, find, getConnection, getFactory, getInstance, inTransaction, original, query, queryOne, refresh, rollback, setIgnoreClose, setKeepOriginals, startTransaction, testGetUseCountpublic static final String NULL
public TestDataContextMock(@Nullable TestDataContextMock.ISavedObjectDecorator onSaveCallback)
public void save(Object o) throws Exception
QDataContextsave in interface QDataContextsave in class TestDataContextStubExceptionpublic void delete(Object o) throws Exception
QDataContextdelete in interface QDataContextdelete in class TestDataContextStubException@Nonnull public <T> T get(@Nonnull Class<T> clz, @Nonnull Object pk) throws Exception
QDataContextQNotFoundException.get in interface QDataContextget in class TestDataContextStubT - The object type.clz - The persistent class for which an instance is being sought.pk - The PK for the instance required.Exception@Nonnull public <T> T getInstance(@Nonnull Class<T> clz, @Nonnull Object pk) throws Exception
QDataContextQDataContext.find(Class, Object).getInstance in interface QDataContextgetInstance in class TestDataContextStubT - The object typeclz - The persistent class for which an instance is being sought.pk - The PK for the instance required.Exception@Nullable public <T> T find(@Nonnull Class<T> clz, @Nonnull Object pk) throws Exception
QDataContextfind in interface QDataContextfind in class TestDataContextStubT - The object type.clz - The persistent class for which an instance is being sought.pk - The PK for the instance required.Exceptionpublic List<Object[]> query(QSelection<?> sel) throws Exception
QDataContextquery in interface QDataContextquery in class TestDataContextStubExceptionpublic <T> List<T> query(QCriteria<T> q) throws Exception
QDataContextquery in interface QDataContextquery in class TestDataContextStubT - The return type for this query, a persistent class typeq - The selection criteriaException@Nullable public <T> T queryOne(@Nonnull QCriteria<T> q) throws Exception
QDataContextqueryOne in interface QDataContextqueryOne in class TestDataContextStubException@Nullable public Object[] queryOne(@Nonnull QSelection<?> sel) throws Exception
QDataContextqueryOne in interface QDataContextqueryOne in class TestDataContextStubExceptionpublic void registerQuery(boolean override,
String testId,
List<?> criteriaResult)
override - when T - overrides already existing mocks, otherwise keep existing value.testId - criteriaResult - public void registerSelection(boolean override,
String testId,
List<Object[]> selectionResult)
override - when T - overrides already existing mocks, otherwise keep existing value.testId - selectionResult - public void registerQueryOne(boolean override,
String testId,
@Nullable
Object queryOneResult)
override - when T - overrides already existing mocks, otherwise keep existing value.testId - queryOneResult - public void registerSelectionOne(String testId, @Nullable Object... selectionResult)
public void registerSelectionOne(boolean override,
String testId,
@Nullable
Object... selectionResult)
override - when T - overrides already existing mocks, otherwise keep existing value.testId - selectionResult - public void clear()
Copyright © 2017 etc.to. All rights reserved.