From c884a331b186c3e2848c72f2f4b770ebae292e69 Mon Sep 17 00:00:00 2001 From: Jason Cooke Date: Thu, 5 Apr 2012 15:30:42 -0700 Subject: [PATCH 1/2] Fix 236: Table: EdmType.GUID should map to java.util.UUID --- .../table/implementation/DefaultEdmValueConterter.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/DefaultEdmValueConterter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/DefaultEdmValueConterter.java index 698859697949..d35293670c1b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/DefaultEdmValueConterter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/DefaultEdmValueConterter.java @@ -16,6 +16,7 @@ import java.text.ParseException; import java.util.Date; +import java.util.UUID; import javax.inject.Inject; @@ -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; } From 2c82f1eea61e915f5dd104a8b2b06ee8c247a41b Mon Sep 17 00:00:00 2001 From: Jason Cooke Date: Thu, 5 Apr 2012 15:52:36 -0700 Subject: [PATCH 2/2] Added unit test for round-tripping UUID values --- .../services/table/TableServiceIntegrationTest.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/TableServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/TableServiceIntegrationTest.java index 88a4e0c1c130..55fc4c14fb3a 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/TableServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/TableServiceIntegrationTest.java @@ -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); @@ -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