Skip to content

Commit

Permalink
Merge pull request #39 from jcookems/fix236
Browse files Browse the repository at this point in the history
Fix236: EdmType.GUID should map to java.util.UUID
  • Loading branch information
Albert Cheng committed Apr 6, 2012
2 parents e629c80 + 2c82f1e commit 640093e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import java.text.ParseException;
import java.util.Date;
import java.util.UUID;

import javax.inject.Inject;

Expand Down Expand Up @@ -80,6 +81,9 @@ else if (EdmType.INT64.equals(edmType)) {
else if (EdmType.BINARY.equals(edmType)) {
return Base64.decode(value);
}
else if (EdmType.GUID.equals(edmType)) {
return UUID.fromString(value);
}

return value;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,10 +302,12 @@ public void insertEntityWorks() throws Exception {
Configuration config = createConfiguration();
TableContract service = TableService.create(config);
byte[] binaryData = new byte[] { 1, 2, 3, 4 };
UUID uuid = UUID.randomUUID();
Entity entity = new Entity().setPartitionKey("001").setRowKey("insertEntityWorks")
.setProperty("test", EdmType.BOOLEAN, true).setProperty("test2", EdmType.STRING, "value")
.setProperty("test3", EdmType.INT32, 3).setProperty("test4", EdmType.INT64, 12345678901L)
.setProperty("test5", EdmType.DATETIME, new Date()).setProperty("test6", EdmType.BINARY, binaryData);
.setProperty("test5", EdmType.DATETIME, new Date()).setProperty("test6", EdmType.BINARY, binaryData)
.setProperty("test7", EdmType.GUID, uuid);

// Act
InsertEntityResult result = service.insertEntity(TEST_TABLE_2, entity);
Expand Down Expand Up @@ -341,6 +343,10 @@ public void insertEntityWorks() throws Exception {
for (int i = 0; i < binaryData.length; i++) {
assertEquals(binaryData[i], returnedBinaryData[i]);
}

assertNotNull(result.getEntity().getProperty("test7"));
assertTrue(result.getEntity().getProperty("test7").getValue() instanceof UUID);
assertEquals(uuid.toString(), result.getEntity().getProperty("test7").getValue().toString());
}

@Test
Expand Down

0 comments on commit 640093e

Please sign in to comment.