private void multiUpdateRetrieveAndDeleteFromOrkut(boolean useRest) {
Random generator = new Random();
String randomValue1 = String.valueOf(generator.nextInt());
String randomValue2 = String.valueOf(generator.nextInt());
Client client = new Client(new OrkutSandboxProvider(useRest),
new OAuth2LeggedScheme(ORKUT_KEY, ORKUT_SECRET, ORKUT_ID));
try {
Map<String, String> data = new HashMap<String, String>();
data.put("key1", randomValue1);
data.put("key2", randomValue2);
Request request = AppDataService.updateAppData(data);
client.send(request);
} catch (Exception e) {
fail("Exception occurred while processing update request");
}
try {
Request request = AppDataService.getAppData();
Response response = client.send(request);
AppData data = response.getEntry();
assertTrue(data.getDataForUser(ORKUT_ID, "key1").equals(randomValue1));
assertTrue(data.getDataForUser(ORKUT_ID, "key2").equals(randomValue2));
} catch (Exception e) {
fail("Exception occurred while processing retrieve request");
}
try {
Request request = AppDataService.deleteAppData(
new String[] {"key1", "key2"});
client.send(request);
} catch (Exception e) {
fail("Exception occurred while processing delete request");
}
try {
Request request = AppDataService.getAppData();
Response response = client.send(request);
AppData data = response.getEntry();
assertTrue(data.hasField(ORKUT_ID));
assertTrue(data.getDataForUser(ORKUT_ID, "key1") == null);
assertTrue(data.getDataForUser(ORKUT_ID, "key2") == null);