Permalink
Browse files

Adding a couple more unit test for query entities

Also adding escape mechanism for expressing filters
  • Loading branch information...
1 parent 06146b7 commit 8fdbcf75d024c17cd220c37b32c668a1b1f9578f Renaud Paquay committed with lodejard Jan 12, 2012
@@ -48,6 +48,7 @@
import com.microsoft.windowsazure.services.table.models.QueryEntitiesResult;
import com.microsoft.windowsazure.services.table.models.QueryTablesOptions;
import com.microsoft.windowsazure.services.table.models.QueryTablesResult;
+import com.microsoft.windowsazure.services.table.models.RawStringFilter;
import com.microsoft.windowsazure.services.table.models.ServiceProperties;
import com.microsoft.windowsazure.services.table.models.TableServiceOptions;
import com.microsoft.windowsazure.services.table.models.UnaryFilter;
@@ -188,6 +189,9 @@ else if (filter instanceof BinaryFilter) {
buildFilterExpression(((BinaryFilter) filter).getRight(), sb);
sb.append(")");
}
+ else if (filter instanceof RawStringFilter) {
+ sb.append(((RawStringFilter) filter).getRawString());
+ }
}
private Builder addOptionalHeader(Builder builder, String name, Object value) {
@@ -44,4 +44,8 @@ public static ConstantFilter constant(Object value) {
public static LitteralFilter litteral(String value) {
return new LitteralFilter().setLitteral(value);
}
+
+ public static RawStringFilter rawString(String value) {
+ return new RawStringFilter().setRawString(value);
+ }
}
@@ -0,0 +1,14 @@
+package com.microsoft.windowsazure.services.table.models;
+
+public class RawStringFilter extends Filter {
+ private String rawString;
+
+ public String getRawString() {
+ return rawString;
+ }
+
+ public RawStringFilter setRawString(String rawString) {
+ this.rawString = rawString;
+ return this;
+ }
+}
@@ -581,15 +581,27 @@ public void queryEntitiesWithFilterWorks() throws Exception {
service.insertEntity(table, entity);
}
- // Act
- QueryEntitiesResult result = service.queryEntities(
- table,
- new QueryEntitiesOptions().setQuery(new Query().setFilter(Filter.eq(Filter.litteral("RowKey"),
- Filter.constant("queryEntitiesWithFilterWorks-3")))));
+ {
+ // Act
+ QueryEntitiesResult result = service.queryEntities(table,
+ new QueryEntitiesOptions().setQuery(new Query().setFilter(Filter.eq(Filter.litteral("RowKey"),
+ Filter.constant("queryEntitiesWithFilterWorks-3")))));
- // Assert
- assertNotNull(result);
- assertEquals(1, result.getEntities().size());
- assertEquals("queryEntitiesWithFilterWorks-3", result.getEntities().get(0).getRowKey());
+ // Assert
+ assertNotNull(result);
+ assertEquals(1, result.getEntities().size());
+ assertEquals("queryEntitiesWithFilterWorks-3", result.getEntities().get(0).getRowKey());
+ }
+
+ {
+ // Act
+ QueryEntitiesResult result = service.queryEntities(table, new QueryEntitiesOptions().setQuery(new Query()
+ .setFilter(Filter.rawString("RowKey eq 'queryEntitiesWithFilterWorks-3'"))));
+
+ // Assert
+ assertNotNull(result);
+ assertEquals(1, result.getEntities().size());
+ assertEquals("queryEntitiesWithFilterWorks-3", result.getEntities().get(0).getRowKey());
+ }
}
}

0 comments on commit 8fdbcf7

Please sign in to comment.