Permalink
Browse files

Removing setExpirationTime from locator update, and removing verifica…

…tion since we have no control over it any more
  • Loading branch information...
1 parent f54155f commit eadf37cf16f616684f02bf40854958e40dfe6ca2 @christav christav committed Dec 14, 2012
@@ -230,9 +230,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.
*
@@ -248,7 +245,7 @@ public Updater(String locatorId) {
*/
@Override
public Object getRequestContents() {
- return new LocatorRestType().setStartTime(startDateTime).setExpirationDateTime(expirationDateTime);
+ return new LocatorRestType().setStartTime(startDateTime);
}
/* (non-Javadoc)
@@ -270,19 +267,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;
- }
-
}
/**
@@ -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,30 +97,28 @@ 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(),
locatorType));
// 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(),
locatorType).setId(String.format("nb:lid:UUID:%s", UUID.randomUUID().toString())));
// Assert
verifyLocatorProperties("locatorInfo", accessPolicyInfoRead.getId(), assetInfo.getId(), locatorType, null,
- expectedExpirationDateTime, locatorInfo);
+ locatorInfo);
}
@Test
@@ -138,16 +127,14 @@ 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(),
locatorType).setStartDateTime(expectedStartDateTime));
// 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
@@ -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 eadf37c

Please sign in to comment.