### Question:
SparqlUpdateHelper { public static String createSparqlInsert(Model model) { StringBuilder query = new StringBuilder(); query.append("INSERT {\n"); ResIterator it = model.listSubjects(); while (it.hasNext()) { Resource resc = it.nextResource(); String currentUri = resc.getURI(); StmtIterator pIt = resc.listProperties(); while (pIt.hasNext()) { Statement property = pIt.nextStatement(); query.append(" <").append(currentUri).append('>').append(" <") .append(property.getPredicate().getURI()).append("> "); if (property.getObject().isResource()) { query.append('<') .append(property.getObject().asResource().getURI()) .append('>'); } else { Node node = property.getObject().asNode(); query.append('"').append(node.getLiteralLexicalForm()) .append('"'); String typeUri = node.getLiteralDatatypeURI(); if (typeUri != null) { query.append("^^<") .append(node.getLiteralDatatypeURI()) .append('>'); } } query.append(" .\n"); } } query.append("}\nWHERE {}"); 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 createSparqlInsertTest() { Property booleanProperty = createProperty("http: Model insertModel = ModelFactory.createDefaultModel(); Resource resc = insertModel.createResource(RESC_URI); resc.addProperty(RDF.type, Cdr.Collection); resc.addLiteral(booleanProperty, false); resc.addProperty(DcElements.title, "Title"); String hashUri = RESC_URI + "#event"; Resource hashResc = insertModel.createResource(hashUri); hashResc.addProperty(RDF.type, Premis.Capture); String query = SparqlUpdateHelper.createSparqlInsert(insertModel); Model destModel = ModelFactory.createDefaultModel(); Resource destResc = destModel.createResource(RESC_URI); destResc.addProperty(RDF.type, Fcrepo4Repository.Container); UpdateAction.parseExecute(query, destModel); assertTrue(destResc.hasProperty(RDF.type, Cdr.Collection)); assertTrue(destResc.hasProperty(DcElements.title, "Title")); destResc.getProperty(booleanProperty).getBoolean(); Resource destHash = destModel.getResource(hashUri); assertTrue(destHash.hasProperty(RDF.type, Premis.Capture)); }
@Test public void createSparqlSingleResourceInsertTest() { String query = SparqlUpdateHelper.createSparqlInsert(RESC_URI, RDF.type, PcdmModels.Object); Model destModel = ModelFactory.createDefaultModel(); Resource destResc = destModel.createResource(RESC_URI); destResc.addProperty(RDF.type, Fcrepo4Repository.Container); UpdateAction.parseExecute(query, destModel); assertTrue(destResc.hasProperty(RDF.type, Fcrepo4Repository.Container)); assertTrue(destResc.hasProperty(RDF.type, PcdmModels.Object)); }