當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。