use of org.eclipse.scout.rt.platform.holders.BooleanHolder in project scout.rt by eclipse.
the class AbstractContextMenu method calculateLocalVisibility.
protected void calculateLocalVisibility() {
final IActionFilter activeFilter = ActionUtility.createMenuFilterMenuTypes(getCurrentMenuTypes(), true);
if (activeFilter != null) {
final BooleanHolder visibleHolder = new BooleanHolder(false);
acceptVisitor(new IActionVisitor() {
@Override
public int visit(IAction action) {
if (action instanceof IMenu) {
IMenu menu = (IMenu) action;
if (menu.hasChildActions() || menu.isSeparator() || menu instanceof IContextMenu) {
return CONTINUE;
} else if (activeFilter.accept(menu)) {
visibleHolder.setValue(true);
return CANCEL;
}
}
return CONTINUE;
}
});
setVisible(visibleHolder.getValue());
}
}
use of org.eclipse.scout.rt.platform.holders.BooleanHolder in project scout.rt by eclipse.
the class SessionDataTest method testComputeIfAbsent.
@Test
public void testComputeIfAbsent() {
final BooleanHolder computedHolder = new BooleanHolder();
Object value = m_sessionData.computeIfAbsent(TEST_KEY, new Callable<Object>() {
@Override
public Object call() throws Exception {
computedHolder.setValue(true);
return TEST_DATA;
}
});
assertSame(TEST_DATA, value);
assertSame(TEST_DATA, m_sessionData.get(TEST_KEY));
assertTrue(computedHolder.getValue());
}
use of org.eclipse.scout.rt.platform.holders.BooleanHolder in project scout.rt by eclipse.
the class JobListenerTest method testCancel.
@Test
public void testCancel() throws Exception {
JobEventCaptureListener captureListener = new JobEventCaptureListener();
Jobs.getJobManager().addListener(captureListener);
final BooleanHolder hasStarted = new BooleanHolder(Boolean.FALSE);
IFuture<Void> future = Jobs.getJobManager().schedule(new IRunnable() {
@Override
public void run() throws Exception {
hasStarted.setValue(Boolean.TRUE);
}
}, Jobs.newInput().withRunContext(RunContexts.empty()).withExecutionTrigger(Jobs.newExecutionTrigger().withStartIn(1, TimeUnit.HOURS)));
future.cancel(true);
Jobs.getJobManager().awaitDone(Jobs.newFutureFilterBuilder().andMatchFuture(future).toFilter(), 10, TimeUnit.SECONDS);
Jobs.getJobManager().shutdown();
// verify events
int i = -1;
List<JobEvent> capturedEvents = captureListener.getCapturedEvents();
List<JobState> capturedFutureStates = captureListener.getCapturedFutureStates();
i++;
assertStateChangedEvent(future, JobState.SCHEDULED, capturedEvents.get(i));
assertEquals(JobState.SCHEDULED, capturedFutureStates.get(i));
i++;
assertStateChangedEvent(future, JobState.PENDING, capturedEvents.get(i));
assertEquals(JobState.PENDING, capturedFutureStates.get(i));
i++;
assertStateChangedEvent(future, JobState.DONE, capturedEvents.get(i));
assertEquals(JobState.DONE, capturedFutureStates.get(i));
i++;
assertJobManagerShutdownEvent(capturedEvents.get(i));
assertNull(capturedFutureStates.get(i));
assertEquals(i + 1, capturedEvents.size());
}
use of org.eclipse.scout.rt.platform.holders.BooleanHolder in project scout.rt by eclipse.
the class SessionDataTest method testComputeIfAbsentReturningNull.
@Test
public void testComputeIfAbsentReturningNull() {
final BooleanHolder computedHolder = new BooleanHolder();
// 1. compute null value
Object value = m_sessionData.computeIfAbsent(TEST_KEY, new Callable<Object>() {
@Override
public Object call() throws Exception {
computedHolder.setValue(true);
return null;
}
});
assertNull(value);
assertTrue(computedHolder.getValue());
// 2. compute non-null value
computedHolder.setValue(false);
value = m_sessionData.computeIfAbsent(TEST_KEY, new Callable<Object>() {
@Override
public Object call() throws Exception {
computedHolder.setValue(true);
return TEST_DATA;
}
});
assertSame(TEST_DATA, value);
assertTrue(computedHolder.getValue());
}
use of org.eclipse.scout.rt.platform.holders.BooleanHolder in project scout.rt by eclipse.
the class InvocationContextTest method testInvokeNotWebMethod.
@Test
public void testInvokeNotWebMethod() {
final BooleanHolder intercepted = new BooleanHolder(false);
ServerRunContexts.copyCurrent().withCorrelationId(TESTING_CORRELATION_ID).run(new IRunnable() {
@Override
public void run() throws Exception {
InvocationContext<TestPort> invocationContext = new InvocationContext<>(m_port, "name");
invocationContext.withEndpointUrl("http://localhost");
invocationContext.whenInvoke(new InvocationHandler() {
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
intercepted.setValue(true);
return method.invoke(proxy, args);
}
});
// invoke method which is not annotated with @WebMethod
invocationContext.getPort().notWebMethod();
}
});
// only methods annotated with @WebMethod are intercepted
assertFalse(intercepted.getValue());
// correlationId is not propagated other than web methods
assertNull(m_port.getRequestContext().get(MessageContexts.PROP_CORRELATION_ID));
verify(m_port).notWebMethod();
}
Aggregations