newProperties.put(propertyName, updatedPropertyValue);
String newPropertyName = "newPropertyName";
String newPropertyValue = "newPropertyValue";
newProperties.put(newPropertyName, newPropertyValue);
newProperties.put(propertyNameToDelete, null);
updatedElementsIn.add(new Gadget(newProperties));
OperationRequest updateOperation =
operationRequest(OperationType.DOCUMENT_MODIFY, rootBlipId,
Parameter.of(ParamsProperty.MODIFY_ACTION,
new DocumentModifyAction(ModifyHow.UPDATE_ELEMENT,
NO_VALUES, NO_ANNOTATION_KEY, updatedElementsIn, NO_BUNDLED_ANNOTATIONS, false)),
Parameter.of(ParamsProperty.MODIFY_QUERY, new DocumentModifyQuery(ElementType.GADGET,
ImmutableMap.of("url", gadgetUrl), 1)));
service.execute(updateOperation, helper.getContext(), ALEX);
Gadget gadget = null;
List<ElementInfo> elementsOut = getApiView().getElements();
for (ElementInfo elementOut : elementsOut) {
if (elementOut.element.isGadget()) {
gadget = (Gadget) elementOut.element;
}
}
assertEquals(gadgetUrl, gadget.getUrl());
assertEquals(ALEX.getAddress(), gadget.getAuthor());
assertEquals(updatedPropertyValue, gadget.getProperty(propertyName));
assertNotNull(gadget.getProperty(newPropertyName));
assertEquals(newPropertyValue, gadget.getProperty(newPropertyName));
assertNull(gadget.getProperty(propertyNameToDelete));
}