public Optional<LocalSession> getActiveLocalSession(Tenant tenant, ApplicationId applicationId) {
        TenantApplications applicationRepo = tenant.getApplicationRepo();
        return applicationRepo.activeSessionOf(applicationId).map(aLong -> tenant.getSessionRepository().getLocalSession(aLong));
    }
@Test
    public void redeploy() {
        long firstSessionId = deployApp(testApp).sessionId();

        long secondSessionId = deployApp(testApp).sessionId();
        assertNotEquals(firstSessionId, secondSessionId);

        Session session = applicationRepository.getActiveLocalSession(tenant(), applicationId()).get();
        assertEquals(firstSessionId, session.getMetaData().getPreviousActiveGeneration());
    }