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 prepareAndActivateWithTenantMetaData() {
        long startTime = clock.instant().toEpochMilli();
        Duration duration = Duration.ofHours(1);
        clock.advance(duration);
        long deployTime = clock.instant().toEpochMilli();
        PrepareResult result = prepareAndActivate(testApp);
        assertTrue(result.configChangeActions().getRefeedActions().isEmpty());
        assertTrue(result.configChangeActions().getReindexActions().isEmpty());
        assertTrue(result.configChangeActions().getRestartActions().isEmpty());

        applicationRepository.getActiveLocalSession(tenant(), applicationId()).get().getAllocatedHosts();

        assertEquals(startTime, tenantMetaData(tenant()).createdTimestamp().toEpochMilli());
        assertEquals(deployTime, tenantMetaData(tenant()).lastDeployTimestamp().toEpochMilli());

        // Creating a new tenant will have metadata with timestamp equal to current time
        clock.advance(duration);
        long createTenantTime = clock.instant().toEpochMilli();
        Tenant fooTenant = tenantRepository.addTenant(TenantName.from("foo"));
        assertEquals(createTenantTime, tenantMetaData(fooTenant).createdTimestamp().toEpochMilli());
        assertEquals(createTenantTime, tenantMetaData(fooTenant).lastDeployTimestamp().toEpochMilli());
    }