@Override
    public AppResponse process(Flow flow, SessionDataRequest request) throws SharedServiceClientException {

        return validateAmountOfApps(flow, appSession.getAccountId(), request)
            .orElseGet(() -> validateSms(flow, appSession.getAccountId(), request.getSmscode())
                .orElseGet(() -> confirmSession(flow, request)));
    }
@Test
    void processValidateAmountOfAppsTooManyDevices() throws SharedServiceClientException {
        AppAuthenticator oldApp = new AppAuthenticator();
        oldApp.setDeviceName("test_device");
        oldApp.setLastSignInAt(ZonedDateTime.now());

        when(sharedServiceClientMock.getSSConfigInt("Maximum_aantal_DigiD_apps_eindgebruiker")).thenReturn(5);
        when(appAuthenticatorService.countByAccountIdAndInstanceIdNot(ACCOUNT_ID, SESSION_DATA_REQUEST_INSTANCE_ID)).thenReturn(6);
        when(appAuthenticatorService.findLeastRecentApp(anyLong())).thenReturn(oldApp);

        AppResponse appResponse = sessionConfirmed.process(mockedActivateAppWithOtherAppFlow, mockedSessionDataRequest);

        assertTrue(appResponse instanceof TooManyAppsResponse);
        assertEquals(TOO_MANY_ACTIVE, ((TooManyAppsResponse) appResponse).getError());
        assertEquals("test_device", ((TooManyAppsResponse) appResponse).getDeviceName());
    }