Search in sources :

Example 1 with ControllerUnderTest

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

the class ToDoControllerTests method testElementStateSync.

@Test
public void testElementStateSync() {
    // given:
    ControllerUnderTest<ToDoList> controllerUnderTest = createController(TODO_CONTROLLER_NAME);
    ControllerUnderTest<ToDoList> controllerUnderTest2 = createController(TODO_CONTROLLER_NAME);
    // when:
    controllerUnderTest.getModel().getNewItemText().set("Banana");
    controllerUnderTest.invoke(ADD_ACTION);
    controllerUnderTest.invoke(CHANGE_ACTION, new Param(ITEM_PARAM, "Banana"));
    // then:
    Assert.assertEquals(controllerUnderTest2.getModel().getItems().size(), 1);
    Assert.assertEquals(controllerUnderTest2.getModel().getItems().get(0).isCompleted(), true);
}
Also used : ToDoList(com.canoo.platform.samples.distribution.common.model.ToDoList) Param(com.canoo.platform.remoting.client.Param) 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 2 with ControllerUnderTest

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

the class ToDoControllerTests method testChangeElementState.

@Test
public void testChangeElementState() {
    // given:
    ControllerUnderTest<ToDoList> controllerUnderTest = createController(TODO_CONTROLLER_NAME);
    // when:
    controllerUnderTest.getModel().getNewItemText().set("Banana");
    controllerUnderTest.invoke(ADD_ACTION);
    controllerUnderTest.invoke(CHANGE_ACTION, new Param(ITEM_PARAM, "Banana"));
    // then:
    Assert.assertEquals(controllerUnderTest.getModel().getItems().get(0).isCompleted(), true);
}
Also used : ToDoList(com.canoo.platform.samples.distribution.common.model.ToDoList) Param(com.canoo.platform.remoting.client.Param) 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 3 with ControllerUnderTest

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

the class ToDoControllerTests method testDeleteElement.

@Test
public void testDeleteElement() {
    // given:
    ControllerUnderTest<ToDoList> controllerUnderTest = createController(TODO_CONTROLLER_NAME);
    // when:
    controllerUnderTest.getModel().getNewItemText().set("Banana");
    controllerUnderTest.invoke(ADD_ACTION);
    controllerUnderTest.invoke(REMOVE_ACTION, new Param(ITEM_PARAM, "Banana"));
    // then:
    Assert.assertEquals(controllerUnderTest.getModel().getItems().size(), 0);
}
Also used : ToDoList(com.canoo.platform.samples.distribution.common.model.ToDoList) Param(com.canoo.platform.remoting.client.Param) 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 4 with ControllerUnderTest

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

the class RunLaterControllerTest method testRunLaterInPostConstruct.

@Test
public void testRunLaterInPostConstruct() {
    // given:
    final ControllerUnderTest<RunLaterTestBean> controller = createController(RUN_LATER_CONTROLLER_NAME);
    final RunLaterTestBean model = controller.getModel();
    // then
    Assert.assertNotNull(model.getPostConstructPreRunLaterCallIndex());
    Assert.assertNotNull(model.getPostConstructRunLaterCallIndex());
    Assert.assertNotNull(model.getPostConstructPostRunLaterCallIndex());
    Assert.assertTrue(model.getPostConstructPreRunLaterCallIndex() > 0);
    Assert.assertTrue(model.getPostConstructRunLaterCallIndex() > 0);
    Assert.assertTrue(model.getPostConstructPostRunLaterCallIndex() > 0);
    Assert.assertTrue(model.getPostConstructPreRunLaterCallIndex() < model.getPostConstructPostRunLaterCallIndex());
    Assert.assertTrue(model.getPostConstructPostRunLaterCallIndex() < model.getPostConstructRunLaterCallIndex());
}
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 5 with ControllerUnderTest

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

the class ToDoControllerTests method testElementDeleteSync.

@Test
public void testElementDeleteSync() {
    // given:
    ControllerUnderTest<ToDoList> controllerUnderTest = createController(TODO_CONTROLLER_NAME);
    ControllerUnderTest<ToDoList> controllerUnderTest2 = createController(TODO_CONTROLLER_NAME);
    // when:
    controllerUnderTest.getModel().getNewItemText().set("Banana");
    controllerUnderTest.invoke(ADD_ACTION);
    controllerUnderTest.invoke(REMOVE_ACTION, new Param(ITEM_PARAM, "Banana"));
    // then:
    Assert.assertEquals(controllerUnderTest2.getModel().getItems().size(), 0);
}
Also used : ToDoList(com.canoo.platform.samples.distribution.common.model.ToDoList) Param(com.canoo.platform.remoting.client.Param) 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