VisibilityGuard { Optional<Repository<?, ?>> repositoryFor(Class<? extends EntityState> stateClass) { checkNotNull(stateClass); RepositoryAccess repositoryAccess = findOrThrow(stateClass); return repositoryAccess.get(); } private  VisibilityGuard(); Set<TypeName> entityStateTypes(Visibility visibility);  }
@Test @DisplayName("give access to visible repos") void giveAccessToVisible() { assertTrue(guard.repositoryFor(FullAccessAggregate.class) .isPresent()); assertTrue(guard.repositoryFor(SubscribableAggregate.class) .isPresent()); }
@Test @DisplayName("deny access to invisible repos") void denyAccessToInvisible() { assertFalse(guard.repositoryFor(HiddenAggregate.class) .isPresent()); }
@Test @DisplayName("reject unregistered state class") void rejectUnregisteredStateClass() { assertThrows(IllegalStateException.class, () -> guard.repositoryFor(Company.class)); }