private Person randomPersonWithId() {
   return Person.Builder.newInstance()
       .id(UUID.randomUUID().toString())
       .name(RandomStringUtils.randomAlphabetic(10))
       .homeTown(RandomStringUtils.randomAlphabetic(10))
       .build();
 }
 private Team createTeam(Client client) {
   Team team = new Team();
   team.setName("Test Team" + RandomStringUtils.randomAlphanumeric(18));
   team.setDescription("Test Team description");
   team.setActive(true);
   team.setClient(client);
   team.setSalesForceAccount(new TeamSalesForce(RandomStringUtils.randomAlphanumeric(18)));
   teamService.create(team);
   return team;
 }
Example #3
0
 /** @return */
 public static Address validAddress() {
   final Address address = new Address();
   address.setCity(RandomStringUtils.random(Address.CONSTRAINT_CITY_MAX_SIZE, TestUtils.charSet));
   address.setCountryCode("fr");
   address.setPostalCode(
       RandomStringUtils.random(Address.CONSTRAINT_POSTAL_CODE_MAX_SIZE, TestUtils.charSet));
   address.setStreetAddress(
       RandomStringUtils.random(Address.CONSTRAINT_STREET_ADDRESS_MAX_SIZE, TestUtils.charSet));
   return address;
 }
 /**
  * RtReleases can edit release tag.
  *
  * @throws Exception if any problem inside.
  */
 @Test
 public void canEditTag() throws Exception {
   final Releases releases = repo.releases();
   final Release release = releases.create(RandomStringUtils.randomAlphanumeric(Tv.TEN));
   final String tag = RandomStringUtils.randomAlphanumeric(Tv.FIFTEEN);
   new Release.Smart(release).tag(tag);
   MatcherAssert.assertThat(
       new Release.Smart(releases.get(release.number())).tag(), Matchers.equalTo(tag));
   releases.remove(release.number());
 }
  public UserCachedService() {

    User preloadedUser =
        new User()
            .setId(PRELOADED_USER_ID)
            .setFirstName("FirstName-" + RandomStringUtils.randomAlphabetic(5))
            .setLastName("LastName-" + RandomStringUtils.randomAlphabetic(5));

    users.add(preloadedUser);
  }
 @Override
 public void verouiller(CompteUtilisateur compteUtilisateur, Cause causeVerrouillage)
     throws ServiceException {
   compteUtilisateur.setVerrou(
       new Verrou(
           RandomStringUtils.randomAlphanumeric(64),
           causeVerrouillage,
           new Date(),
           RandomStringUtils.randomAlphanumeric(32)));
   dao.update(compteUtilisateur);
   notifierVerrou(compteUtilisateur);
 }
Example #7
0
 public void noTransactionNoPipeline() {
   Jedis jedis = pool.getResource();
   try {
     for (int i = 0; i < rowCount; i++) {
       String key = RandomStringUtils.randomAlphabetic(8);
       jedis.set(key, RandomStringUtils.randomNumeric(5));
       jedis.expire(key, 5 * 60);
     }
   } catch (Exception e) {
     pool.returnResource(jedis);
   }
 }
 @Test
 public void createWithNameAndDescriptionFinallyDelete() {
   Category category = new Category();
   category.setName(
       RandomStringUtils.randomAlphanumeric(random.nextInt(NAME_MAX_LENGTH) + NAME_MIN_LENGTH));
   category.setDescription(
       RandomStringUtils.randomAlphanumeric(
           random.nextInt(DESCRIPTION_MAX_LENGTH) + DESCRIPTION_MIN_LENGTH));
   Category temp = categoryDao.create(category);
   assertEquals(category, temp);
   categoryDao.delete(temp.getId());
 }
Example #9
0
 public void addTestingData() {
   em.getTransaction().begin();
   for (int i = 1; i < 10; i++) {
     FacilityEntity entity = new FacilityEntity();
     entity.code = RandomStringUtils.random(10, "abcdefghi987654321");
     entity.desc = RandomStringUtils.random(30, "abcdefghiasdfgbhnjmkl987654321");
     entity.city = "Phoenix";
     entity.state = "Arizona";
     entity.country = "USA";
     em.persist(entity);
   }
   em.getTransaction().commit();
 }
