IdGenerator { public static void initialize(int node) { nodeId = node; }  static void initialize(int node); static void cleanUp(); static void initialize(
            int node, List<IdValidationConstraint> globalConstraints, Map<String, List<IdValidationConstraint>> domainSpecificConstraints); static synchronized void registerGlobalConstraints(IdValidationConstraint... constraints); static synchronized void registerGlobalConstraints(List<IdValidationConstraint> constraints); static synchronized void registerDomainSpecificConstraints(String domain, IdValidationConstraint... validationConstraints); static synchronized void registerDomainSpecificConstraints(String domain, List<IdValidationConstraint> validationConstraints); static Id generate(String prefix); static Optional<Id> generateWithConstraints(String prefix, String domain); static Optional<Id> generateWithConstraints(String prefix, String domain, boolean skipGlobal); static Optional<Id> generateWithConstraints(String prefix, final List<IdValidationConstraint> inConstraints); static Optional<Id> generateWithConstraints(String prefix, final List<IdValidationConstraint> inConstraints, boolean skipGlobal);  }
@Test public void testGenerateWithConstraintsNoConstraint() throws Exception { IdGenerator.initialize(23); int numRunners = 20; ImmutableList.Builder<ConstraintRunner> listBuilder = ImmutableList.builder(); for (int i = 0; i < numRunners; i++) { listBuilder.add(new ConstraintRunner(new PartitionValidator(4, new JavaHashCodeBasedKeyPartitioner(16)))); } List<ConstraintRunner> runners = listBuilder.build(); ExecutorService executorService = Executors.newFixedThreadPool(numRunners); for(ConstraintRunner runner : runners) { executorService.submit(runner); } Thread.sleep(10000); executorService.shutdownNow(); long totalCount = runners.stream().mapToLong(ConstraintRunner::getCount).sum(); log.debug("Generated ID count: {}", totalCount); log.debug("Generated ID rate: {}/sec", totalCount/10); Assert.assertTrue(totalCount > 0); }