Search in sources :

Example 11 with RoboSystem

use of com.robo4j.core.RoboSystem in project robo4j by Robo4J.

the class SchedulePeriodUnitTest method basicScheudlePeriodUnitTest.

@Test
public void basicScheudlePeriodUnitTest() throws ConfigurationException {
    RoboSystem system = new RoboSystem();
    Configuration config = ConfigurationFactory.createEmptyConfiguration();
    SchedulePeriodUnit unit = new SchedulePeriodUnit(system, "schedulePeriodUnit");
    config.setString("unit", "test");
    config.setInteger("delay", 1);
    config.setInteger("period", 1);
    config.setString("timeUnit", "SECONDS");
    unit.initialize(config);
    Assert.assertTrue(unit.getState().equals(LifecycleState.INITIALIZED));
}
Also used : RoboSystem(com.robo4j.core.RoboSystem) Configuration(com.robo4j.core.configuration.Configuration) Test(org.junit.Test)

Example 12 with RoboSystem

use of com.robo4j.core.RoboSystem in project robo4j by Robo4J.

the class SimpleTankUnitTests method simpleTankUnitMockTest.

@Test
public void simpleTankUnitMockTest() throws Exception {
    RoboSystem system = new RoboSystem();
    SimpleTankUnitMock tank = new SimpleTankUnitMock(system, "tank");
    Configuration config = ConfigurationFactory.createEmptyConfiguration();
    tank.onInitialization(config);
    DefaultAttributeDescriptor<Boolean> descriptor = DefaultAttributeDescriptor.create(Boolean.class, "getStatus");
    tank.onMessage(new LegoPlatformMessage("right"));
    tank.onMessage(new LegoPlatformMessage("left"));
    tank.onMessage(new LegoPlatformMessage("move"));
    tank.onMessage(new LegoPlatformMessage("back"));
    tank.onMessage(new LegoPlatformMessage("stop"));
    Assert.assertTrue(tank.getAttribute(descriptor).get());
    tank.shutdown();
}
Also used : RoboSystem(com.robo4j.core.RoboSystem) Configuration(com.robo4j.core.configuration.Configuration) LegoPlatformMessage(com.robo4j.units.lego.platform.LegoPlatformMessage) Test(org.junit.Test)

Aggregations

RoboSystem (com.robo4j.core.RoboSystem)12 Configuration (com.robo4j.core.configuration.Configuration)9 Test (org.junit.Test)8 HttpCommandTestController (com.robo4j.core.httpunit.test.HttpCommandTestController)3 StringConsumer (com.robo4j.core.StringConsumer)2 Robo4JSystem (com.robo4j.db.sql.model.Robo4JSystem)2 RoboEntity (com.robo4j.db.sql.model.RoboEntity)2 List (java.util.List)2 StringProducer (com.robo4j.core.StringProducer)1 HttpServerUnit (com.robo4j.core.httpunit.HttpServerUnit)1 Robo4JUnit (com.robo4j.db.sql.model.Robo4JUnit)1 LcdTestUnit (com.robo4j.units.lego.LcdTestUnit)1 SimpleTankTestUnit (com.robo4j.units.lego.SimpleTankTestUnit)1 LegoPlatformMessage (com.robo4j.units.lego.platform.LegoPlatformMessage)1