Search in sources :

Example 6 with ControllerUnderTest

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

the class RunLaterControllerTest method testRunLaterInAction.

@Test
public void testRunLaterInAction() {
    // given:
    final ControllerUnderTest<RunLaterTestBean> controller = createController(RUN_LATER_CONTROLLER_NAME);
    final RunLaterTestBean model = controller.getModel();
    // when:
    controller.invoke(RUN_LATER_ACTION_NAME);
    // then:
    Assert.assertNotNull(model.getActionPreRunLaterCallIndex());
    Assert.assertNotNull(model.getActionRunLaterCallIndex());
    Assert.assertNotNull(model.getActionPostRunLaterCallIndex());
    Assert.assertTrue(model.getActionPreRunLaterCallIndex() > 0);
    Assert.assertTrue(model.getActionRunLaterCallIndex() > 0);
    Assert.assertTrue(model.getActionPostRunLaterCallIndex() > 0);
    Assert.assertTrue(model.getActionPreRunLaterCallIndex() < model.getActionPostRunLaterCallIndex());
    Assert.assertTrue(model.getActionPostRunLaterCallIndex() < model.getActionRunLaterCallIndex());
}
Also used : 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)

Example 7 with ControllerUnderTest

use of com.canoo.platform.spring.test.ControllerUnderTest 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

ControllerUnderTest (com.canoo.platform.spring.test.ControllerUnderTest)7 SpringTestNGControllerTest (com.canoo.platform.spring.test.SpringTestNGControllerTest)7 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)7 Test (org.testng.annotations.Test)7 Param (com.canoo.platform.remoting.client.Param)4 ToDoList (com.canoo.platform.samples.distribution.common.model.ToDoList)4 RunLaterTestBean (com.canoo.dolphin.integration.runlater.RunLaterTestBean)3 CommunicationMonitor (com.canoo.platform.spring.test.CommunicationMonitor)1