Skip to content
Browse files

Merge pull request #35 from christav/locator-expiration-not-used-541

Removing setExpirationTime from locator update
  • Loading branch information...
2 parents 875d24f + eadf37c commit bbec59419aeed2e4b3d1bf27e3e8fbd4042916bb @jcookems jcookems committed
View
18 ...oft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java
@@ -242,9 +242,6 @@ public static Updater update(String locatorId) {
/** The start date time. */
private Date startDateTime;
- /** The expiration date time. */
- private Date expirationDateTime;
-
/**
* Instantiates a new updater.
*
@@ -260,7 +257,7 @@ public Updater(String locatorId) {
*/
@Override
public Object getRequestContents() {
- return new LocatorRestType().setStartTime(startDateTime).setExpirationDateTime(expirationDateTime);
+ return new LocatorRestType().setStartTime(startDateTime);
}
/* (non-Javadoc)
@@ -282,19 +279,6 @@ public Updater setStartDateTime(Date startDateTime) {
this.startDateTime = startDateTime;
return this;
}
-
- /**
- * Set when the locator will expire.
- *
- * @param expirationDateTime
- * the expiration date & time
- * @return Updater instance
- */
- public Updater setExpirationDateTime(Date expirationDateTime) {
- this.expirationDateTime = expirationDateTime;
- return this;
- }
-
}
/**
View
39 ...-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java
@@ -46,33 +46,24 @@
private static int minuteInMS = 60 * 1000;
private static int tenMinutesInMS = 10 * 60 * 1000;
- private Date calculateDefaultExpectedExpDate(AccessPolicyInfo accessPolicy, AssetInfo asset) {
- return new Date(asset.getLastModified().getTime() + (long) accessPolicy.getDurationInMinutes() * minuteInMS);
- }
-
private void verifyLocatorInfosEqual(String message, LocatorInfo expected, LocatorInfo actual) {
verifyLocatorProperties(message, expected.getAccessPolicyId(), expected.getAssetId(),
- expected.getLocatorType(), expected.getStartTime(), expected.getExpirationDateTime(), expected.getId(),
- expected.getPath(), actual);
+ expected.getLocatorType(), expected.getStartTime(), expected.getId(), expected.getPath(), actual);
}
private void verifyLocatorProperties(String message, String accessPolicyId, String assetId,
- LocatorType locatorType, Date startTime, Date expirationDateTime, LocatorInfo actualLocator) {
- verifyLocatorProperties(message, accessPolicyId, assetId, locatorType, startTime, expirationDateTime, null,
- null, actualLocator);
+ LocatorType locatorType, Date startTime, LocatorInfo actualLocator) {
+ verifyLocatorProperties(message, accessPolicyId, assetId, locatorType, startTime, null, null, actualLocator);
}
private void verifyLocatorProperties(String message, String accessPolicyId, String assetId,
- LocatorType locatorType, Date startTime, Date expirationDateTime, String id, String path,
- LocatorInfo actualLocator) {
+ LocatorType locatorType, Date startTime, String id, String path, LocatorInfo actualLocator) {
assertNotNull(message, actualLocator);
assertEquals(message + " accessPolicyId", accessPolicyId, actualLocator.getAccessPolicyId());
assertEquals(message + " assetId", assetId, actualLocator.getAssetId());
assertEquals(message + " locatorType", locatorType, actualLocator.getLocatorType());
assertDateApproxEquals(message + " startTime", startTime, actualLocator.getStartTime());
- assertDateApproxEquals(message + " expirationDateTime", expirationDateTime,
- actualLocator.getExpirationDateTime());
if (id == null) {
assertNotNull(message + " Id", actualLocator.getId());
@@ -106,7 +97,6 @@ public void instanceSetup() throws Exception {
public void createLocatorSuccess() throws ServiceException {
// Arrange
LocatorType locatorType = LocatorType.SAS;
- Date expectedExpirationDateTime = calculateDefaultExpectedExpDate(accessPolicyInfoRead, assetInfo);
// Act
LocatorInfo locatorInfo = service.create(Locator.create(accessPolicyInfoRead.getId(), assetInfo.getId(),
@@ -114,14 +104,13 @@ public void createLocatorSuccess() throws ServiceException {
// Assert
verifyLocatorProperties("locatorInfo", accessPolicyInfoRead.getId(), assetInfo.getId(), locatorType, null,
- expectedExpirationDateTime, locatorInfo);
+ locatorInfo);
}
@Test
public void createLocatorWithSpecifiedIdSuccess() throws ServiceException {
// Arrange
LocatorType locatorType = LocatorType.SAS;
- Date expectedExpirationDateTime = calculateDefaultExpectedExpDate(accessPolicyInfoRead, assetInfo);
// Act
LocatorInfo locatorInfo = service.create(Locator.create(accessPolicyInfoRead.getId(), assetInfo.getId(),
@@ -129,7 +118,7 @@ public void createLocatorWithSpecifiedIdSuccess() throws ServiceException {
// Assert
verifyLocatorProperties("locatorInfo", accessPolicyInfoRead.getId(), assetInfo.getId(), locatorType, null,
- expectedExpirationDateTime, locatorInfo);
+ locatorInfo);
}
@Test
@@ -138,8 +127,6 @@ public void createLocatorOptionsSetStartTimeSuccess() throws ServiceException {
Date expectedStartDateTime = new Date();
expectedStartDateTime.setTime(expectedStartDateTime.getTime() + tenMinutesInMS);
LocatorType locatorType = LocatorType.SAS;
- Date expectedExpirationDateTime = new Date(expectedStartDateTime.getTime()
- + (long) accessPolicyInfo.getDurationInMinutes() * minuteInMS);
// Act
LocatorInfo locatorInfo = service.create(Locator.create(accessPolicyInfo.getId(), assetInfo.getId(),
@@ -147,7 +134,7 @@ public void createLocatorOptionsSetStartTimeSuccess() throws ServiceException {
// Assert
verifyLocatorProperties("locatorInfo", accessPolicyInfo.getId(), assetInfo.getId(), locatorType,
- expectedStartDateTime, expectedExpirationDateTime, locatorInfo);
+ expectedStartDateTime, locatorInfo);
}
@Test
@@ -229,20 +216,20 @@ public void updateLocatorSuccess() throws ServiceException {
LocatorInfo locatorInfo = service.create(Locator.create(accessPolicyInfoRead.getId(), assetInfo.getId(),
locatorType));
- Date expirationDateTime = new Date();
- expirationDateTime.setTime(expirationDateTime.getTime() + tenMinutesInMS);
Date startTime = new Date();
startTime.setTime(startTime.getTime() - tenMinutesInMS);
// Act
- service.update(Locator.update(locatorInfo.getId()).setExpirationDateTime(expirationDateTime)
- .setStartDateTime(startTime));
+ service.update(Locator.update(locatorInfo.getId()).setStartDateTime(startTime));
LocatorInfo updatedLocatorInfo = service.get(Locator.get(locatorInfo.getId()));
// Assert
+ Date expectedExpiration = new Date();
+ expectedExpiration.setTime(startTime.getTime() + (long) accessPolicyInfoRead.getDurationInMinutes()
+ * minuteInMS);
+
verifyLocatorProperties("updatedLocatorInfo", locatorInfo.getAccessPolicyId(), locatorInfo.getAssetId(),
- locatorInfo.getLocatorType(), startTime, expirationDateTime, locatorInfo.getId(),
- locatorInfo.getPath(), updatedLocatorInfo);
+ locatorInfo.getLocatorType(), startTime, locatorInfo.getId(), locatorInfo.getPath(), updatedLocatorInfo);
}
@Test
View
7 ...api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorEntityTest.java
@@ -157,19 +157,16 @@ public void locatorUpdateReturnsExpectedUri() throws Exception {
}
@Test
- public void locatorUpdateCanStartAndExpirationTime() throws Exception {
+ public void locatorUpdateCanSetStarTime() throws Exception {
Date now = new Date();
Date tenMinutesAgo = new Date(now.getTime() - 10 * 60 * 1000);
- Date twoHoursFromNow = new Date(now.getTime() + 2 * 60 * 60 * 1000);
- EntityUpdateOperation updater = Locator.update(exampleLocatorId).setStartDateTime(tenMinutesAgo)
- .setExpirationDateTime(twoHoursFromNow);
+ EntityUpdateOperation updater = Locator.update(exampleLocatorId).setStartDateTime(tenMinutesAgo);
LocatorRestType payload = (LocatorRestType) updater.getRequestContents();
assertEquals(tenMinutesAgo, payload.getStartTime());
- assertEquals(twoHoursFromNow, payload.getExpirationDateTime());
}
@Test

0 comments on commit bbec594

Please sign in to comment.
Something went wrong with that request. Please try again.