@Override
    public AppResponse process(Flow flow, ActivationWithCodeRequest body) {
        var authAppSession = appSessionService.getSession(body.getAuthSessionId());

        if (!State.AUTHENTICATED.name().equals(authAppSession.getState())){
            return new NokResponse();
        }

        appSession = new AppSession();
        appSession.setState(State.INITIALIZED.name());
        appSession.setFlow(body.isReRequestLetter() ? ReApplyActivateActivationCode.NAME : ActivateAccountAndAppFlow.NAME);
        appSession.setActivationMethod(ActivationMethod.LETTER);
        appSession.setAction(body.isReRequestLetter() ? "re_request_letter" : "activation_by_letter");

        AppAuthenticator appAuthenticator = appAuthenticatorService.findByUserAppId(body.getUserAppId());

        appSession.setAccountId(appAuthenticator.getAccountId());
        appSession.setUserAppId(appAuthenticator.getUserAppId());
        appSession.setDeviceName(appAuthenticator.getDeviceName());
        appSession.setInstanceId(appAuthenticator.getInstanceId());

        Map<String, String> result = digidClient.getRegistrationByAccount(appAuthenticator.getAccountId());

        if (!result.get(lowerUnderscore(STATUS)).equals("OK"))
            return new NokResponse();

        var registrationId = result.get(lowerUnderscore(REGISTRATION_ID));
        if (registrationId != null) {
            appSession.setRegistrationId(Long.valueOf(registrationId));
        }

        appSession.setWithBsn(Boolean.valueOf(result.get("has_bsn")));

        digidClient.remoteLog("1089", Map.of(
            lowerUnderscore(ACCOUNT_ID), appAuthenticator.getAccountId(),
            lowerUnderscore(APP_CODE), appAuthenticator.getAppCode(),
            lowerUnderscore(DEVICE_NAME), appAuthenticator.getDeviceName()));

        return new AppSessionResponse(appSession.getId(), Instant.now().getEpochSecond());
    }
@Test
    void processNOKTest() {
        var mockedAppSession = new AppSession();
        mockedAppSession.setAccountId(1L);
        mockedAppSession.setUserAppId(USER_APP_ID);
        mockedAppSession.setId(APP_SESSION_ID);

        var mockedAppAuthenticator = new AppAuthenticator();
        mockedAppAuthenticator.setUserAppId(USER_APP_ID);
        mockedAppAuthenticator.setDeviceName(DEVICE_NAME);
        mockedAppAuthenticator.setInstanceId("test");
        mockedAppAuthenticator.setAccountId(2L);

        when(appAuthenticatorService.findByUserAppId(USER_APP_ID)).thenReturn(mockedAppAuthenticator);
        when(appSessionService.getSession(APP_SESSION_ID)).thenReturn(mockedAppSession);
        when(digidClientMock.getRegistrationByAccount(mockedAppAuthenticator.getAccountId())).thenReturn(requestNOK);

        AppResponse appResponse = startActivationWithCode.process(mockedFlow, activationWithCodeRequest());

        assertTrue(appResponse instanceof NokResponse);
    }