Example #10
0
 public static Advert validAdvert() {
   final Advert advert = new Advert();
   advert.setAddress(TestUtils.validAddress());
   advert.setDescription(
       RandomStringUtils.random(Advert.CONSTRAINT_DESCRIPTION_MAX_SIZE, TestUtils.charSet));
   advert.setEmail("*****@*****.**");
   advert.setName(RandomStringUtils.random(Advert.CONSTRAINT_NAME_MAX_SIZE, TestUtils.charSet));
   advert.setPhoneNumber(
       RandomStringUtils.random(Advert.CONSTRAINT_PHONE_NUMBER_MAX_SIZE, TestUtils.charSet));
   advert.setReference(
       RandomStringUtils.random(Advert.CONSTRAINT_REFERENCE_MAX_SIZE, TestUtils.charSet));
   return advert;
 }
Example #11
0
 public void pipelineWithoutTransaction() {
   Jedis jedis = pool.getResource();
   try {
     Pipeline p = jedis.pipelined();
     for (int i = 0; i < rowCount; i++) {
       String key = RandomStringUtils.randomAlphabetic(8);
       p.set(key, RandomStringUtils.randomNumeric(5));
       p.expire(key, 5 * 60);
     }
     p.sync();
   } catch (Exception e) {
     pool.returnResource(jedis);
   }
 }
 @Test(expected = ConstraintViolationException.class)
 public void createCategoryWithATooLongName() {
   final String name = RandomStringUtils.randomAlphanumeric(NAME_MAX_LENGTH + 1);
   Category category = new Category();
   category.setName(name);
   categoryDao.create(category);
 }
Example #13
0
 public CubeInfo(String name) {
   this.name = name;
   dimensions = new int[] {1, 1, 1};
   scale = new double[] {1D, 1D, 1D};
   opacity = 100D;
   identifier = RandomStringUtils.randomAscii(ProjectInfo.IDENTIFIER_LENGTH);
 }
 @Test
 public void test03_SearchNodeTypeNotMatch() {
   String keyword = RandomStringUtils.randomAlphabetic(20);
   info("Search Node Type when no Node type match with keyword");
   magNode.doNodeTypeSearch(keyword);
   waitForTextPresent(magNode.MESSAGE_FOR_NOT_MATCH_KEYWORD);
 }
Example #15
0
  private String getEmailValidationKey(AppUser user) {

    String randomString = RandomStringUtils.randomAlphanumeric(EMAIL_VALIDATION_KEY_LENGTH);
    String hashedUsername = DigestUtils.md2Hex(user.getEmailAddress());

    return randomString + hashedUsername;
  }
 /**
  * Generate a list of random alphabetic strings
  *
  * @param size
  * @param strLength
  * @return
  */
 public List<String> newRandomDataList(int size, int strLength) {
   List<String> dataList = new ArrayList<String>();
   for (int i = 0; i < size; i++) {
     dataList.add(RandomStringUtils.randomAlphabetic(strLength));
   }
   return dataList;
 }
 private Group createGroup(Client client) {
   Group group = new Group();
   group.setName("Test Group" + RandomStringUtils.randomAlphanumeric(9));
   group.setClient(clientService.reload(client));
   groupService.save(group);
   return group;
 }
 /*
  * (non-Javadoc)
  *
  * @see
  * org.adorsys.platform.domain.service.ApplicationInitService#initProviders
  * ()
  */
 @Override
 public boolean initProviders(UserAccount account) {
   if (Provider.countProviders() < 1) {
     Provider provider =
         new Provider(
             "Hsimo",
             "Franklin",
             "bp",
             "email",
             "site",
             "76699918",
             "phone",
             "fax",
             Gender.MALE,
             "",
             "",
             "Ubipharma");
     provider.setTaxPayersNumber("taxPayersNumber_" + RandomStringUtils.randomAlphabetic(5));
     provider.setExchangeKey("Provider_exchangeKey");
     // provider.setAccount(account);
     provider.persist();
     Logger LOG = LoggerFactory.getLogger(Provider.class);
     LOG.debug("[provider Initialise Succefully ]");
     return true;
   }
   return false;
 }
 /*
  * (non-Javadoc)
  *
  * @see
  * org.adorsys.platform.domain.service.ApplicationInitService#initDrugStores
  * ()
  */
 @Override
 public boolean initDrugStores(UserAccount account) {
   if (DrugStore.countDrugStores() <= 0) {
     DrugStore drugStore =
         new DrugStore(
             "gakam",
             "clovis",
             "bp",
             "email",
             "site",
             "77166381",
             "phone",
             "fax",
             Gender.MALE,
             "",
             "",
             "Pharmacie de l'alliance");
     drugStore.setTaxPayersNumber("taxPayersNumber_" + RandomStringUtils.randomAlphabetic(5));
     drugStore.setExchangeKey("drugStore_exchangeKey");
     drugStore.persist();
     Logger LOG = LoggerFactory.getLogger(DrugStore.class);
     LOG.debug("[DrugStore Initialise Succefully ]");
   }
   return true;
 }
