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


Java UUID.randomUUID方法代码示例

本文整理汇总了Java中java.util.UUID.randomUUID方法的典型用法代码示例。如果您正苦于以下问题:Java UUID.randomUUID方法的具体用法?Java UUID.randomUUID怎么用?Java UUID.randomUUID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.UUID的用法示例。


在下文中一共展示了UUID.randomUUID方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createsNewChange

import java.util.UUID; //导入方法依赖的package包/类
@Test
public void createsNewChange() {
    this.builder.with(ValueGroupChangeBuilder::drivers, Arrays.asList("Test1", "Test2", "Test4"));
    this.builder.with(ValueGroupChangeBuilder::changeRange, new DateRange(NOW, NOW.plus(Period.ofWeeks(1))));
    this.builder.with(ValueGroupChangeBuilder::driver, "TestDriver");

    final UUID id = UUID.randomUUID();
    this.builder.with(ValueGroupChangeBuilder::ruleCodes, Collections.singletonList(id));

    final List<ValueGroupChange> changes = this.builder.build();
    assertThat(changes, hasSize(1));

    final ValueGroupChange change = changes.get(0);

    assertValueGroupChange(change, Type.NEW, null, "TestValueGroup",
            NOW, NOW.plus(Period.ofWeeks(1)), Arrays.asList("Test1", "Test2", "Test4"));
    assertEquals("TestDriver", change.getValueGroup().getDriverName());
    assertThat(change.getValueGroup().getRuleCodes(), contains(id));
}
 
开发者ID:jpmorganchase,项目名称:swblocks-decisiontree,代码行数:20,代码来源:ValueGroupChangeBuilderTest.java

示例2: raise_adds_pending_event_correctly

import java.util.UUID; //导入方法依赖的package包/类
@Test
public void raise_adds_pending_event_correctly() {
    // Arrange
    AggregateRootProxy sut = new AggregateRootProxy(UUID.randomUUID());
    AbstractDomainEvent domainEvent = Mockito.spy(AbstractDomainEvent.class);
    final ZonedDateTime lowerBoundOfOccurrenceTime = ZonedDateTime.now();

    // Act
    sut.raise(domainEvent);

    // Assert
    List<DomainEvent> actual = new ArrayList<>();
    sut.pollAllPendingEvents().forEach(actual::add);
    Assert.assertEquals(1, actual.size());
    Assert.assertEquals(domainEvent, actual.get(0));
    Assert.assertEquals(1, actual.get(0).getVersion());
    Assert.assertEquals(sut.getId(), actual.get(0).getAggregateId());
    Assert.assertTrue(
            lowerBoundOfOccurrenceTime.compareTo(actual.get(0).getOccurrenceTime()) <= 0);
    Assert.assertTrue(ZonedDateTime.now().compareTo(actual.get(0).getOccurrenceTime()) >= 0);
}
 
开发者ID:loom,项目名称:loom-core,代码行数:22,代码来源:AbstractAggregateRootSpecs.java

示例3: tryGetListShardMap

import java.util.UUID; //导入方法依赖的package包/类
/**
 * Tries to obtains a <see cref="ListShardMap{KeyT}"/> given the name. <typeparam name="KeyT">Key type.</typeparam>
 *
 * @param shardMapName
 *            Name of shard map.
 * @return ListShardMap
 */
public <KeyT> boolean tryGetListShardMap(String shardMapName,
        ShardKeyType keyType,
        ReferenceObjectHelper<ListShardMap<KeyT>> shardMap) {
    ShardMapManager.validateShardMapName(shardMapName);

    try (ActivityIdScope activityIdScope = new ActivityIdScope(UUID.randomUUID())) {
        log.info("ShardMapManager TryGetListShardMap Start; ShardMap: {}", shardMapName);

        shardMap.argValue = (ListShardMap<KeyT>) this.lookupAndConvertShardMapHelper("TryGetListShardMap", shardMapName, keyType, false);

        log.info("Complete; ShardMap: {}", shardMapName);

        return shardMap.argValue != null;
    }
}
 
开发者ID:Microsoft,项目名称:elastic-db-tools-for-java,代码行数:23,代码来源:ShardMapManager.java

示例4: findByPrincipalNameNoPrincipalNameChange

import java.util.UUID; //导入方法依赖的package包/类
@Test
public void findByPrincipalNameNoPrincipalNameChange() throws Exception {
	
	String principalName = "findByPrincipalNameNoPrincipalNameChange"
			+ UUID.randomUUID();
	MongoSession toSave = this.repository.createSession();
	toSave.setAttribute(INDEX_NAME, principalName);

	this.repository.save(toSave);

	toSave.setAttribute("other", "value");
	this.repository.save(toSave);

	Map<String, MongoSession> findByPrincipalName = this.repository
			.findByIndexNameAndIndexValue(INDEX_NAME, principalName);

	assertThat(findByPrincipalName).hasSize(1);
	assertThat(findByPrincipalName.keySet()).containsOnly(toSave.getId());
}
 
开发者ID:spring-projects,项目名称:spring-session-data-mongodb,代码行数:20,代码来源:AbstractMongoRepositoryITest.java

示例5: shouldSendNotificationForAdds

import java.util.UUID; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void shouldSendNotificationForAdds() {
    // given:
    final UUID uuid1 = UUID.randomUUID();
    final UUID uuid2 = UUID.randomUUID();
    final TestSubscriber<CrdtCommand> subscriber = TestSubscriber.create();
    final USet<UUID> set = new USet<>("ID_1");
    set.subscribe(subscriber);

    // when:
    set.add(uuid1);
    set.add(uuid2);

    // then:
    subscriber.assertNotComplete();
    subscriber.assertNoErrors();
    assertThat(subscriber.values(), contains(
            new AddCommandMatcher<>(set.getCrdtId(), uuid1),
            new AddCommandMatcher<>(set.getCrdtId(), uuid2)
    ));
}
 
开发者ID:netopyr,项目名称:wurmloch-crdt,代码行数:23,代码来源:USetTest.java

示例6: cannotProvideAdditionalPropertiesInLoanStatus

import java.util.UUID; //导入方法依赖的package包/类
@Test
public void cannotProvideAdditionalPropertiesInLoanStatus()
  throws InterruptedException,
  MalformedURLException,
  TimeoutException,
  ExecutionException {

  UUID id = UUID.randomUUID();

  JsonObject requestWithAdditionalProperty = new LoanRequestBuilder()
    .withId(id)
    .create();

  requestWithAdditionalProperty.getJsonObject("status")
    .put("somethingAdditional", "foo");

  CompletableFuture<JsonErrorResponse> createCompleted = new CompletableFuture();

  client.post(loanStorageUrl(), requestWithAdditionalProperty,
    StorageTestSuite.TENANT_ID, ResponseHandler.jsonErrors(createCompleted));

  JsonErrorResponse response = createCompleted.get(5, TimeUnit.SECONDS);

  assertThat(response.getStatusCode(), is(UNPROCESSABLE_ENTITY));
  assertThat(response.getErrors(), hasSoleMessgeContaining("Unrecognized field"));
}
 
开发者ID:folio-org,项目名称:mod-circulation-storage,代码行数:27,代码来源:LoansApiTest.java

示例7: HeapDumpNameFormatter

import java.util.UUID; //导入方法依赖的package包/类
HeapDumpNameFormatter(final String pattern, final String hostName) {
  this(pattern, hostName, new Provider<UUID>() {
    @Override
    public UUID get() {
      return UUID.randomUUID();
    }
  });
}
 
开发者ID:SAP,项目名称:java-memory-assistant,代码行数:9,代码来源:HeapDumpNameFormatter.java

示例8: testRuleMatcher

import java.util.UUID; //导入方法依赖的package包/类
@Test
public void testRuleMatcher() {
    final Map<String, String> outputDriver = Collections.singletonMap("outputDriver", "result");

    final DecisionTreeRule decisionTreeRule1 =
            new DecisionTreeRule(new UUID(0, 1), UUID.randomUUID(),
                    new InputDriver[]{new StringDriver("Test1"), new StringDriver("Test2")},
                    outputDriver, null, null);

    assertThat(decisionTreeRule1, isSame(decisionTreeRule1));
    assertThat(decisionTreeRule1, isSame(new DecisionTreeRule(new UUID(0, 1),
            UUID.randomUUID(), new InputDriver[]{new StringDriver("Test1"), new StringDriver("Test2")},
            outputDriver, null, null)));
}
 
开发者ID:jpmorganchase,项目名称:swblocks-decisiontree,代码行数:15,代码来源:DecisionTreeRuleMatcher.java

示例9: testFindAccessTokensByClientIdAndUserName

import java.util.UUID; //导入方法依赖的package包/类
@Test
public void testFindAccessTokensByClientIdAndUserName() {
	String clientId = "id" + UUID.randomUUID();
	String name = "test2" + UUID.randomUUID();
	OAuth2Authentication expectedAuthentication = new OAuth2Authentication(RequestTokenFactory.createOAuth2Request(clientId, false), new TestAuthentication(name, false));
	OAuth2AccessToken expectedOAuth2AccessToken = new DefaultOAuth2AccessToken("testToken");
	getTokenStore().storeAccessToken(expectedOAuth2AccessToken, expectedAuthentication);

	Collection<OAuth2AccessToken> actualOAuth2AccessTokens = getTokenStore().findTokensByClientIdAndUserName(clientId, name);
	assertEquals(1, actualOAuth2AccessTokens.size());
}
 
开发者ID:Mert-Z,项目名称:spring-oauth2-cassandra-token-store,代码行数:12,代码来源:TokenStoreBaseTests.java

示例10: MeviusClient

import java.util.UUID; //导入方法依赖的package包/类
public MeviusClient(SocketChannel channel, PublicKey publickey, MeviusHandler handler) {
	this.sc = channel;
	this.handler = handler;
	handler.getClientHandler().join(this);
	uuid = UUID.randomUUID();
	self = false;
	this.publickey = publickey;
}
 
开发者ID:biancso,项目名称:Mevius-IO,代码行数:9,代码来源:MeviusClient.java

示例11: shouldRemoveElements

import java.util.UUID; //导入方法依赖的package包/类
@Test
public void shouldRemoveElements() {
    // given:
    final UUID uuid1 = UUID.randomUUID();
    final UUID uuid2 = UUID.randomUUID();
    final UUID uuid3 = UUID.randomUUID();
    final Set<UUID> expected = new HashSet<>();
    expected.addAll(Arrays.asList(uuid1, uuid2, uuid3));
    final USet<UUID> set = new USet<>("ID_1");
    set.addAll(expected);
    final Iterator<UUID> it = set.iterator();

    // when:
    final UUID e1 = it.next();
    it.remove();
    expected.remove(e1);

    // then:
    assertThat(set, equalTo(expected));

    // when:
    final UUID e2 = it.next();
    it.remove();
    expected.remove(e2);

    // then:
    assertThat(set, equalTo(expected));

    // when:
    it.next();
    it.remove();

    // then:
    assertThat(set, empty());
}
 
开发者ID:netopyr,项目名称:wurmloch-crdt,代码行数:36,代码来源:USetTest.java

示例12: testCheckPermissionForOrganizationThrowsAuthenticationFailedException

import java.util.UUID; //导入方法依赖的package包/类
@Test(expected = AuthenticationFailedException.class)
public void testCheckPermissionForOrganizationThrowsAuthenticationFailedException() throws Exception {
  UUID organizationID = UUID.randomUUID();
  when(identityResolver.resolveOrganizationIdentity(organizationID)).thenReturn(organization);
  when(accessController.hasPermission(credentials, viewFactObjects, organization)).thenThrow(InvalidCredentialsException.class);
  context.checkPermission(viewFactObjects, organizationID);
}
 
开发者ID:mnemonic-no,项目名称:act-platform,代码行数:8,代码来源:SecurityContextTest.java

示例13: testNullRange

import java.util.UUID; //导入方法依赖的package包/类
@Test(expected = IllegalArgumentException.class)
public void testNullRange() {
    this.bean = new ValueGroup(UUID.randomUUID(), "test-group", Arrays.asList("input1"), null);
}
 
开发者ID:jpmorganchase,项目名称:swblocks-decisiontree,代码行数:5,代码来源:ValueGroupTest.java

示例14: test

import java.util.UUID; //导入方法依赖的package包/类
@Test
public void test() throws Exception
{
    SerializationTest.prepareSerialization();
    ToStringBuilder.setDefaultStyle(ToStringStyle.SHORT_PREFIX_STYLE);


    ConfigTemplate<SomeConfigNoSpecial> configTemplate = this.configManager.getConfigFile(SomeConfigNoSpecial.class);
    Assert.assertNotNull(configTemplate);
    Assert.assertEquals(SomeConfigNoSpecial.class.getSimpleName(), configTemplate.getName());
    Assert.assertEquals(StandardCharsets.UTF_8, configTemplate.getDefaultDecoder().charset());
    Assert.assertEquals(StandardCharsets.UTF_8, configTemplate.getDefaultEncoder().charset());

    System.out.println("[ConfigTest] creating config instance.");
    SomeConfigNoSpecial someConfig = configTemplate.create();
    Assert.assertNotNull(someConfig);

    this.testNicknames(someConfig);
    Assert.assertNotNull(someConfig.getSpecialData());
    someConfig.setStorage(SerializationTest.prepareObject());

    someConfig.save(System.out);

    try
    {
        someConfig.getSpecialData().clear();
        Assert.assertTrue("This should never happen, special data should be immutable.", false);
    }
    catch (UnsupportedOperationException e)
    {
    }
    MetaObject snowflake = new MetaObject("snowflake", new MetaValue("so special", 25));
    someConfig.putInSpecialData(snowflake);
    Assert.assertEquals(ImmutableList.of(snowflake), someConfig.getSpecialData());

    UUID randomUUID = UUID.randomUUID();
    someConfig.putInEvenMoreSpecialData(randomUUID, snowflake);
    Assert.assertEquals(1, someConfig.getEvenMoreSpecialData().size());

    System.out.println("\n====================\n");
    someConfig.save(System.out);

    Assert.assertEquals(snowflake, someConfig.removeFromEvenMoreSpecialData(randomUUID));
    Assert.assertTrue(someConfig.getEvenMoreSpecialData().isEmpty());


    // check if all data is still valid after reload of config.
    StringBuilderWriter writer = new StringBuilderWriter(500);
    someConfig.save(writer);
    Assert.assertEquals(someConfig, configTemplate.load(new StringReader(writer.toString())));
}
 
开发者ID:GotoFinal,项目名称:diorite-configs-java8,代码行数:52,代码来源:ConfigTestNoSpecial.java

示例15: getMappingLockOwner

import java.util.UUID; //导入方法依赖的package包/类
/**
 * Gets the lock owner id of the specified mapping.
 *
 * @param mapping
 *            Input range mapping.
 * @return An instance of <see cref="MappingLockToken"/>
 */
public MappingLockToken getMappingLockOwner(RangeMapping mapping) {
    ExceptionUtils.disallowNullArgument(mapping, "mapping");

    try (ActivityIdScope activityIdScope = new ActivityIdScope(UUID.randomUUID())) {
        log.info("LookupLockOwner Start");

        Stopwatch stopwatch = Stopwatch.createStarted();

        UUID storeLockOwnerId = this.rsm.getLockOwnerForMapping(mapping);

        stopwatch.stop();

        log.info("LookupLockOwner Complete; Duration: {}; StoreLockOwnerId: {}", stopwatch.elapsed(TimeUnit.MILLISECONDS), storeLockOwnerId);

        return new MappingLockToken(storeLockOwnerId);
    }
}
 
开发者ID:Microsoft,项目名称:elastic-db-tools-for-java,代码行数:25,代码来源:RangeShardMap.java


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