SessionRepository { public LocalSession getLocalSession(long sessionId) { return localSessionCache.get(sessionId); } SessionRepository(TenantName tenantName,
                             GlobalComponentRegistry componentRegistry,
                             TenantApplications applicationRepo,
                             FlagSource flagSource,
                             SessionPreparer sessionPreparer); synchronized void addLocalSession(LocalSession session); LocalSession getLocalSession(long sessionId); Collection<LocalSession> getLocalSessions(); ConfigChangeActions prepareLocalSession(LocalSession session,
                                                   DeployLogger logger,
                                                   PrepareParams params,
                                                   Path tenantPath,
                                                   Instant now); void deleteExpiredSessions(Map<ApplicationId, Long> activeSessions); void deleteLocalSession(LocalSession session); void close(); RemoteSession getRemoteSession(long sessionId); List<Long> getRemoteSessions(); int deleteExpiredRemoteSessions(Clock clock, Duration expiryTime); void deactivate(RemoteSession remoteSession); void deleteRemoteSessionFromZooKeeper(RemoteSession session); synchronized void sessionAdded(long sessionId); void delete(RemoteSession remoteSession); ApplicationSet ensureApplicationLoaded(RemoteSession session); LocalSession createSession(File applicationDirectory, ApplicationId applicationId, TimeoutBudget timeoutBudget); synchronized RemoteSession createRemoteSession(long sessionId); LocalSession createSessionFromExisting(Session existingSession,
                                                  DeployLogger logger,
                                                  boolean internalRedeploy,
                                                  TimeoutBudget timeoutBudget); Optional<ApplicationSet> getActiveApplicationSet(ApplicationId appId); void createLocalSessionUsingDistributedApplicationPackage(long sessionId); Path getSessionPath(long sessionId); @Override String toString(); Clock clock(); Transaction createActivateTransaction(Session session);  }
@Test public void require_that_local_sessions_belong_to_a_tenant() throws Exception { setup(); long firstSessionId = deploy(); long secondSessionId = deploy(); assertNotNull(sessionRepository.getLocalSession(firstSessionId)); assertNotNull(sessionRepository.getLocalSession(secondSessionId)); assertNull(sessionRepository.getLocalSession(secondSessionId + 1)); TenantName newTenant = TenantName.from("newTenant"); tenantRepository.addTenant(newTenant); long sessionId = deploy(ApplicationId.from(newTenant.value(), "testapp", "default")); SessionRepository sessionRepository2 = tenantRepository.getTenant(newTenant).getSessionRepository(); assertNotNull(sessionRepository2.getLocalSession(sessionId)); }