当前位置: 首页>>代码示例>>Java>>正文


Java UniqueValueGenerator类代码示例

本文整理汇总了Java中gov.samhsa.c2s.common.util.UniqueValueGenerator的典型用法代码示例。如果您正苦于以下问题:Java UniqueValueGenerator类的具体用法?Java UniqueValueGenerator怎么用?Java UniqueValueGenerator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


UniqueValueGenerator类属于gov.samhsa.c2s.common.util包,在下文中一共展示了UniqueValueGenerator类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testGenerateUniqueValue_Success_First_Trial

import gov.samhsa.c2s.common.util.UniqueValueGenerator; //导入依赖的package包/类
@Test
public void testGenerateUniqueValue_Success_First_Trial() {
    // Arrange
    AtomicInteger counter = new AtomicInteger(0);

    // Act
    String value = UniqueValueGenerator.generateUniqueValue(
            () -> TEST_VALUE, v -> {
                counter.incrementAndGet();
                return true;
            }, LIMIT);

    // Assert
    assertEquals(TEST_VALUE, value);
    assertEquals(1, counter.get());
}
 
开发者ID:bhits,项目名称:common-libraries,代码行数:17,代码来源:UniqueValueGeneratorTest.java

示例2: testGenerateUniqueValue_Throws_UniqueValueGeneratorException_Last_Trial1

import gov.samhsa.c2s.common.util.UniqueValueGenerator; //导入依赖的package包/类
@Test
public void testGenerateUniqueValue_Throws_UniqueValueGeneratorException_Last_Trial1() {
    // Arrange
    AtomicInteger counter = new AtomicInteger(0);
    thrown.expect(UniqueValueGeneratorException.class);

    // Act
    String value = null;
    try {
        value = UniqueValueGenerator.generateUniqueValue(() -> TEST_VALUE,
                v -> {
                    counter.incrementAndGet();
                    return false;
                }, LIMIT);
    } catch (Exception e) {
        // Assert
        assertEquals(null, value);
        assertEquals(LIMIT, counter.get());
        throw e;
    }
}
 
开发者ID:bhits,项目名称:common-libraries,代码行数:22,代码来源:UniqueValueGeneratorTest.java

示例3: testGenerateUniqueValue_Throws_UniqueValueGeneratorException_Last_Trial2

import gov.samhsa.c2s.common.util.UniqueValueGenerator; //导入依赖的package包/类
@Test
public void testGenerateUniqueValue_Throws_UniqueValueGeneratorException_Last_Trial2() {
    // Arrange
    AtomicInteger counter = new AtomicInteger(0);
    thrown.expect(UniqueValueGeneratorException.class);

    // Act
    String value = null;
    try {
        value = UniqueValueGenerator.generateUniqueValue(() -> TEST_VALUE,
                v -> counter.incrementAndGet() > LIMIT, LIMIT);
    } catch (Exception e) {
        // Assert
        assertEquals(null, value);
        assertEquals(LIMIT, counter.get());
        throw e;
    }
}
 
开发者ID:bhits,项目名称:common-libraries,代码行数:19,代码来源:UniqueValueGeneratorTest.java

示例4: generatePolicyId

import gov.samhsa.c2s.common.util.UniqueValueGenerator; //导入依赖的package包/类
@Override
public String generatePolicyId(ConsentDto consentDto, String mrn) {
    final short iterationLimit = 3;
    return UniqueValueGenerator
            .generateUniqueValue(() -> generateRandomPolicyId(consentDto, mrn),
                    generatedValue -> consentRepository.findAllByConsentReferenceId(generatedValue)
                            .size() == 0, iterationLimit);
}
 
开发者ID:bhits,项目名称:pcm-api,代码行数:9,代码来源:PolicyIdServiceImpl.java

示例5: generateMrn

import gov.samhsa.c2s.common.util.UniqueValueGenerator; //导入依赖的package包/类
@Override
public String generateMrn() {
    final short iterationLimit = 3;
    return UniqueValueGenerator
            .generateUniqueValue(this::generateRandomMrn,
                    generatedValue -> patientRepository
                            .findAllByMedicalRecordNumber(generatedValue)
                            .size() == 0, iterationLimit);
}
 
开发者ID:bhits,项目名称:pcm-api,代码行数:10,代码来源:MrnServiceImpl.java

示例6: testGenerateUniqueValue_Success_Last_Trial

import gov.samhsa.c2s.common.util.UniqueValueGenerator; //导入依赖的package包/类
@Test
public void testGenerateUniqueValue_Success_Last_Trial() {
    // Arrange
    AtomicInteger counter = new AtomicInteger(0);

    // Act
    String value = UniqueValueGenerator.generateUniqueValue(
            () -> TEST_VALUE, v -> counter.incrementAndGet() >= LIMIT,
            LIMIT);

    // Assert
    assertEquals(TEST_VALUE, value);
    assertEquals(LIMIT, counter.get());
}
 
开发者ID:bhits,项目名称:common-libraries,代码行数:15,代码来源:UniqueValueGeneratorTest.java

示例7: generateEmailToken

import gov.samhsa.c2s.common.util.UniqueValueGenerator; //导入依赖的package包/类
@Override
@Transactional(readOnly = true)
public String generateEmailToken() {
    short trialLimit = 3;
    return UniqueValueGenerator.generateUniqueValue(tokenGenerator::generateToken, this::isUnique, trialLimit);
}
 
开发者ID:bhits,项目名称:patient-user-api,代码行数:7,代码来源:EmailTokenGeneratorImpl.java


注:本文中的gov.samhsa.c2s.common.util.UniqueValueGenerator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。