Example #20
0
  @Test
  @Ignore("Phantomjs not installed on our build server")
  public void testWide() throws InterruptedException, URISyntaxException {

    Configuration conf = new Configuration();
    conf.getChart().setType(ChartType.COLUMN);
    conf.getChart().setMarginRight(200);
    Legend legend = conf.getLegend();
    legend.setLayout(LayoutDirection.VERTICAL);
    legend.setHorizontalAlign(HorizontalAlign.RIGHT);
    legend.setVerticalAlign(VerticalAlign.MIDDLE);
    legend.setBorderWidth(0);

    Random r = new Random();

    for (int i = 0; i < 20; i++) {
      String name = RandomStringUtils.randomAlphabetic(r.nextInt(20));
      DataSeries dataSeries = new DataSeries(name);
      dataSeries.add(new DataSeriesItem(name, r.nextInt(100)));
      conf.addSeries(dataSeries);
    }

    SVGGenerator instance = SVGGenerator.getInstance();
    String generatedSVG = instance.generate(conf, 1200, 400);

    Assert.assertTrue(generatedSVG.contains("width=\"1200\""));
    Assert.assertTrue(generatedSVG.contains("height=\"400\""));

    SVGGenerator.getInstance().destroy();
  }
Example #21
0
 public static JavassistDynamicBean json() {
   return new JavassistDynamicBean(
       "com.geccocrawler.gecco.dynamic.JsonBean"
           + RandomStringUtils.randomAlphabetic(6)
           + System.nanoTime(),
       JavassistDynamicBean.JsonBean);
 }
Example #22
0
  protected void populateParams() {

    try {
      if (StringUtils.isNotBlank(minRows)) {
        this.setDynamicAttribute(null, "minRows", minRows);
      }
      if (StringUtils.isNotBlank(maxRows)) {
        this.setDynamicAttribute(null, "maxRows", maxRows);
      }
      if (StringUtils.isNotBlank(afterAdd)) {
        this.setDynamicAttribute(null, "afterAdd", afterAdd);
      }
    } catch (JspException e) {
      e.printStackTrace();
    }

    super.populateParams();

    DynamicTable uiBean = ((DynamicTable) component);
    if (id == null) {
      // 设置ID随机
      uiBean.setId("dynamictable_" + RandomStringUtils.randomAlphabetic(10));
    }
    if (cssClass == null) {
      uiBean.setCssClass("table table-striped table-condensed");
    }
  }
  @Test
  public void updateAcceptorSocketBinding() throws IOException, CommandFailedException {
    cliClient.executeCommand(command);
    page.navigateToMessaging();
    page.selectView("Connections");
    page.selectInTable(NAME, 0);
    page.edit();

    String socketBindingName = "RemoteAcceptorSB" + RandomStringUtils.randomAlphanumeric(5);

    try (OnlineManagementClient client = ManagementClientProvider.createOnlineManagementClient()) {
      int port = AvailablePortFinder.getNextAvailable(1024);
      log.info("Obtained port for socket binding '" + socketBindingName + "' is " + port);
      client.apply(new AddSocketBinding.Builder(socketBindingName).port(port).build());
    }

    ConfigFragment editPanelFragment = page.getConfigFragment();

    editPanelFragment.getEditor().text("socketBinding", socketBindingName);
    boolean finished = editPanelFragment.save();

    assertTrue("Config should be saved and closed.", finished);
    verifier.verifyAttribute(address, "socket-binding", socketBindingName, 500);

    cliClient.executeCommand(remove);
  }
  @Secured(value = {"ROLE_ADMIN", "ROLE_MANAGER"})
  @RequestMapping(method = RequestMethod.POST)
  public @ResponseBody void createUser(@RequestBody UserDto dto, Principal principal) {
    PipUser user = new PipUser();
    user.setEmail(dto.getEmail());
    Set<OrganisazionDto> organizations = dto.getOrganizations();
    if (organizations.isEmpty()) {
      PipUser currentUser =
          PipUser.findPipUsersByEmailEquals(principal.getName()).getSingleResult();
      List<Organisazion> organisazions = currentUser.getOrganisazions();
      if (!organisazions.isEmpty()) {
        user.getOrganisazions().add(organisazions.get(0));
      }
    } else {
      Organisazion organisazion =
          Organisazion.findOrganisazionsByName(
                  new ArrayList<OrganisazionDto>(organizations).get(0).getName())
              .getSingleResult();
      user.getOrganisazions().add(organisazion);
    }

    String randomPassword = RandomStringUtils.randomAlphanumeric(6);
    user.setPassword(encoder.encode(randomPassword));
    user.setRole(PipRole.USER.getName());
    user.persist();
    mailingUtil.sendCreationMail(user, randomPassword);
  }
  private Client createClient() {
    UserAdmin user = new UserAdmin(1l, 0);

    Client client = new Client();
    client.setTier(new ClientTier(3l));
    client.setContractEnd(LocalDate.now().plusYears(1));
    client.setContractStart(LocalDate.now());
    client.setRegion(new ClientRegion(1l));
    client.setName("Test Client " + RandomStringUtils.randomAlphanumeric(18));
    client.setType(new ClientType(1l));
    client.setContractOwner(user);
    client.setActive(false);
    client.setSalesForceAccount(new SalesForce(RandomStringUtils.randomAlphanumeric(18)));
    clientService.create(client);
    return client;
  }
