Skip to content
This repository
Browse code

Merge pull request #555 from christav/dev

Added fluent setters for list query params
  • Loading branch information...
commit 5a0876b2cd16319714251b8e6b90621017d5e7f7 2 parents dfba509 + 782905e
Chris Tavares authored December 14, 2012

Showing 18 changed files with 83 additions and 82 deletions. Show diff stats Hide diff stats

  1. 38  ...i/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultListOperation.java
  2. 5  microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicy.java
  3. 7  microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java
  4. 5  microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetFile.java
  5. 5  microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java
  6. 5  microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java
  7. 5  microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java
  8. 5  microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/MediaProcessor.java
  9. 5  microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java
  10. 8  microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java
  11. 5  microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java
  12. 8  microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ContentKeyIntegrationTest.java
  13. 12  microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EntityProxyTest.java
  14. 7  microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java
  15. 13  microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java
  16. 14  microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaProcessorIntegrationTest.java
  17. 10  microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetEntityTest.java
  18. 8  microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java
38  ...rc/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultListOperation.java
@@ -41,6 +41,44 @@ public DefaultListOperation(String entityUri, GenericType<ListResult<T>> respons
41 41
         this.queryParameters.putAll(queryParameters);
42 42
     }
43 43
 
  44
+    /**
  45
+     * Add a "$top" query parameter to set the number of values to return
  46
+     * 
  47
+     * @param topValue
  48
+     *            number of values to return
  49
+     * @return this
  50
+     */
  51
+    public DefaultListOperation<T> setTop(int topValue) {
  52
+        queryParameters.add("$top", Integer.toString(topValue));
  53
+        return this;
  54
+    }
  55
+
  56
+    /**
  57
+     * Add a "$skip" query parameter to set the number of values to skip
  58
+     * 
  59
+     * @param skipValue
  60
+     *            the number of values to skip
  61
+     * @return this
  62
+     */
  63
+    public DefaultListOperation<T> setSkip(int skipValue) {
  64
+        queryParameters.add("$skip", Integer.toString(skipValue));
  65
+        return this;
  66
+    }
  67
+
  68
+    /**
  69
+     * Add an arbitrary query parameter
  70
+     * 
  71
+     * @param parameterName
  72
+     *            name of query parameter
  73
+     * @param parameterValue
  74
+     *            value for query parameter
  75
+     * @return this
  76
+     */
  77
+    public DefaultListOperation<T> set(String parameterName, String parameterValue) {
  78
+        queryParameters.add(parameterName, parameterValue);
  79
+        return this;
  80
+    }
  81
+
44 82
     /* (non-Javadoc)
45 83
      * @see com.microsoft.windowsazure.services.media.entities.EntityListOperation#getQueryParameters()
46 84
      */
5  microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicy.java
@@ -26,7 +26,6 @@
26 26
 import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreationOperation;
27 27
 import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation;
28 28
 import com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation;
29  
-import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation;
30 29
 import com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationSingleResultBase;
31 30
 import com.sun.jersey.api.client.GenericType;
32 31
 
