LocalPaxosComponents { public PaxosLearner learner(Client client) { return getOrCreateComponents(client).learner(); } private  LocalPaxosComponents(TimelockPaxosMetrics metrics,
            PaxosUseCase paxosUseCase,
            Path legacyLogDirectory,
            DataSource sqliteDataSource,
            UUID leaderUuid,
            boolean canCreateNewClients,
            OrderableSlsVersion timeLockVersion); static LocalPaxosComponents createWithBlockingMigration(TimelockPaxosMetrics metrics,
            PaxosUseCase paxosUseCase,
            Path legacyLogDirectory,
            DataSource sqliteDataSource,
            UUID leaderUuid,
            boolean canCreateNewClients,
            OrderableSlsVersion timeLockVersion); PaxosAcceptor acceptor(Client client); PaxosLearner learner(Client client); PingableLeader pingableLeader(Client client); BatchPaxosAcceptor batchAcceptor(); BatchPaxosLearner batchLearner(); BatchPingableLeader batchPingableLeader();  }
@Test public void addsClientsInSubdirectory() { paxosComponents.learner(CLIENT); File expectedAcceptorLogDir = legacyDirectory.resolve( Paths.get(CLIENT.value(), PaxosTimeLockConstants.ACCEPTOR_SUBDIRECTORY_PATH)).toFile(); assertThat(expectedAcceptorLogDir.exists()).isTrue(); File expectedLearnerLogDir = legacyDirectory.resolve( Paths.get(CLIENT.value(), PaxosTimeLockConstants.LEARNER_SUBDIRECTORY_PATH)).toFile(); assertThat(expectedLearnerLogDir.exists()).isTrue(); }
@Test public void newClientCannotBeCreatedIfCreatingClientsIsNotPermitted() { LocalPaxosComponents rejectingComponents = createPaxosComponents(false); assertThatThrownBy(() -> rejectingComponents.learner(CLIENT)) .isInstanceOf(ServiceNotAvailableException.class) .hasMessageContaining("not allowed to create new clients at this time") .hasMessageContaining(CLIENT.value()); }
@Test public void newClientCanBeCreatedIfItAlreadyExistsInTheDirectory() { paxosComponents.learner(CLIENT); LocalPaxosComponents rejectingComponents = createPaxosComponents(false); assertThat(rejectingComponents.learner(CLIENT)).isNotNull(); }