Example #26
0
  @Override
  public SessionDto login(String username, String attemptedPassword) {
    log.debug("logging in user: "******"Could not log in!", e);
      throw new RuntimeException("Could not log in!");
    }
  }
Example #27
0
  @Override
  public SessionDto register(String username, String password, String name, String email) {
    log.debug("registering new user: "******"Could not register user!", e);
      throw new RuntimeException("Could not register user!");
    }
  }
  /** Tests that entry name is URL encoded. */
  @Test
  @IgnoreBrowsers({
    @IgnoreBrowser(
        value = "internet.*",
        version = "8\\.*",
        reason = "See http://jira.xwiki.org/browse/XE-1146"),
    @IgnoreBrowser(
        value = "internet.*",
        version = "9\\.*",
        reason = "See http://jira.xwiki.org/browse/XE-1177")
  })
  public void testEntryNameWithURLSpecialCharacters() {
    EntryNamePane entryNamePane = homePage.clickAddNewEntry();
    String entryName = "A?b=c&d#" + RandomStringUtils.randomAlphanumeric(3);
    entryNamePane.setName(entryName);
    EntryEditPage entryEditPage = entryNamePane.clickAdd();
    entryEditPage.setValue("description", "This is a test panel.");
    entryEditPage.clickSaveAndView();

    getUtil().gotoPage(getTestClassName(), getTestMethodName());
    homePage = new ApplicationHomePage();
    LiveTableElement entriesLiveTable = homePage.getEntriesLiveTable();
    entriesLiveTable.waitUntilReady();
    Assert.assertTrue(entriesLiveTable.hasRow("Page name", entryName));
  }
Example #29
0
 public void prepareCreate() {
   super.prepareCreate();
   String parentId = this.getParameter("parentId");
   if (StringUtils.isNotBlank(parentId) && !"NULL".equalsIgnoreCase(parentId)) {
     bindingEntity.setParent(menuService.findOne(parentId));
   }
   bindingEntity.setCode("M" + RandomStringUtils.randomNumeric(6));
 }
 /**
  * Creates a new access token. The secret is selected as random alphanumeric string with a length
  * of 16 characters.
  *
  * @param pUserId The user id this token is associated with.
  * @param pServiceId The service id this token is associated with.
  * @param pTokenKey The token key.
  * @return A new random service access token.
  * @throws SecretEncryptionException If the encryption of the secret fails.
  */
 public static ServiceAccessToken factoryRandomToken(
     String pUserId, String pServiceId, String pTokenKey) throws SecretEncryptionException {
   ServiceAccessToken result = new ServiceAccessToken(pUserId);
   result.setServiceId(pServiceId);
   result.setTokenKey(pTokenKey);
   result.setSecret(RandomStringUtils.randomAlphanumeric(16));
   return result;
 }