Skip to content

Strange hook method invocation #16

@vania-pooh

Description

@vania-pooh

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);
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions