Example usage for java.util UUID randomUUID

List of usage examples for java.util UUID randomUUID

Introduction

In this page you can find the example usage for java.util UUID randomUUID.

Prototype

public static UUID randomUUID() 

Source Link

Document

Static factory to retrieve a type 4 (pseudo randomly generated) UUID.

Usage

From source file:com.bbytes.zorba.domain.testing.SendMailJobTest.java

@Test
public void sendMail() throws JobExecutionException {
    SendMailJob sendMailJob = new SendMailJob();
    Map<String, String> data = new HashMap<String, String>();
    data.put("from", "zorba.jobserver@gmail.com");
    data.put("to", "tm@beyondbytes.co.in");
    data.put("subject", "Zorba job id " + UUID.randomUUID().toString());
    data.put("body", "Zorba message body... date with time : " + new Date());
    sendMailJob.execute(data);/*  www.  j  a v  a  2  s. c o m*/
}

From source file:edu.kit.scc.test.redis.RedisClientTest.java

@Test
public void createGroupTest() {
    String uuid = UUID.randomUUID().toString();

    String gidNumber = redisClient.createGroup(uuid);

    assertNotNull(gidNumber);/*from   www. ja v  a2 s .com*/

    gidNumber = redisClient.createGroup(uuid);

    assertNull(gidNumber);
}

From source file:com.esofthead.mycollab.module.project.ui.components.ProjectMemberLink.java

public ProjectMemberLink(String username, String userAvatarId, String displayName) {
    if (StringUtils.isBlank(username)) {
        return;//from www.  ja v a 2  s. co m
    }
    this.setContentMode(ContentMode.HTML);
    String uid = UUID.randomUUID().toString();
    DivLessFormatter div = new DivLessFormatter();
    Img userAvatar = new Img("", StorageManager.getAvatarLink(userAvatarId, 16));
    A userLink = new A()
            .setId("tag" + uid).setHref(ProjectLinkBuilder
                    .generateProjectMemberFullLink(CurrentProjectVariables.getProjectId(), username))
            .appendText(displayName);
    userLink.setAttribute("onmouseover", TooltipHelper.userHoverJsDunction(uid, username));
    userLink.setAttribute("onmouseleave", TooltipHelper.itemMouseLeaveJsFunction(uid));
    div.appendChild(userAvatar, DivLessFormatter.EMPTY_SPACE(), userLink, DivLessFormatter.EMPTY_SPACE(),
            TooltipHelper.buildDivTooltipEnable(uid));
    this.setValue(div.write());
}

From source file:net.carinae.dev.async.QueuedTaskHolder.java

@Id
public String getId() {
    if (this.id == null) {
        this.setId(UUID.randomUUID().toString());
    }//ww  w . j  a v a2 s.c o  m
    return this.id;
}

From source file:com.hp.autonomy.frontend.find.core.savedsearches.UserEntityRepositoryIT.java

@Test
public void createWithUuidAndUserStore() {
    final UserEntity userEntity = new UserEntity();
    userEntity.setDomain("DOMAIN");
    userEntity.setUserStore("DEFAULT_USERSTORE");
    userEntity.setUuid(UUID.randomUUID());

    final UserEntity savedEntity = userEntityRepository.save(userEntity);
    assertThat(savedEntity.getUserId(), not(nullValue()));

    final List<UserEntity> users = listUsers();
    assertThat(users, hasSize(1));/*  ww w.java2  s  . c o  m*/
}

From source file:org.eurekastreams.server.domain.GadgetDefinitionTest.java

/**
 * Very basic test to ensure that the gadget constructor stores parameters correctly.
 */// www. j a va2s  .  c o m
@Test
public void sutinitionConstructor() {
    String message = "accessor parameters should be stored and accessible via getters/setters";

    /** fixture. */
    String gadgetUrl = "http://www.example.com";
    GadgetDefinition sut = new GadgetDefinition(gadgetUrl, UUID.randomUUID().toString(),
            new GalleryItemCategory("somecategory"));
    assertEquals("gadget url does not match url passed into the constructor.", gadgetUrl, sut.getUrl());

    List<Gadget> gadgets = new ArrayList<Gadget>();
    GadgetDefinition def = new GadgetDefinition(gadgetUrl, UUID.randomUUID().toString(),
            new GalleryItemCategory("somecategory"));
    Gadget gadget = new Gadget(def, 1, 0, new Person(), "");
    gadgets.clear();
    gadgets.add(gadget);

    sut.setGadgets(gadgets);
    sut.setNumberOfUsers(gadgets.size());

    sut.getUrl();
    sut.getUUID();
    sut.getCategory();
    sut.getNumberOfUsers();

    assertEquals(message, gadgets, sut.getGadgets());
}

From source file:com.surevine.gateway.scm.git.jgit.TestUtility.java

public static LocalRepoBean createTestRepoMultipleBranches() throws Exception {
    final String projectKey = "test_" + UUID.randomUUID().toString();
    final String repoSlug = "testRepo";
    final String remoteURL = "ssh://fake_url";
    final Path repoPath = Paths.get(PropertyUtil.getGitDir(), "local_scm", projectKey, repoSlug);
    Files.createDirectories(repoPath);
    final Repository repo = new FileRepository(repoPath.resolve(".git").toFile());
    repo.create();/*from w ww  .  j av  a 2s.c  om*/
    final StoredConfig config = repo.getConfig();
    config.setString("remote", "origin", "url", remoteURL);
    config.save();

    final LocalRepoBean repoBean = new LocalRepoBean();
    repoBean.setProjectKey(projectKey);
    repoBean.setSlug(repoSlug);
    repoBean.setLocalBare(false);

    final Git git = new Git(repo);

    // add some files to some branches
    for (int i = 0; i < 3; i++) {
        final String filename = "newfile" + i + ".txt";
        Files.write(repoPath.resolve(filename), Arrays.asList("Hello World"), StandardCharsets.UTF_8,
                StandardOpenOption.CREATE, StandardOpenOption.APPEND);
        git.add().addFilepattern(filename).call();
        git.commit().setMessage("Added " + filename).call();
    }

    git.checkout().setName("branch1").setCreateBranch(true).call();
    for (int i = 0; i < 3; i++) {
        final String filename = "branch1" + i + ".txt";
        Files.write(repoPath.resolve(filename), Arrays.asList("Hello World"), StandardCharsets.UTF_8,
                StandardOpenOption.CREATE, StandardOpenOption.APPEND);
        git.add().addFilepattern(filename).call();
        git.commit().setMessage("Added " + filename).call();
    }

    git.checkout().setName("master").call();
    git.checkout().setName("branch2").setCreateBranch(true).call();
    for (int i = 0; i < 3; i++) {
        final String filename = "branch2" + i + ".txt";
        Files.write(repoPath.resolve(filename), Arrays.asList("Hello World"), StandardCharsets.UTF_8,
                StandardOpenOption.CREATE, StandardOpenOption.APPEND);
        git.add().addFilepattern(filename).call();
        git.commit().setMessage("Added " + filename).call();
    }

    repo.close();
    return repoBean;
}

From source file:eu.scape_project.resource.PlanIdentifiers.java

/**
 * Exposes a HTTP end point to reserve a plan id in fedora. In the current
 * implementation plan UUID's are used to mock a reservation mechanism
 * /*  ww w . j ava2 s  .c o  m*/
 * @return a {@link Response} which maps to a corresponding HTTP response,
 *         containing the generated id
 * @throws RepositoryException
 *             if an error occurred while generating the id
 */
@GET
@Produces(MediaType.TEXT_PLAIN)
public Response reservePlanIdentifier() throws RepositoryException {
    final String id = UUID.randomUUID().toString();
    return Response.ok(id, MediaType.TEXT_PLAIN).build();
}

From source file:com.adaptris.interlok.types.DefaultSerializableMessage.java

public DefaultSerializableMessage() {
    messageHeaders = new HashMap<>();
    setUniqueId(UUID.randomUUID().toString());
    setNextServiceId("");
}