SoldParticipationCache { public static SoldParticipationCache forTenant(final Tenant tenant) { return INSTANCES.computeIfAbsent(tenant.getSessionInfo(), key -> newCache(tenant)); } private  SoldParticipationCache(final Tenant tenant); static SoldParticipationCache forTenant(final Tenant tenant); synchronized LongStream getOffered(); synchronized void unmarkAsOffered(final long investmentId); void markAsOffered(final long investmentId); void markAsSold(final long investmentId); boolean wasOnceSold(final long investmentId);  }
@Test void persistent() { final SecretProvider sp = SecretProvider.inMemory("someone@somewhere.cz"); final Tenant tenant = new TenantBuilder().withSecrets(sp) .build(false); final SoldParticipationCache instance = SoldParticipationCache.forTenant(tenant); final SoldParticipationCache instance2 = SoldParticipationCache.forTenant(tenant); assertThat(instance2).isSameAs(instance); }
@Test void tenantSpecific() { final SecretProvider sp = SecretProvider.inMemory("someone@somewhere.cz"); final Tenant tenant = new TenantBuilder().withSecrets(sp) .build(false); final SecretProvider sp2 = SecretProvider.inMemory("someoneElse@somewhere.cz"); final Tenant tenant2 = new TenantBuilder().withSecrets(sp2) .build(false); final SoldParticipationCache instance = SoldParticipationCache.forTenant(tenant); final SoldParticipationCache instance2 = SoldParticipationCache.forTenant(tenant2); assertThat(instance2).isNotSameAs(instance); }