public AppResponse startFlow(String flowName, Action action, AppRequest request) throws FlowNotDefinedException, NoSuchAlgorithmException, IOException, FlowStateNotDefinedException, SharedServiceClientException {
        Flow flow =  flowFactoryFactory.getFactory(ActivationFlowFactory.TYPE).getFlow(flowName);
        AbstractFlowStep flowStep =  flowFactoryFactory.getFactory(ActivationFlowFactory.TYPE).getStep(action);
        AppResponse appResponse = flow.processState(flowStep, request);

        if (appResponse instanceof NokResponse || !flowStep.isValid()) {
            return appResponse;
        }

        AppSession appSession = flowStep.getAppSession();

        appSession.setState(getStateName(flow.getNextState(State.valueOf(appSession.getState().toUpperCase()), action)));
        appSessionService.save(appSession);

        return appResponse;
    }
@Test
    void startFlowTest() throws FlowNotDefinedException, FlowStateNotDefinedException, IOException, NoSuchAlgorithmException, SharedServiceClientException {
        AppSession appSession = new AppSession();
        appSession.setState(State.INITIALIZED.name());

        AbstractFlowStep flowStep = mock(AbstractFlowStep.class);

        Flow flow = mock(Flow.class);

        when(flowFactoryFactory.getFactory(any())).thenReturn(flowFactory);
        when(flowFactory.getFlow(any())).thenReturn(flow);
        when(flowStep.getAppSession()).thenReturn(appSession);
        when(flowFactory.getStep(any())).thenReturn(flowStep);
        when(flow.getNextState(any(), any())).thenReturn(State.PASSWORD_CONFIRMED);
        when(flow.processState(any(), any())).thenReturn(new OkResponse());
        when(flowStep.isValid()).thenReturn(true);

        AppResponse result = flowService.startFlow(UndefinedFlow.NAME, Action.CONFIRM_PASSWORD, new ActivationUsernamePasswordRequest());

        assertEquals(State.PASSWORD_CONFIRMED.name(), appSession.getState());
        assertEquals(null, appSession.getFlow()); // nl.logius.digid.app.domain.shared.flow is set within steps
        assertTrue(result instanceof OkResponse);
    }