Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange hook method invocation #16

Open
vania-pooh opened this issue Dec 22, 2016 · 1 comment
Open

Strange hook method invocation #16

vania-pooh opened this issue Dec 22, 2016 · 1 comment

Comments

@vania-pooh
Copy link
Member

This test fails:

package ru.yandex.qatools.fsm.impl;

import org.junit.Before;
import org.junit.Test;
import ru.yandex.qatools.fsm.FSMException;
import ru.yandex.qatools.fsm.Yatomata;
import ru.yandex.qatools.fsm.annotations.FSM;
import ru.yandex.qatools.fsm.annotations.OnTransit;
import ru.yandex.qatools.fsm.annotations.Transit;
import ru.yandex.qatools.fsm.annotations.Transitions;
import ru.yandex.qatools.fsm.beans.TestFailedState;
import ru.yandex.qatools.fsm.beans.TestStartedState;
import ru.yandex.qatools.fsm.beans.TestState;
import ru.yandex.qatools.fsm.beans.UndefinedState;

import static org.mockito.Mockito.*;

public class TransitFromParentClassTest {

    @FSM(start = UndefinedState.class)
    @Transitions({
            @Transit(from = TestState.class, to = TestFailedState.class, on = TestFailedState.class),
    })
    public interface TransitFromBaseClassFSM {

        @OnTransit
        void onTestStarted(TestStartedState event);
        
        @OnTransit
        void onTestFailed(TestState state, TestFailedState event);

    }

    private TransitFromBaseClassFSM fsm;
    private Yatomata<TransitFromBaseClassFSM> engine;

    @Before
    public void init() throws FSMException {
        fsm = mock(TransitFromBaseClassFSM.class);
        engine = new YatomataImpl<>(TransitFromBaseClassFSM.class, fsm, new TestStartedState());
    }

    @Test
    public void testEvents() {
        TestFailedState event = new TestFailedState();
        engine.fire(event);
        verify(fsm, never()).onTestStarted(any(TestStartedState.class));
        verify(fsm).onTestFailed(any(TestState.class), any(TestFailedState.class));
        verifyNoMoreInteractions(fsm);
    }
}
@vania-pooh
Copy link
Member Author

@smecsia ping.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant