### Question:
SparqlUpdateHelper { public static String createSparqlDelete(String subjUri, Property property, Object object) { String subjString = getSubjectString(subjUri); StringBuilder query = new StringBuilder(); query.append("DELETE { "); query.append(subjString).append(" <").append(property.getURI()).append('>'); if (object == null) { query.append(" ?obj . }\n"); } else { query.append(' ').append(getObjectAsString(object)).append(" . }\n"); } query.append("\nWHERE {"); if (object == null) { query.append(subjString).append(" <").append(property.getURI()).append("> ?obj . }"); } else { query.append('}'); } return query.toString(); } private  SparqlUpdateHelper(); static String createSparqlInsert(Model model); static String createSparqlInsert(String subjUri, Property property,
            Object object); static String createSparqlReplace(String subjUri, Property property, Object object); static String createSparqlReplace(String subjUri, Property property,
            Object object, List<Object> previousValues); static String createSparqlDelete(String subjUri, Property property, Object object); static String getObjectAsString(Object object);  }### Answer:
@Test public void createSparqlDeleteWithObject() { String deleteTitle = "Delete me"; String retainTitle = "Keep me"; String sparql = SparqlUpdateHelper.createSparqlDelete(RESC_URI, DC.title, deleteTitle); Model model = ModelFactory.createDefaultModel(); Resource resc = model.getResource(RESC_URI); resc.addProperty(DC.title, retainTitle); resc.addProperty(DC.title, deleteTitle); UpdateRequest request = UpdateFactory.create(sparql); UpdateAction.execute(request, model); StmtIterator stmtIt = resc.listProperties(DC.title); assertEquals(retainTitle, stmtIt.next().getString()); assertFalse(stmtIt.hasNext()); }
@Test public void createSparqlDeleteNullObject() { String sparql = SparqlUpdateHelper.createSparqlDelete(RESC_URI, DC.title, null); Model model = ModelFactory.createDefaultModel(); Resource resc = model.getResource(RESC_URI); resc.addProperty(DC.title, "Title1"); resc.addProperty(DC.title, "Title2"); UpdateRequest request = UpdateFactory.create(sparql); UpdateAction.execute(request, model); assertFalse(resc.hasProperty(DC.title)); }