@Test @DisplayName("in a multitenant environment") void multitenant() { DocumentRepository documentRepository = new DocumentRepository(); BoundedContextBuilder .assumingTests(true) .add(documentRepository) .build(); UserId johnDoe = userId(); TenantId acmeCorp = TenantId .newBuilder() .setDomain(InternetDomain.newBuilder() .setValue("acme.com")) .build(); TenantId cyberdyne = TenantId .newBuilder() .setDomain(InternetDomain.newBuilder() .setValue("cyberdyne.com")) .build(); DocumentId documentId = DocumentId.generate(); OpenOfficeDocumentUploaded importEvent = OpenOfficeDocumentUploaded .newBuilder() .setId(documentId) .setText("Daily report") .build(); postForTenant(acmeCorp, johnDoe, importEvent); Optional<DocumentAggregate> acmeDailyReport = TenantAwareRunner .with(acmeCorp) .evaluate(() -> documentRepository.find(documentId)); assertThat(acmeDailyReport).isPresent(); Optional<DocumentAggregate> cyberdyneDailyReport = TenantAwareRunner .with(cyberdyne) .evaluate(() -> documentRepository.find(documentId)); assertThat(cyberdyneDailyReport).isEmpty(); }
public static ThirdPartyContext multitenant(String name) { return newContext(name, true); }
ThirdPartyContext implements Closeable { public static ThirdPartyContext multitenant(String name) { return newContext(name, true); } }
ThirdPartyContext implements Closeable { public static ThirdPartyContext multitenant(String name) { return newContext(name, true); } private  ThirdPartyContext(BoundedContext context); }
ThirdPartyContext implements Closeable { public static ThirdPartyContext multitenant(String name) { return newContext(name, true); } private  ThirdPartyContext(BoundedContext context); static ThirdPartyContext singleTenant(String name); static ThirdPartyContext multitenant(String name); void emittedEvent(EventMessage eventMessage, ActorContext actorContext); void emittedEvent(EventMessage eventMessage, UserId userId); @Override void close(); @Override boolean isOpen(); }
ThirdPartyContext implements Closeable { public static ThirdPartyContext multitenant(String name) { return newContext(name, true); } private  ThirdPartyContext(BoundedContext context); static ThirdPartyContext singleTenant(String name); static ThirdPartyContext multitenant(String name); void emittedEvent(EventMessage eventMessage, ActorContext actorContext); void emittedEvent(EventMessage eventMessage, UserId userId); @Override void close(); @Override boolean isOpen();  }