Search in sources :

Example 1 with CommunicationMonitor

use of com.canoo.platform.spring.test.CommunicationMonitor in project dolphin-platform by canoo.

the class RunLaterControllerTest method testRunLaterAsyncInAction.

@Test
public void testRunLaterAsyncInAction() throws Exception {
    // given:
    final ControllerUnderTest<RunLaterTestBean> controller = createController(RUN_LATER_CONTROLLER_NAME);
    final RunLaterTestBean model = controller.getModel();
    final CommunicationMonitor monitor = controller.createMonitor();
    model.actionRunLaterAsyncCallIndexProperty().onChanged(e -> {
        monitor.signal();
    });
    // when:
    controller.invoke(RUN_LATER_ASYNC_ACTION_NAME);
    monitor.await(10, TimeUnit.SECONDS);
    // then:
    Assert.assertNotNull(model.getActionPreRunLaterAsyncCallIndex());
    Assert.assertNotNull(model.getActionRunLaterAsyncCallIndex());
    Assert.assertNotNull(model.getActionPostRunLaterAsyncCallIndex());
    Assert.assertTrue(model.getActionPreRunLaterAsyncCallIndex() > 0);
    Assert.assertTrue(model.getActionRunLaterAsyncCallIndex() > 0);
    Assert.assertTrue(model.getActionPostRunLaterAsyncCallIndex() > 0);
    Assert.assertTrue(model.getActionPreRunLaterAsyncCallIndex() < model.getActionPostRunLaterAsyncCallIndex());
    Assert.assertTrue(model.getActionPostRunLaterAsyncCallIndex() < model.getActionRunLaterAsyncCallIndex());
}
Also used : CommunicationMonitor(com.canoo.platform.spring.test.CommunicationMonitor) RunLaterTestBean(com.canoo.dolphin.integration.runlater.RunLaterTestBean) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) SpringTestNGControllerTest(com.canoo.platform.spring.test.SpringTestNGControllerTest) Test(org.testng.annotations.Test) ControllerUnderTest(com.canoo.platform.spring.test.ControllerUnderTest)

Aggregations

RunLaterTestBean (com.canoo.dolphin.integration.runlater.RunLaterTestBean)1 CommunicationMonitor (com.canoo.platform.spring.test.CommunicationMonitor)1 ControllerUnderTest (com.canoo.platform.spring.test.ControllerUnderTest)1 SpringTestNGControllerTest (com.canoo.platform.spring.test.SpringTestNGControllerTest)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1 Test (org.testng.annotations.Test)1