use of org.eclipse.scout.rt.platform.holders.Holder in project scout.rt by eclipse.
the class SelectIntoArrayTest method testSelectIntoListInHolder.
@Test
public void testSelectIntoListInHolder() throws Exception {
SqlServiceMock sql = createSqlServiceMock(ROLES_DATA);
//
Holder<List> rolesHolder = new Holder<List>(List.class);
sql.selectInto("SELECT ROLE_NR FROM USER_ROLE WHERE USER_NR = :personNr INTO :{roles}", new NVPair("personNr", 63L), new NVPair("roles", rolesHolder));
List r = rolesHolder.getValue();
assertNotNull(r);
assertEquals(3, r.size());
assertEquals("first role", 3L, r.get(0));
assertEquals("second role", 5L, r.get(1));
assertEquals("third role", 7L, r.get(2));
}
use of org.eclipse.scout.rt.platform.holders.Holder in project scout.rt by eclipse.
the class AbstractDesktopTest method testDataChangedSimple.
@Test
public void testDataChangedSimple() {
TestEnvironmentDesktop desktop = (TestEnvironmentDesktop) IDesktop.CURRENT.get();
final Holder<Object[]> resultHolder = new Holder<Object[]>(Object[].class);
desktop.addDataChangeListener(new DataChangeListener() {
@Override
public void dataChanged(Object... dataTypes) {
resultHolder.setValue(dataTypes);
}
}, TEST_DATA_TYPE_1, TEST_DATA_TYPE_2);
desktop.dataChanged(TEST_DATA_TYPE_1, TEST_DATA_TYPE_2);
verifyDataChanged(resultHolder);
}
use of org.eclipse.scout.rt.platform.holders.Holder in project scout.rt by eclipse.
the class TransactionProcessorTest method testRequiresNewWithoutExistingTransactionAndSuccess.
@Test
public void testRequiresNewWithoutExistingTransactionAndSuccess() throws Exception {
final Holder<ITransaction> actualTransaction = new Holder<>();
CallableChain<Object> chain = new CallableChain<>();
chain.add(new TransactionProcessor<Object>().withCallerTransaction(null).withTransactionScope(TransactionScope.REQUIRES_NEW));
Object result = chain.call(new Callable<Object>() {
@Override
public Object call() throws Exception {
actualTransaction.setValue(ITransaction.CURRENT.get());
return "result";
}
});
// verify
assertSame(m_transaction, actualTransaction.getValue());
assertEquals("result", result);
verify(m_transaction, times(1)).release();
InOrder inOrder = Mockito.inOrder(m_transaction);
inOrder.verify(m_transaction, times(1)).commitPhase1();
inOrder.verify(m_transaction, times(1)).commitPhase2();
inOrder.verify(m_transaction, never()).rollback();
inOrder.verify(m_transaction, times(1)).release();
}
use of org.eclipse.scout.rt.platform.holders.Holder in project scout.rt by eclipse.
the class TransactionProcessorTest method testRequiresNewWithExistingTransactionAndSuccess.
@Test
public void testRequiresNewWithExistingTransactionAndSuccess() throws Exception {
ITransaction callingTransaction = mock(ITransaction.class);
final Holder<ITransaction> actualTransaction = new Holder<>();
CallableChain<Object> chain = new CallableChain<>();
chain.add(new TransactionProcessor<Object>().withCallerTransaction(callingTransaction).withTransactionScope(TransactionScope.REQUIRES_NEW));
Object result = chain.call(new Callable<Object>() {
@Override
public Object call() throws Exception {
actualTransaction.setValue(ITransaction.CURRENT.get());
return "result";
}
});
// verify
assertSame(m_transaction, actualTransaction.getValue());
assertEquals("result", result);
verifyZeroInteractions(callingTransaction);
verify(m_transaction, times(1)).release();
InOrder inOrder = Mockito.inOrder(m_transaction);
inOrder.verify(m_transaction, times(1)).commitPhase1();
inOrder.verify(m_transaction, times(1)).commitPhase2();
inOrder.verify(m_transaction, never()).rollback();
inOrder.verify(m_transaction, times(1)).release();
}
use of org.eclipse.scout.rt.platform.holders.Holder in project scout.rt by eclipse.
the class TransactionProcessorTest method testRequiredWithoutExistingTransactionAndSuccess.
@Test
public void testRequiredWithoutExistingTransactionAndSuccess() throws Exception {
final Holder<ITransaction> actualTransaction = new Holder<>();
CallableChain<Object> chain = new CallableChain<>();
chain.add(new TransactionProcessor<Object>().withCallerTransaction(null).withTransactionScope(TransactionScope.REQUIRED));
Object result = chain.call(new Callable<Object>() {
@Override
public Object call() throws Exception {
actualTransaction.setValue(ITransaction.CURRENT.get());
return "result";
}
});
// verify
assertEquals("result", result);
assertSame(m_transaction, actualTransaction.getValue());
verify(m_transaction, times(1)).release();
InOrder inOrder = Mockito.inOrder(m_transaction);
inOrder.verify(m_transaction, times(1)).commitPhase1();
inOrder.verify(m_transaction, times(1)).commitPhase2();
inOrder.verify(m_transaction, never()).rollback();
inOrder.verify(m_transaction, times(1)).release();
}
Aggregations