@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()); }
private void extendTrialByGuid(TrialInstanceUpdateDto trialInstanceUpdateDto) { TrialInstance trialInstance = trialInstanceDao.findByGuid(trialInstanceUpdateDto.getGuid()); if (trialInstance == null || !trialInstanceDao.exists(trialInstance.getId())) { throw new CSWebApplicationException(StringDefs.GENERAL_ERROR_CODE, "GUID does not exist!"); } extendSingleTrialInstanceExpiration(trialInstance, daysToExtendFromDto(trialInstanceUpdateDto)); trialInstance.setUpdatedAt(trialInstanceUpdateDto.getUpdatedAt()); trialInstanceDao.save(trialInstance); trialInstanceDao.flush(); }