@@ -96,7 +95,7 @@ public Object getRequestContents() {
96 95
      * 
97 96
      * @return the operation
98 97
      */
99  
-    public static EntityListOperation<AccessPolicyInfo> list() {
  98
+    public static DefaultListOperation<AccessPolicyInfo> list() {
100 99
         return new DefaultListOperation<AccessPolicyInfo>(ENTITY_SET, new GenericType<ListResult<AccessPolicyInfo>>() {
101 100
         });
102 101
     }
@@ -108,7 +107,7 @@ public Object getRequestContents() {
108 107
      *            query parameters to add to the request
109 108
      * @return the operation
110 109
      */
111  
-    public static EntityListOperation<AccessPolicyInfo> list(MultivaluedMap<String, String> queryParameters) {
  110
+    public static DefaultListOperation<AccessPolicyInfo> list(MultivaluedMap<String, String> queryParameters) {
112 111
         return new DefaultListOperation<AccessPolicyInfo>(ENTITY_SET, new GenericType<ListResult<AccessPolicyInfo>>() {
113 112
         }, queryParameters);
114 113
     }
7  microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java
@@ -27,7 +27,6 @@
27 27
 import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation;
28 28
 import com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation;
29 29
 import com.microsoft.windowsazure.services.media.implementation.entities.EntityLinkOperation;
30  
-import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation;
31 30
 import com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationBase;
32 31
 import com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationSingleResultBase;
33 32
 import com.microsoft.windowsazure.services.media.implementation.entities.EntityProxyData;
@@ -167,7 +166,7 @@ public Creator setState(AssetState state) {
167 166
      * 
168 167
      * @return The list operation
169 168
      */
170  
-    public static EntityListOperation<AssetInfo> list() {
  169
+    public static DefaultListOperation<AssetInfo> list() {
171 170
         return new DefaultListOperation<AssetInfo>(ENTITY_SET, new GenericType<ListResult<AssetInfo>>() {
172 171
         });
173 172
     }
@@ -179,7 +178,7 @@ public Creator setState(AssetState state) {
179 178
      *            query parameters to pass to the server.
180 179
      * @return the list operation.
181 180
      */
182  
-    public static EntityListOperation<AssetInfo> list(MultivaluedMap<String, String> queryParameters) {
  181
+    public static DefaultListOperation<AssetInfo> list(MultivaluedMap<String, String> queryParameters) {
183 182
         return new DefaultListOperation<AssetInfo>(ENTITY_SET, new GenericType<ListResult<AssetInfo>>() {
184 183
         }, queryParameters);
185 184
     }
@@ -191,7 +190,7 @@ public Creator setState(AssetState state) {
191 190
      *            Link to request assets from.
192 191
      * @return The list operation.
193 192
      */
194  
-    public static EntityListOperation<AssetInfo> list(LinkInfo link) {
  193
+    public static DefaultListOperation<AssetInfo> list(LinkInfo link) {
195 194
         return new DefaultListOperation<AssetInfo>(link.getHref(), new GenericType<ListResult<AssetInfo>>() {
196 195
         });
197 196
     }
5  microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetFile.java
@@ -28,7 +28,6 @@
28 28
 import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreationOperation;
29 29
 import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation;
30 30
 import com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation;
31  
-import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation;
32 31
 import com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationBase;
33 32
 import com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationSingleResultBase;
34 33
 import com.microsoft.windowsazure.services.media.implementation.entities.EntityProxyData;
@@ -196,7 +195,7 @@ public static EntityActionOperation createFileInfos(String assetId) {
196 195
      * 
197 196
      * @return The list operation to pass to rest proxy.
198 197
      */
199  
-    public static EntityListOperation<AssetFileInfo> list() {
  198
+    public static DefaultListOperation<AssetFileInfo> list() {
200 199
         return new DefaultListOperation<AssetFileInfo>(ENTITY_SET, new GenericType<ListResult<AssetFileInfo>>() {
201 200
         });
202 201
     }
@@ -208,7 +207,7 @@ public static EntityActionOperation createFileInfos(String assetId) {
208 207
      *            asset to list files for
209 208
      * @return the list operation object
210 209
      */
211  
-    public static EntityListOperation<AssetFileInfo> list(String assetId) {
  210
+    public static DefaultListOperation<AssetFileInfo> list(String assetId) {
212 211
         String assetUri = new EntityOperationBase.EntityIdUriBuilder("Assets", assetId).getUri() + "/Files";
213 212
         return new DefaultListOperation<AssetFileInfo>(assetUri, new GenericType<ListResult<AssetFileInfo>>() {
214 213
         });
5  microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java
@@ -24,7 +24,6 @@
24 24
 import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreationOperation;
25 25
 import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation;
26 26
 import com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation;
27  
-import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation;
28 27
 import com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationSingleResultBase;
29 28
 import com.sun.jersey.api.client.GenericType;
30 29
 
@@ -155,7 +154,7 @@ public Creator setChecksum(String checksum) {
155 154
      * 
156 155
      * @return the operation
157 156
      */
158  
-    public static EntityListOperation<ContentKeyInfo> list() {
  157
+    public static DefaultListOperation<ContentKeyInfo> list() {
159 158
         return new DefaultListOperation<ContentKeyInfo>(ENTITY_SET, new GenericType<ListResult<ContentKeyInfo>>() {
160 159
         });
161 160
     }
@@ -167,7 +166,7 @@ public Creator setChecksum(String checksum) {
167 166
      *            query parameters to add to the request
168 167
      * @return the operation
169 168
      */
170  
-    public static EntityListOperation<ContentKeyInfo> list(MultivaluedMap<String, String> queryParameters) {
  169
+    public static DefaultListOperation<ContentKeyInfo> list(MultivaluedMap<String, String> queryParameters) {
171 170
         return new DefaultListOperation<ContentKeyInfo>(ENTITY_SET, new GenericType<ListResult<ContentKeyInfo>>() {
172 171
         }, queryParameters);
173 172
     }
5  microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java
@@ -40,7 +40,6 @@
40 40
 import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreationOperation;
41 41
 import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation;
42 42
 import com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation;
43  
-import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation;
44 43
 import com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationSingleResultBase;
45 44
 import com.sun.jersey.api.client.ClientResponse;
46 45
 import com.sun.jersey.api.client.GenericType;
@@ -426,7 +425,7 @@ public JobInfo getJobInfo() {
426 425
      * 
427 426
      * @return The list operation
428 427
      */
429  
-    public static EntityListOperation<JobInfo> list() {
  428
+    public static DefaultListOperation<JobInfo> list() {
430 429
         return new DefaultListOperation<JobInfo>(ENTITY_SET, new GenericType<ListResult<JobInfo>>() {
431 430
         });
432 431
     }
@@ -438,7 +437,7 @@ public JobInfo getJobInfo() {
438 437
      *            query parameters to pass to the server.
439 438
      * @return the list operation.
440 439
      */
441  
-    public static EntityListOperation<JobInfo> list(MultivaluedMap<String, String> queryParameters) {
  440
+    public static DefaultListOperation<JobInfo> list(MultivaluedMap<String, String> queryParameters) {
442 441
         return new DefaultListOperation<JobInfo>(ENTITY_SET, new GenericType<ListResult<JobInfo>>() {
443 442
         }, queryParameters);
444 443
     }
5  microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java
@@ -25,7 +25,6 @@
25 25
 import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreationOperation;
26 26
 import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation;
27 27
 import com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation;
28  
-import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation;
29 28
 import com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationBase;
30 29
 import com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationSingleResultBase;
31 30
 import com.microsoft.windowsazure.services.media.implementation.entities.EntityProxyData;
@@ -195,7 +194,7 @@ public Creator setContentAccessComponent(String contentAccessComponent) {
195 194
      * 
196 195
      * @return the list operation
197 196
      */
198  
-    public static EntityListOperation<LocatorInfo> list() {
  197
+    public static DefaultListOperation<LocatorInfo> list() {
199 198
         return new DefaultListOperation<LocatorInfo>(ENTITY_SET, new GenericType<ListResult<LocatorInfo>>() {
200 199
         });
201 200
     }
@@ -207,7 +206,7 @@ public Creator setContentAccessComponent(String contentAccessComponent) {
207 206
      *            query parameters to send with the request
208 207
      * @return the list operation
209 208
      */
210  
-    public static EntityListOperation<LocatorInfo> list(MultivaluedMap<String, String> queryParameters) {
  209
+    public static DefaultListOperation<LocatorInfo> list(MultivaluedMap<String, String> queryParameters) {
211 210
         return new DefaultListOperation<LocatorInfo>(ENTITY_SET, new GenericType<ListResult<LocatorInfo>>() {
212 211
         }, queryParameters);
213 212
     }
5  microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/MediaProcessor.java
@@ -18,7 +18,6 @@
18 18
 import javax.ws.rs.core.MultivaluedMap;
19 19
 
20 20
 import com.microsoft.windowsazure.services.media.implementation.entities.DefaultListOperation;
21  
-import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation;
22 21
 import com.sun.jersey.api.client.GenericType;
23 22
 
24 23
 /**
@@ -37,7 +36,7 @@ private MediaProcessor() {
37 36
      * 
38 37
      * @return the list operation
39 38
      */
40  
-    public static EntityListOperation<MediaProcessorInfo> list() {
  39
+    public static DefaultListOperation<MediaProcessorInfo> list() {
41 40
         return new DefaultListOperation<MediaProcessorInfo>(ENTITY_SET,
42 41
                 new GenericType<ListResult<MediaProcessorInfo>>() {
43 42
                 });
@@ -50,7 +49,7 @@ private MediaProcessor() {
50 49
      *            query parameters to pass with the request
51 50
      * @return the list operation
52 51
      */
53  
-    public static EntityListOperation<MediaProcessorInfo> list(MultivaluedMap<String, String> queryParameters) {
  52
+    public static DefaultListOperation<MediaProcessorInfo> list(MultivaluedMap<String, String> queryParameters) {
54 53
         return new DefaultListOperation<MediaProcessorInfo>(ENTITY_SET,
55 54
                 new GenericType<ListResult<MediaProcessorInfo>>() {
56 55
                 }, queryParameters);
5  microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java
@@ -22,7 +22,6 @@
22 22
 import com.microsoft.windowsazure.services.media.implementation.entities.DefaultListOperation;
23 23
 import com.microsoft.windowsazure.services.media.implementation.entities.EntityBatchOperation;
24 24
 import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation;
25  
-import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation;
26 25
 import com.sun.jersey.api.client.GenericType;
27 26
 
28 27
 /**
@@ -61,7 +60,7 @@ public static CreateBatchOperation create(String mediaProcessorId, String taskBo
61 60
      * 
62 61
      * @return The list operation
63 62
      */
64  
-    public static EntityListOperation<TaskInfo> list() {
  63
+    public static DefaultListOperation<TaskInfo> list() {
65 64
         return new DefaultListOperation<TaskInfo>(ENTITY_SET, new GenericType<ListResult<TaskInfo>>() {
66 65
         });
67 66
     }
@@ -73,7 +72,7 @@ public static CreateBatchOperation create(String mediaProcessorId, String taskBo
73 72
      *            query parameters to pass to the server.
74 73
      * @return the list operation.
75 74
      */
76  
-    public static EntityListOperation<TaskInfo> list(MultivaluedMap<String, String> queryParameters) {
  75
+    public static DefaultListOperation<TaskInfo> list(MultivaluedMap<String, String> queryParameters) {
77 76
         return new DefaultListOperation<TaskInfo>(ENTITY_SET, new GenericType<ListResult<TaskInfo>>() {
78 77
         }, queryParameters);
79 78
     }
8  ...osoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java
@@ -21,8 +21,6 @@
21 21
 import java.util.EnumSet;
22 22
 import java.util.List;
23 23
 
24  
-import javax.ws.rs.core.MultivaluedMap;
25  
-
26 24
 import org.junit.Test;
27 25
 
28 26
 import com.microsoft.windowsazure.services.core.ExponentialRetryPolicy;
@@ -31,7 +29,6 @@
31 29
 import com.microsoft.windowsazure.services.media.models.AccessPolicy;
32 30
 import com.microsoft.windowsazure.services.media.models.AccessPolicyInfo;
33 31
 import com.microsoft.windowsazure.services.media.models.AccessPolicyPermission;
34  
-import com.sun.jersey.core.util.MultivaluedMapImpl;
35 32
 
36 33
 public class AccessPolicyIntegrationTest extends IntegrationTestBase {
37 34
     private void verifyInfosEqual(String message, AccessPolicyInfo expected, AccessPolicyInfo actual) {
@@ -153,10 +150,7 @@ public void canUseQueryParametersWhenListingAccessPolicies() throws Exception {
153 150
             expectedAccessPolicies.add(policy);
154 151
         }
155 152
 
156  
-        MultivaluedMap<String, String> options = new MultivaluedMapImpl();
157  
-        options.add("$top", "2");
158  
-
159  
-        List<AccessPolicyInfo> actualAccessPolicies = service.list(AccessPolicy.list(options));
  153
+        List<AccessPolicyInfo> actualAccessPolicies = service.list(AccessPolicy.list().setTop(2));
160 154
 
161 155
         assertEquals(2, actualAccessPolicies.size());
162 156
     }
5  microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java
@@ -39,7 +39,6 @@
39 39
 import com.microsoft.windowsazure.services.media.models.ContentKey;
40 40
 import com.microsoft.windowsazure.services.media.models.ContentKeyInfo;
41 41
 import com.microsoft.windowsazure.services.media.models.ContentKeyType;
42  
-import com.sun.jersey.core.util.MultivaluedMapImpl;
43 42
 
44 43
 public class AssetIntegrationTest extends IntegrationTestBase {
45 44
 
@@ -199,9 +198,7 @@ public void canListAssetsWithOptions() throws ServiceException {
199 198
             expectedAssets.add(service.create(Asset.create().setName(name)));
200 199
         }
201 200
 
202  
-        MultivaluedMapImpl options = new MultivaluedMapImpl();
203  
-        options.add("$top", "2");
204  
-        Collection<AssetInfo> listAssetResult = service.list(Asset.list(options));
  201
+        Collection<AssetInfo> listAssetResult = service.list(Asset.list().setTop(2));
205 202
 
206 203
         // Assert
207 204
 
8  microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ContentKeyIntegrationTest.java
@@ -21,8 +21,6 @@
21 21
 import java.util.List;
22 22
 import java.util.UUID;
23 23
 
24  
-import javax.ws.rs.core.MultivaluedMap;
25  
-
26 24
 import org.junit.Test;
27 25
 
28 26
 import com.microsoft.windowsazure.services.core.ServiceException;
@@ -30,7 +28,6 @@
30 28
 import com.microsoft.windowsazure.services.media.models.ContentKeyInfo;
31 29
 import com.microsoft.windowsazure.services.media.models.ContentKeyType;
32 30
 import com.microsoft.windowsazure.services.media.models.ProtectionKeyType;
33  
-import com.sun.jersey.core.util.MultivaluedMapImpl;
34 31
 
35 32
 public class ContentKeyIntegrationTest extends IntegrationTestBase {
36 33
 
@@ -138,10 +135,7 @@ public void canUseQueryParametersWhenListingContentKeys() throws Exception {
138 135
             expectedContentKeys.add(contentKeyInfo);
139 136
         }
140 137
 
141  
-        MultivaluedMap<String, String> options = new MultivaluedMapImpl();
142  
-        options.add("$top", "2");
143  
-
144  
-        List<ContentKeyInfo> actualContentKeys = service.list(ContentKey.list(options));
  138
+        List<ContentKeyInfo> actualContentKeys = service.list(ContentKey.list().setTop(2));
145 139
 
146 140
         assertEquals(2, actualContentKeys.size());
147 141
     }
12  microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EntityProxyTest.java
@@ -5,15 +5,12 @@
5 5
 import java.util.HashSet;
6 6
 import java.util.Set;
7 7
 
8  
-import javax.ws.rs.core.MultivaluedMap;
9  
-
10 8
 import org.junit.BeforeClass;
11 9
 import org.junit.Test;
12 10
 
13 11
 import com.microsoft.windowsazure.services.media.models.Asset;
14 12
 import com.microsoft.windowsazure.services.media.models.AssetInfo;
15 13
 import com.microsoft.windowsazure.services.media.models.ListResult;
16  
-import com.sun.jersey.core.util.MultivaluedMapImpl;
17 14
 
18 15
 public class EntityProxyTest extends IntegrationTestBase {
19 16
     private static MediaContract entityService;
@@ -80,10 +77,7 @@ public void canListAllAssets() throws Exception {
80 77
     public void canListAssetsWithQueryParameters() throws Exception {
81 78
         createTestAssets(4, "withQuery");
82 79
 
83  
-        MultivaluedMap<String, String> params = new MultivaluedMapImpl();
84  
-        params.add("$top", "2");
85  
-
86  
-        ListResult<AssetInfo> assets = entityService.list(Asset.list(params));
  80
+        ListResult<AssetInfo> assets = entityService.list(Asset.list().setTop(2));
87 81
 
88 82
         assertEquals(2, assets.size());
89 83
     }
@@ -130,8 +124,8 @@ public void canDeleteAssetsById() throws Exception {
130 124
         Set<String> expectedAssets = new HashSet<String>();
131 125
 
132 126
         for (int i = 0; i < numAssets; ++i) {
133  
-            AssetInfo asset = entityService.create(Asset.create()
134  
-                    .setName(testAssetPrefix + namePart + Integer.toString(i)));
  127
+            AssetInfo asset = entityService.create(Asset.create().setName(
  128
+                    testAssetPrefix + namePart + Integer.toString(i)));
135 129
             expectedAssets.add(asset.getId());
136 130
         }
137 131
         return expectedAssets;
7  microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java
@@ -25,8 +25,6 @@
25 25
 import java.util.List;
26 26
 import java.util.UUID;
27 27
 
28  
-import javax.ws.rs.core.MultivaluedMap;
29  
-
30 28
 import org.junit.BeforeClass;
31 29
 import org.junit.Test;
32 30
 
@@ -44,7 +42,6 @@
44 42
 import com.microsoft.windowsazure.services.media.models.LocatorInfo;
45 43
 import com.microsoft.windowsazure.services.media.models.Task;
46 44
 import com.microsoft.windowsazure.services.media.models.Task.CreateBatchOperation;
47  
-import com.sun.jersey.core.util.MultivaluedMapImpl;
48 45
 
49 46
 public class JobIntegrationTest extends IntegrationTestBase {
50 47
 
@@ -225,9 +222,7 @@ public void canListJobsWithOptions() throws ServiceException {
225 222
             expectedJobs.add(jobInfo);
226 223
         }
227 224
 
228  
-        MultivaluedMap<String, String> queryParameters = new MultivaluedMapImpl();
229  
-        queryParameters.add("$top", "2");
230  
-        ListResult<JobInfo> listJobsResult = service.list(Job.list(queryParameters));
  225
+        ListResult<JobInfo> listJobsResult = service.list(Job.list().setTop(2));
231 226
 
232 227
         // Assert
233 228
         assertEquals(2, listJobsResult.size());
13  microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java
@@ -37,7 +37,6 @@
37 37
 import com.microsoft.windowsazure.services.media.models.Locator;
38 38
 import com.microsoft.windowsazure.services.media.models.LocatorInfo;
39 39
 import com.microsoft.windowsazure.services.media.models.LocatorType;
40  
-import com.sun.jersey.core.util.MultivaluedMapImpl;
41 40
 
42 41
 public class LocatorIntegrationTests extends IntegrationTestBase {
43 42
 
@@ -213,12 +212,12 @@ public void listLocatorsWithOptions() throws ServiceException {
213 212
                     LocatorType.SAS)));
214 213
         }
215 214
 
216  
-        MultivaluedMapImpl options = new MultivaluedMapImpl();
217  
-        options.add("$filter", "(Id eq '" + expectedLocators.get(1).getId() + "') or (" + "Id eq '"
218  
-                + expectedLocators.get(3).getId() + "')");
219  
-        options.add("$top", "3");
220  
-
221  
-        ListResult<LocatorInfo> result = service.list(Locator.list(options));
  215
+        ListResult<LocatorInfo> result = service.list(Locator
  216
+                .list()
  217
+                .setTop(3)
  218
+                .set("$filter",
  219
+                        "(Id eq '" + expectedLocators.get(1).getId() + "') or (" + "Id eq '"
  220
+                                + expectedLocators.get(3).getId() + "')"));
222 221
 
223 222
         assertEquals(2, result.size());
224 223
     }
14  ...oft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaProcessorIntegrationTest.java
@@ -19,15 +19,12 @@
19 19
 
20 20
 import java.util.List;
21 21
 
22  
-import javax.ws.rs.core.MultivaluedMap;
23  
-
24 22
 import org.junit.Test;
25 23
 
26 24
 import com.microsoft.windowsazure.services.core.ServiceException;
27 25
 import com.microsoft.windowsazure.services.media.models.ListResult;
28 26
 import com.microsoft.windowsazure.services.media.models.MediaProcessor;
29 27
 import com.microsoft.windowsazure.services.media.models.MediaProcessorInfo;
30  
-import com.sun.jersey.core.util.MultivaluedMapImpl;
31 28
 
32 29
 public class MediaProcessorIntegrationTest extends IntegrationTestBase {
33 30
 
@@ -69,16 +66,9 @@ public void listMediaProcessorsSuccess() throws ServiceException {
69 66
 
70 67
     @Test
71 68
     public void listMediaProcessorWithOptionSuccess() throws ServiceException {
72  
-        // Arrange
73  
-        MultivaluedMap<String, String> queryParameters = new MultivaluedMapImpl();
74  
-        queryParameters.add("$filter", "Id eq 'nb:mpid:UUID:aec03716-7c5e-4f68-b592-f4850eba9f10'");
75  
-        queryParameters.add("$top", "2");
  69
+        ListResult<MediaProcessorInfo> listMediaProcessorsResult = service.list(MediaProcessor.list().setTop(2)
  70
+                .set("$filter", "Id eq 'nb:mpid:UUID:aec03716-7c5e-4f68-b592-f4850eba9f10'"));
76 71
 
77  
-        // Act
78  
-        ListResult<MediaProcessorInfo> listMediaProcessorsResult = service.list(MediaProcessor
79  
-                .list(queryParameters));
80  
-
81  
-        // Assert
82 72
         assertNotNull("listMediaProcessorsResult", listMediaProcessorsResult);
83 73
         assertEquals("listMediaProcessors size", 1, listMediaProcessorsResult.size());
84 74
         MediaProcessorInfo mediaProcessorInfo = listMediaProcessorsResult.get(0);
10  microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetEntityTest.java
@@ -111,6 +111,16 @@ public void assetListCanTakeQueryParameters() {
111 111
     }
112 112
 
113 113
     @Test
  114
+    public void assetListCanTakeQueryParametersChained() {
  115
+        EntityListOperation<AssetInfo> lister = Asset.list().setTop(10).setSkip(2).set("filter", "something");
  116
+
  117
+        assertEquals("10", lister.getQueryParameters().getFirst("$top"));
  118
+        assertEquals("2", lister.getQueryParameters().getFirst("$skip"));
  119
+        assertEquals("something", lister.getQueryParameters().getFirst("filter"));
  120
+        assertEquals(3, lister.getQueryParameters().size());
  121
+    }
  122
+
  123
+    @Test
114 124
     public void assetUpdateReturnsExpectedUri() throws Exception {
115 125
         EntityUpdateOperation updater = Asset.update(sampleAssetId);
116 126
         assertEquals(expectedUri, updater.getUri());
8  microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java
@@ -116,11 +116,9 @@ public AssetInfo createAsset(String name, AssetOption encryption) throws Service
116 116
             throws ServiceException {
117 117
         List<ListResult<AssetInfo>> pages = new ArrayList<ListResult<AssetInfo>>();
118 118
         for (int skip = 0; true; skip += pageSize) {
119  
-            EntityListOperation<AssetInfo> listOperation = Asset.list();
120  
-            listOperation.getQueryParameters().add("$skip", skip + "");
121  
-            listOperation.getQueryParameters().add("$top", pageSize + "");
122  
-            listOperation.getQueryParameters().add("$filter", "startswith(Name,'" + rootName + "')");
123  
-            listOperation.getQueryParameters().add("$orderby", "Name");
  119
+            EntityListOperation<AssetInfo> listOperation = Asset.list().setTop(pageSize).setSkip(skip)
  120
+                    .set("$filter", "startswith(Name,'" + rootName + "')").set("$orderby", "Name");
  121
+
124 122
             ListResult<AssetInfo> listAssetResult = service.list(listOperation);
125 123
             pages.add(listAssetResult);
126 124
             if (listAssetResult.size() == 0) {

0 notes on commit 5a0876b

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