Package com.atlassian.bamboo.mockito
Class MockitoUtils
- java.lang.Object
-
- com.atlassian.bamboo.mockito.MockitoUtils
-
public final class MockitoUtils extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T extends Comparable<T>>
voidaddComparator(Comparable<T> mock, Comparator<T> comparator)
Add the supplied comparator to the mocked object.static <T extends Comparable<T>>
Comparator<T>hashCodeComparator()
Creates a comparator that compares identity hashcodes of the supplied objects.static @NotNull org.mockito.stubbing.Answer<Void>
nonReturningAnswer(@NotNull Consumer<org.mockito.invocation.InvocationOnMock> answer)
static org.mockito.stubbing.Answer<String>
returnsReversedString()
static void
setUpHibernateTemplate(@NotNull TransactionAndHibernateTemplate mock)
static void
setUpHibernateTemplate(@NotNull TransactionAndHibernateTemplate mock, @NotNull org.springframework.transaction.TransactionStatus transactionStatus, @NotNull org.hibernate.Session session, @NotNull Connection connection)
-
-
-
Method Detail
-
hashCodeComparator
public static <T extends Comparable<T>> Comparator<T> hashCodeComparator()
Creates a comparator that compares identity hashcodes of the supplied objects.
-
addComparator
public static <T extends Comparable<T>> void addComparator(Comparable<T> mock, Comparator<T> comparator)
Add the supplied comparator to the mocked object.
-
nonReturningAnswer
@NotNull public static @NotNull org.mockito.stubbing.Answer<Void> nonReturningAnswer(@NotNull @NotNull Consumer<org.mockito.invocation.InvocationOnMock> answer)
-
returnsReversedString
public static org.mockito.stubbing.Answer<String> returnsReversedString()
-
setUpHibernateTemplate
public static void setUpHibernateTemplate(@NotNull @NotNull TransactionAndHibernateTemplate mock, @NotNull @NotNull org.springframework.transaction.TransactionStatus transactionStatus, @NotNull @NotNull org.hibernate.Session session, @NotNull @NotNull Connection connection)
Set up mocked responses forTransactionAndHibernateTemplate
's methods (#doWork
,#execute
). Mocked responses will call the actual code passed to the methods (TransactionCallback
,HibernateCallback
,Work
).- Parameters:
mock
- mock of theTransactionAndHibernateTemplate
to set uptransactionStatus
- used forTransactionOperations.execute(TransactionCallback)
session
- used forTransactionAndHibernateTemplate.execute(HibernateCallback)
connection
- used forTransactionAndHibernateTemplate.doWork(Work)
-
setUpHibernateTemplate
public static void setUpHibernateTemplate(@NotNull @NotNull TransactionAndHibernateTemplate mock)
Set up mocked responses forTransactionAndHibernateTemplate
's methods (#doWork
,#execute
). Mocked responses will call the actual code passed to the methods (TransactionCallback
,HibernateCallback
,Work
).TransactionStatus
,Session
andConnection
instances will be mocked.- Parameters:
mock
- mock of theTransactionAndHibernateTemplate
to set up
-
-