Search in sources :

Example 1 with InteractionMock

use of org.malai.interaction.InteractionMock in project Malai by arnobl.

the class TestInteractor method setUp.

@BeforeEach
public void setUp() {
    instrument = new StubInstrument() {

        @Override
        protected void configureBindings() {
            TestInteractor.this.interactor = new StubInteractor(instrument, false, CommandImplStub.class, new InteractionMock());
            addBinding(interactor);
        }
    };
    instrument.setActivated(true);
    ErrorCatcher.INSTANCE.setNotifier(exception -> fail(exception.toString()));
}
Also used : InteractionMock(org.malai.interaction.InteractionMock) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with InteractionMock

use of org.malai.interaction.InteractionMock in project Malai by arnobl.

the class TestInteractor method testInteractionStartsOkCauseOfTheNonPublicAction.

@Test
void testInteractionStartsOkCauseOfTheNonPublicAction() throws CancelFSMException {
    final boolean[] ok = { false };
    ErrorCatcher.INSTANCE.setNotifier(exception -> ok[0] = true);
    StubInstrument ins = new StubInstrument();
    WidgetBinding interactor2 = new WidgetBindingImpl<CommandImplStub2, InteractionMock, StubInstrument>(ins, false, CommandImplStub2.class, new InteractionMock()) {

        @Override
        public void first() {
        }

        @Override
        public boolean when() {
            return true;
        }

        @Override
        protected void executeCmdAsync(final Command cmd) {
        }
    };
    ins.setActivated(true);
    interactor2.fsmStarts();
    assertTrue(ok[0]);
    assertNull(interactor.getCommand());
}
Also used : WidgetBinding(org.malai.binding.WidgetBinding) InteractionMock(org.malai.interaction.InteractionMock) WidgetBindingImpl(org.malai.binding.WidgetBindingImpl) Command(org.malai.command.Command) Test(org.junit.jupiter.api.Test)

Example 3 with InteractionMock

use of org.malai.interaction.InteractionMock in project Malai by arnobl.

the class TestInteractor method testInteractionStartsOkCauseOfTheNonPublicAction2.

@Test
void testInteractionStartsOkCauseOfTheNonPublicAction2() throws CancelFSMException {
    final boolean[] ok = { false };
    ErrorCatcher.INSTANCE.setNotifier(exception -> ok[0] = true);
    StubInstrument ins = new StubInstrument();
    WidgetBinding interactor2 = new WidgetBindingImpl<CommandImplStub3, InteractionMock, StubInstrument>(ins, false, CommandImplStub3.class, new InteractionMock()) {

        @Override
        public void first() {
        }

        @Override
        public boolean when() {
            return true;
        }

        @Override
        protected void executeCmdAsync(final Command cmd) {
        }
    };
    ins.setActivated(true);
    interactor2.fsmStarts();
    assertTrue(ok[0]);
    assertNull(interactor2.getCommand());
}
Also used : WidgetBinding(org.malai.binding.WidgetBinding) InteractionMock(org.malai.interaction.InteractionMock) WidgetBindingImpl(org.malai.binding.WidgetBindingImpl) Command(org.malai.command.Command) Test(org.junit.jupiter.api.Test)

Aggregations

InteractionMock (org.malai.interaction.InteractionMock)3 Test (org.junit.jupiter.api.Test)2 WidgetBinding (org.malai.binding.WidgetBinding)2 WidgetBindingImpl (org.malai.binding.WidgetBindingImpl)2 Command (org.malai.command.Command)2 BeforeEach (org.junit.jupiter.api.BeforeEach)1