Browse files

Added fluent setters for list query params

  • Loading branch information...
1 parent 89eb936 commit 8062bc63c810c924347c4ef4bdd5eef20d023594 @christav christav committed Dec 13, 2012
Showing with 83 additions and 82 deletions.
  1. +38 −0 .../java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultListOperation.java
  2. +2 −3 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicy.java
  3. +3 −4 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java
  4. +2 −3 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetFile.java
  5. +2 −3 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java
  6. +2 −3 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java
  7. +2 −3 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java
  8. +2 −3 ...soft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/MediaProcessor.java
  9. +2 −3 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java
  10. +1 −7 ...zure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java
  11. +1 −4 ...osoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java
  12. +1 −7 ...-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ContentKeyIntegrationTest.java
  13. +3 −9 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EntityProxyTest.java
  14. +1 −6 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java
  15. +6 −7 ...ft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java
  16. +2 −12 ...re-api/src/test/java/com/microsoft/windowsazure/services/media/MediaProcessorIntegrationTest.java
  17. +10 −0 ...oft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetEntityTest.java
  18. +3 −5 ...ft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java
View
38 ...m/microsoft/windowsazure/services/media/implementation/entities/DefaultListOperation.java
@@ -41,6 +41,44 @@ public DefaultListOperation(String entityUri, GenericType<ListResult<T>> respons
this.queryParameters.putAll(queryParameters);
}
+ /**
+ * Add a "$top" query parameter to set the number of values to return
+ *
+ * @param topValue
+ * number of values to return
+ * @return this
+ */
+ public DefaultListOperation<T> setTop(int topValue) {
+ queryParameters.add("$top", Integer.toString(topValue));
+ return this;
+ }
+
+ /**
+ * Add a "$skip" query parameter to set the number of values to skip
+ *
+ * @param skipValue
+ * the number of values to skip
+ * @return this
+ */
+ public DefaultListOperation<T> setSkip(int skipValue) {
+ queryParameters.add("$skip", Integer.toString(skipValue));
+ return this;
+ }
+
+ /**
+ * Add an arbitrary query parameter
+ *
+ * @param parameterName
+ * name of query parameter
+ * @param parameterValue
+ * value for query parameter
+ * @return this
+ */
+ public DefaultListOperation<T> set(String parameterName, String parameterValue) {
+ queryParameters.add(parameterName, parameterValue);
+ return this;
+ }
+
/* (non-Javadoc)
* @see com.microsoft.windowsazure.services.media.entities.EntityListOperation#getQueryParameters()
*/
View
5 ...zure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicy.java
@@ -26,7 +26,6 @@
import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreationOperation;
import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation;
import com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation;
-import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation;
import com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationSingleResultBase;
import com.sun.jersey.api.client.GenericType;
@@ -96,7 +95,7 @@ public Object getRequestContents() {
*
* @return the operation
*/
- public static EntityListOperation<AccessPolicyInfo> list() {
+ public static DefaultListOperation<AccessPolicyInfo> list() {
return new DefaultListOperation<AccessPolicyInfo>(ENTITY_SET, new GenericType<ListResult<AccessPolicyInfo>>() {
});
}
@@ -108,7 +107,7 @@ public Object getRequestContents() {
* query parameters to add to the request
* @return the operation
*/
- public static EntityListOperation<AccessPolicyInfo> list(MultivaluedMap<String, String> queryParameters) {
+ public static DefaultListOperation<AccessPolicyInfo> list(MultivaluedMap<String, String> queryParameters) {
return new DefaultListOperation<AccessPolicyInfo>(ENTITY_SET, new GenericType<ListResult<AccessPolicyInfo>>() {
}, queryParameters);
}
View
7 ...osoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java
@@ -27,7 +27,6 @@
import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation;
import com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation;
import com.microsoft.windowsazure.services.media.implementation.entities.EntityLinkOperation;
-import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation;
import com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationBase;
import com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationSingleResultBase;
import com.microsoft.windowsazure.services.media.implementation.entities.EntityProxyData;
@@ -167,7 +166,7 @@ public Creator setState(AssetState state) {
*
* @return The list operation
*/
- public static EntityListOperation<AssetInfo> list() {
+ public static DefaultListOperation<AssetInfo> list() {
return new DefaultListOperation<AssetInfo>(ENTITY_SET, new GenericType<ListResult<AssetInfo>>() {
});
}
@@ -179,7 +178,7 @@ public Creator setState(AssetState state) {
* query parameters to pass to the server.
* @return the list operation.
*/
- public static EntityListOperation<AssetInfo> list(MultivaluedMap<String, String> queryParameters) {
+ public static DefaultListOperation<AssetInfo> list(MultivaluedMap<String, String> queryParameters) {
return new DefaultListOperation<AssetInfo>(ENTITY_SET, new GenericType<ListResult<AssetInfo>>() {
}, queryParameters);
}
@@ -191,7 +190,7 @@ public Creator setState(AssetState state) {
* Link to request assets from.
* @return The list operation.
*/
- public static EntityListOperation<AssetInfo> list(LinkInfo link) {
+ public static DefaultListOperation<AssetInfo> list(LinkInfo link) {
return new DefaultListOperation<AssetInfo>(link.getHref(), new GenericType<ListResult<AssetInfo>>() {
});
}
View
5 ...t-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetFile.java
@@ -28,7 +28,6 @@
import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreationOperation;
import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation;
import com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation;
-import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation;
import com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationBase;
import com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationSingleResultBase;
import com.microsoft.windowsazure.services.media.implementation.entities.EntityProxyData;
@@ -196,7 +195,7 @@ public static EntityActionOperation createFileInfos(String assetId) {
*
* @return The list operation to pass to rest proxy.
*/
- public static EntityListOperation<AssetFileInfo> list() {
+ public static DefaultListOperation<AssetFileInfo> list() {
return new DefaultListOperation<AssetFileInfo>(ENTITY_SET, new GenericType<ListResult<AssetFileInfo>>() {
});
}
@@ -208,7 +207,7 @@ public static EntityActionOperation createFileInfos(String assetId) {
* asset to list files for
* @return the list operation object
*/
- public static EntityListOperation<AssetFileInfo> list(String assetId) {
+ public static DefaultListOperation<AssetFileInfo> list(String assetId) {
String assetUri = new EntityOperationBase.EntityIdUriBuilder("Assets", assetId).getUri() + "/Files";
return new DefaultListOperation<AssetFileInfo>(assetUri, new GenericType<ListResult<AssetFileInfo>>() {
});
View
5 ...-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java
@@ -24,7 +24,6 @@
import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreationOperation;
import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation;
import com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation;
-import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation;
import com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationSingleResultBase;
import com.sun.jersey.api.client.GenericType;
@@ -155,7 +154,7 @@ public Creator setChecksum(String checksum) {
*
* @return the operation
*/
- public static EntityListOperation<ContentKeyInfo> list() {
+ public static DefaultListOperation<ContentKeyInfo> list() {
return new DefaultListOperation<ContentKeyInfo>(ENTITY_SET, new GenericType<ListResult<ContentKeyInfo>>() {
});
}
@@ -167,7 +166,7 @@ public Creator setChecksum(String checksum) {
* query parameters to add to the request
* @return the operation
*/
- public static EntityListOperation<ContentKeyInfo> list(MultivaluedMap<String, String> queryParameters) {
+ public static DefaultListOperation<ContentKeyInfo> list(MultivaluedMap<String, String> queryParameters) {
return new DefaultListOperation<ContentKeyInfo>(ENTITY_SET, new GenericType<ListResult<ContentKeyInfo>>() {
}, queryParameters);
}
View
5 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java
@@ -40,7 +40,6 @@
import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreationOperation;
import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation;
import com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation;
-import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation;
import com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationSingleResultBase;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.GenericType;
@@ -426,7 +425,7 @@ public JobInfo getJobInfo() {
*
* @return The list operation
*/
- public static EntityListOperation<JobInfo> list() {
+ public static DefaultListOperation<JobInfo> list() {
return new DefaultListOperation<JobInfo>(ENTITY_SET, new GenericType<ListResult<JobInfo>>() {
});
}
@@ -438,7 +437,7 @@ public JobInfo getJobInfo() {
* query parameters to pass to the server.
* @return the list operation.
*/
- public static EntityListOperation<JobInfo> list(MultivaluedMap<String, String> queryParameters) {
+ public static DefaultListOperation<JobInfo> list(MultivaluedMap<String, String> queryParameters) {
return new DefaultListOperation<JobInfo>(ENTITY_SET, new GenericType<ListResult<JobInfo>>() {
}, queryParameters);
}
View
5 ...oft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java
@@ -25,7 +25,6 @@
import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreationOperation;
import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation;
import com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation;
-import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation;
import com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationBase;
import com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationSingleResultBase;
import com.microsoft.windowsazure.services.media.implementation.entities.EntityProxyData;
@@ -195,7 +194,7 @@ public Creator setContentAccessComponent(String contentAccessComponent) {
*
* @return the list operation
*/
- public static EntityListOperation<LocatorInfo> list() {
+ public static DefaultListOperation<LocatorInfo> list() {
return new DefaultListOperation<LocatorInfo>(ENTITY_SET, new GenericType<ListResult<LocatorInfo>>() {
});
}
@@ -207,7 +206,7 @@ public Creator setContentAccessComponent(String contentAccessComponent) {
* query parameters to send with the request
* @return the list operation
*/
- public static EntityListOperation<LocatorInfo> list(MultivaluedMap<String, String> queryParameters) {
+ public static DefaultListOperation<LocatorInfo> list(MultivaluedMap<String, String> queryParameters) {
return new DefaultListOperation<LocatorInfo>(ENTITY_SET, new GenericType<ListResult<LocatorInfo>>() {
}, queryParameters);
}
View
5 ...re-api/src/main/java/com/microsoft/windowsazure/services/media/models/MediaProcessor.java
@@ -18,7 +18,6 @@
import javax.ws.rs.core.MultivaluedMap;
import com.microsoft.windowsazure.services.media.implementation.entities.DefaultListOperation;
-import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation;
import com.sun.jersey.api.client.GenericType;
/**
@@ -37,7 +36,7 @@ private MediaProcessor() {
*
* @return the list operation
*/
- public static EntityListOperation<MediaProcessorInfo> list() {
+ public static DefaultListOperation<MediaProcessorInfo> list() {
return new DefaultListOperation<MediaProcessorInfo>(ENTITY_SET,
new GenericType<ListResult<MediaProcessorInfo>>() {
});
@@ -50,7 +49,7 @@ private MediaProcessor() {
* query parameters to pass with the request
* @return the list operation
*/
- public static EntityListOperation<MediaProcessorInfo> list(MultivaluedMap<String, String> queryParameters) {
+ public static DefaultListOperation<MediaProcessorInfo> list(MultivaluedMap<String, String> queryParameters) {
return new DefaultListOperation<MediaProcessorInfo>(ENTITY_SET,
new GenericType<ListResult<MediaProcessorInfo>>() {
}, queryParameters);
View
5 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java
@@ -22,7 +22,6 @@
import com.microsoft.windowsazure.services.media.implementation.entities.DefaultListOperation;
import com.microsoft.windowsazure.services.media.implementation.entities.EntityBatchOperation;
import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation;
-import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation;
import com.sun.jersey.api.client.GenericType;
/**
@@ -55,7 +54,7 @@ public static CreateBatchOperation create() {
*
* @return The list operation
*/
- public static EntityListOperation<TaskInfo> list() {
+ public static DefaultListOperation<TaskInfo> list() {
return new DefaultListOperation<TaskInfo>(ENTITY_SET, new GenericType<ListResult<TaskInfo>>() {
});
}
@@ -67,7 +66,7 @@ public static CreateBatchOperation create() {
* query parameters to pass to the server.
* @return the list operation.
*/
- public static EntityListOperation<TaskInfo> list(MultivaluedMap<String, String> queryParameters) {
+ public static DefaultListOperation<TaskInfo> list(MultivaluedMap<String, String> queryParameters) {
return new DefaultListOperation<TaskInfo>(ENTITY_SET, new GenericType<ListResult<TaskInfo>>() {
}, queryParameters);
}
View
8 .../src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java
@@ -21,8 +21,6 @@
import java.util.EnumSet;
import java.util.List;
-import javax.ws.rs.core.MultivaluedMap;
-
import org.junit.Test;
import com.microsoft.windowsazure.services.core.ExponentialRetryPolicy;
@@ -31,7 +29,6 @@
import com.microsoft.windowsazure.services.media.models.AccessPolicy;
import com.microsoft.windowsazure.services.media.models.AccessPolicyInfo;
import com.microsoft.windowsazure.services.media.models.AccessPolicyPermission;
-import com.sun.jersey.core.util.MultivaluedMapImpl;
public class AccessPolicyIntegrationTest extends IntegrationTestBase {
private void verifyInfosEqual(String message, AccessPolicyInfo expected, AccessPolicyInfo actual) {
@@ -153,10 +150,7 @@ public void canUseQueryParametersWhenListingAccessPolicies() throws Exception {
expectedAccessPolicies.add(policy);
}
- MultivaluedMap<String, String> options = new MultivaluedMapImpl();
- options.add("$top", "2");
-
- List<AccessPolicyInfo> actualAccessPolicies = service.list(AccessPolicy.list(options));
+ List<AccessPolicyInfo> actualAccessPolicies = service.list(AccessPolicy.list().setTop(2));
assertEquals(2, actualAccessPolicies.size());
}
View
5 ...ure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java
@@ -39,7 +39,6 @@
import com.microsoft.windowsazure.services.media.models.ContentKey;
import com.microsoft.windowsazure.services.media.models.ContentKeyInfo;
import com.microsoft.windowsazure.services.media.models.ContentKeyType;
-import com.sun.jersey.core.util.MultivaluedMapImpl;
public class AssetIntegrationTest extends IntegrationTestBase {
@@ -199,9 +198,7 @@ public void canListAssetsWithOptions() throws ServiceException {
expectedAssets.add(service.create(Asset.create().setName(name)));
}
- MultivaluedMapImpl options = new MultivaluedMapImpl();
- options.add("$top", "2");
- Collection<AssetInfo> listAssetResult = service.list(Asset.list(options));
+ Collection<AssetInfo> listAssetResult = service.list(Asset.list().setTop(2));
// Assert
View
8 ...pi/src/test/java/com/microsoft/windowsazure/services/media/ContentKeyIntegrationTest.java
@@ -21,16 +21,13 @@
import java.util.List;
import java.util.UUID;
-import javax.ws.rs.core.MultivaluedMap;
-
import org.junit.Test;
import com.microsoft.windowsazure.services.core.ServiceException;
import com.microsoft.windowsazure.services.media.models.ContentKey;
import com.microsoft.windowsazure.services.media.models.ContentKeyInfo;
import com.microsoft.windowsazure.services.media.models.ContentKeyType;
import com.microsoft.windowsazure.services.media.models.ProtectionKeyType;
-import com.sun.jersey.core.util.MultivaluedMapImpl;
public class ContentKeyIntegrationTest extends IntegrationTestBase {
@@ -138,10 +135,7 @@ public void canUseQueryParametersWhenListingContentKeys() throws Exception {
expectedContentKeys.add(contentKeyInfo);
}
- MultivaluedMap<String, String> options = new MultivaluedMapImpl();
- options.add("$top", "2");
-
- List<ContentKeyInfo> actualContentKeys = service.list(ContentKey.list(options));
+ List<ContentKeyInfo> actualContentKeys = service.list(ContentKey.list().setTop(2));
assertEquals(2, actualContentKeys.size());
}
View
12 ...ft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EntityProxyTest.java
@@ -5,15 +5,12 @@
import java.util.HashSet;
import java.util.Set;
-import javax.ws.rs.core.MultivaluedMap;
-
import org.junit.BeforeClass;
import org.junit.Test;
import com.microsoft.windowsazure.services.media.models.Asset;
import com.microsoft.windowsazure.services.media.models.AssetInfo;
import com.microsoft.windowsazure.services.media.models.ListResult;
-import com.sun.jersey.core.util.MultivaluedMapImpl;
public class EntityProxyTest extends IntegrationTestBase {
private static MediaContract entityService;
@@ -80,10 +77,7 @@ public void canListAllAssets() throws Exception {
public void canListAssetsWithQueryParameters() throws Exception {
createTestAssets(4, "withQuery");
- MultivaluedMap<String, String> params = new MultivaluedMapImpl();
- params.add("$top", "2");
-
- ListResult<AssetInfo> assets = entityService.list(Asset.list(params));
+ ListResult<AssetInfo> assets = entityService.list(Asset.list().setTop(2));
assertEquals(2, assets.size());
}
@@ -130,8 +124,8 @@ public void canDeleteAssetsById() throws Exception {
Set<String> expectedAssets = new HashSet<String>();
for (int i = 0; i < numAssets; ++i) {
- AssetInfo asset = entityService.create(Asset.create()
- .setName(testAssetPrefix + namePart + Integer.toString(i)));
+ AssetInfo asset = entityService.create(Asset.create().setName(
+ testAssetPrefix + namePart + Integer.toString(i)));
expectedAssets.add(asset.getId());
}
return expectedAssets;
View
7 ...azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java
@@ -25,8 +25,6 @@
import java.util.List;
import java.util.UUID;
-import javax.ws.rs.core.MultivaluedMap;
-
import org.junit.BeforeClass;
import org.junit.Test;
@@ -44,7 +42,6 @@
import com.microsoft.windowsazure.services.media.models.LocatorInfo;
import com.microsoft.windowsazure.services.media.models.Task;
import com.microsoft.windowsazure.services.media.models.Task.CreateBatchOperation;
-import com.sun.jersey.core.util.MultivaluedMapImpl;
public class JobIntegrationTest extends IntegrationTestBase {
@@ -228,9 +225,7 @@ public void canListJobsWithOptions() throws ServiceException {
expectedJobs.add(jobInfo);
}
- MultivaluedMap<String, String> queryParameters = new MultivaluedMapImpl();
- queryParameters.add("$top", "2");
- ListResult<JobInfo> listJobsResult = service.list(Job.list(queryParameters));
+ ListResult<JobInfo> listJobsResult = service.list(Job.list().setTop(2));
// Assert
assertEquals(2, listJobsResult.size());
View
13 ...-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java
@@ -37,7 +37,6 @@
import com.microsoft.windowsazure.services.media.models.Locator;
import com.microsoft.windowsazure.services.media.models.LocatorInfo;
import com.microsoft.windowsazure.services.media.models.LocatorType;
-import com.sun.jersey.core.util.MultivaluedMapImpl;
public class LocatorIntegrationTests extends IntegrationTestBase {
@@ -213,12 +212,12 @@ public void listLocatorsWithOptions() throws ServiceException {
LocatorType.SAS)));
}
- MultivaluedMapImpl options = new MultivaluedMapImpl();
- options.add("$filter", "(Id eq '" + expectedLocators.get(1).getId() + "') or (" + "Id eq '"
- + expectedLocators.get(3).getId() + "')");
- options.add("$top", "3");
-
- ListResult<LocatorInfo> result = service.list(Locator.list(options));
+ ListResult<LocatorInfo> result = service.list(Locator
+ .list()
+ .setTop(3)
+ .set("$filter",
+ "(Id eq '" + expectedLocators.get(1).getId() + "') or (" + "Id eq '"
+ + expectedLocators.get(3).getId() + "')"));
assertEquals(2, result.size());
}
View
14 ...rc/test/java/com/microsoft/windowsazure/services/media/MediaProcessorIntegrationTest.java
@@ -19,15 +19,12 @@
import java.util.List;
-import javax.ws.rs.core.MultivaluedMap;
-
import org.junit.Test;
import com.microsoft.windowsazure.services.core.ServiceException;
import com.microsoft.windowsazure.services.media.models.ListResult;
import com.microsoft.windowsazure.services.media.models.MediaProcessor;
import com.microsoft.windowsazure.services.media.models.MediaProcessorInfo;
-import com.sun.jersey.core.util.MultivaluedMapImpl;
public class MediaProcessorIntegrationTest extends IntegrationTestBase {
@@ -69,16 +66,9 @@ public void listMediaProcessorsSuccess() throws ServiceException {
@Test
public void listMediaProcessorWithOptionSuccess() throws ServiceException {
- // Arrange
- MultivaluedMap<String, String> queryParameters = new MultivaluedMapImpl();
- queryParameters.add("$filter", "Id eq 'nb:mpid:UUID:aec03716-7c5e-4f68-b592-f4850eba9f10'");
- queryParameters.add("$top", "2");
+ ListResult<MediaProcessorInfo> listMediaProcessorsResult = service.list(MediaProcessor.list().setTop(2)
+ .set("$filter", "Id eq 'nb:mpid:UUID:aec03716-7c5e-4f68-b592-f4850eba9f10'"));
- // Act
- ListResult<MediaProcessorInfo> listMediaProcessorsResult = service.list(MediaProcessor
- .list(queryParameters));
-
- // Assert
assertNotNull("listMediaProcessorsResult", listMediaProcessorsResult);
assertEquals("listMediaProcessors size", 1, listMediaProcessorsResult.size());
MediaProcessorInfo mediaProcessorInfo = listMediaProcessorsResult.get(0);
View
10 ...e-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetEntityTest.java
@@ -111,6 +111,16 @@ public void assetListCanTakeQueryParameters() {
}
@Test
+ public void assetListCanTakeQueryParametersChained() {
+ EntityListOperation<AssetInfo> lister = Asset.list().setTop(10).setSkip(2).set("filter", "something");
+
+ assertEquals("10", lister.getQueryParameters().getFirst("$top"));
+ assertEquals("2", lister.getQueryParameters().getFirst("$skip"));
+ assertEquals("something", lister.getQueryParameters().getFirst("filter"));
+ assertEquals(3, lister.getQueryParameters().size());
+ }
+
+ @Test
public void assetUpdateReturnsExpectedUri() throws Exception {
EntityUpdateOperation updater = Asset.update(sampleAssetId);
assertEquals(expectedUri, updater.getUri());
View
8 ...-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java
@@ -116,11 +116,9 @@ public AssetInfo createAsset(String name, AssetOption encryption) throws Service
throws ServiceException {
List<ListResult<AssetInfo>> pages = new ArrayList<ListResult<AssetInfo>>();
for (int skip = 0; true; skip += pageSize) {
- EntityListOperation<AssetInfo> listOperation = Asset.list();
- listOperation.getQueryParameters().add("$skip", skip + "");
- listOperation.getQueryParameters().add("$top", pageSize + "");
- listOperation.getQueryParameters().add("$filter", "startswith(Name,'" + rootName + "')");
- listOperation.getQueryParameters().add("$orderby", "Name");
+ EntityListOperation<AssetInfo> listOperation = Asset.list().setTop(pageSize).setSkip(skip)
+ .set("$filter", "startswith(Name,'" + rootName + "')").set("$orderby", "Name");
+
ListResult<AssetInfo> listAssetResult = service.list(listOperation);
pages.add(listAssetResult);
if (listAssetResult.size() == 0) {

0 comments on commit 8062bc6

Please sign in to comment.