public void removeByInstanceIdAndIdNot(String instanceId, String appSessionId) {
        repository.findAllByInstanceFlow(AuthenticateLoginFlow.NAME + instanceId ).stream()
            .filter(s -> !s.getId().equals(appSessionId))
            .forEach(s -> removeById(s.getId()));
    }
@Test
    void removeByInstanceIdAndIdNotTest() {
        // persist app session
        AppSession session = new AppSession();
        session.setId(T_APP_SESSION_ID);
        session.setFlow(AuthenticateLoginFlow.NAME);
        session.setState("AUTHENTICATED");
        session.setUserAppId(T_USER_APP_ID);
        session.setInstanceId(T_INSTANCE_ID);
        session.setDeviceName(T_DEVICE_NAME);

        repository.save(session);

        // Given app session is created
        assertTrue(repository.findById(T_APP_SESSION_ID).isPresent());
        // Should not be removed when removing with same instanceId and appSessionId
        service.removeByInstanceIdAndIdNot(T_INSTANCE_ID, T_APP_SESSION_ID);
        assertTrue(repository.findById(T_APP_SESSION_ID).isPresent());
        // Old session should be removed when removing with same instanceId and new appSessionId
        service.removeByInstanceIdAndIdNot(T_INSTANCE_ID, T_APP_SESSION_ID + "1");
        assertFalse(repository.findById(T_APP_SESSION_ID).isPresent());
    }