Ejemplo n.º 1
0
  @Test
  public void testGetActualUrl() {
    ProductVersion productVersion =
        productVersionDao.findByProductAndName(productDao.findByShortName("EAM"), "EAM-BC-3");
    User user = userDao.findByUsername(testUserName);
    Region region = regionDao.getReference(2L);
    final TrialDto trialDto =
        trialService.launchTrial(getRequestStub(), productVersion, user, region, Locale.US);
    String guid = trialDto.getGuid();
    String url = trialDto.getUrl();
    assertNotNull(guid);
    assertNotNull(url);
    final TrialInstance actual = trialInstanceDao.findById(trialDto.getId());
    assertEquals(guid, actual.getGuid());
    assertEquals(url, actual.getUrl());

    RedirectUrlDto redirectUrlDto = trialService.getActualUrl(guid);
    assertNotNull(redirectUrlDto);
    assertEquals(actual.getUrl(), redirectUrlDto.getRedirectUrl());
    List<UserTracking> data =
        userTrackingDao.findByTrackingTypeAndUser(TrackingType.PROXY_URL_HIT, user);
    assertNotNull(data);
    assertEquals(1, data.size());
    assertEquals(actual.getId(), data.get(0).getTargetObject());

    redirectUrlDto = trialService.getActualUrl(guid);
    assertEquals(actual.getUrl(), redirectUrlDto.getRedirectUrl());
    data = userTrackingDao.findByTrackingTypeAndUser(TrackingType.PROXY_URL_HIT, user);
    assertNotNull(data);
    assertEquals(2, data.size());
    assertEquals(actual.getId(), data.get(0).getTargetObject());
    assertEquals(actual.getId(), data.get(1).getTargetObject());
  }
Ejemplo n.º 2
0
  @Test
  public void testAddTrialEnvironment() throws Exception {
    loginTestUser();
    List<TrialEnvironment> environments = trialService.getEnvironments(1L);
    int enviroSize = environments.size();

    User user = new User();
    user.setUsername("*****@*****.**");
    user.setFirstName("Test");
    user.setLastName("Test");
    user.setCreatedAt(new Date());
    user.getRoles().add(Role.ROLE_EXTERNAL);
    user.setPassword(securityService.encodePassword("test", user.getCreatedAt()));
    userDao.save(user);

    Product product = new Product();
    product.setShortName("Test");
    product.setName("Test Long");

    productService.addProduct(product);

    ProductVersion productVersion = new ProductVersion();
    productVersion.setName("Test-version");
    productVersion.setCreatedAt(new Date());
    productVersion.setProduct(product);
    productVersion.setIeOnly(true);
    productVersionDao.save(productVersion);
    product.getProductVersions().add(productVersion);
    productDao.save(product);

    emService.flush();

    TrialDto trial = new TrialDto();
    trial.setProductId(product.getId());
    trial.setProductVersionId(productVersion.getId());
    trial.setUserId(user.getId());
    trial.setUrl("http://test/hahahaha");
    trial.setUsername("test");
    trial.setPassword("haha");
    trialService.createTrialEnvironment(trial);
    emService.flush();

    environments = trialService.getEnvironments(product.getId());
    assertEquals(enviroSize + 1, environments.size());
  }