@Override public boolean equals(Object o) { if (this == o) { return true; } if (o instanceof Model) { Model model = (Model)o; return Models.isomorphic(this, model); } return false; }
/** * Compares two RDF models, defined by two statement collections, and returns * <tt>true</tt> if they are equal. Models are equal if they contain the same * set of statements. Blank node IDs are not relevant for model equality, * they are mapped from one model to the other by using the attached * properties. * * @deprecated since 2.8.0. Use {@link Models#isomorphic(Iterable, Iterable)} * instead. */ @Deprecated public static boolean equals(Iterable<? extends Statement> model1, Iterable<? extends Statement> model2) { return isomorphic(model1, model2); }
private void assertModel(Model expectedModel) { if(logger.isTraceEnabled()) { logger.trace("Expected: {}", expectedModel); logger.trace("Actual: {}", testStatements); } assertTrue("Did not find expected statements", Models.isomorphic(expectedModel, testStatements)); }
private void compareGraphs(Iterable<? extends Statement> actual, Iterable<? extends Statement> expected) throws Exception { if (!Models.isomorphic(expected, actual)) { StringBuilder message = new StringBuilder(128); message.append("\n============ "); message.append(getName()); message.append(" =======================\n"); message.append("Expected result: \n"); for (Statement st : expected) { message.append(st.toString()); message.append("\n"); } message.append("============="); StringUtil.appendN('=', getName().length(), message); message.append("========================\n"); message.append("Actual result: \n"); for (Statement st : actual) { message.append(st.toString()); message.append("\n"); } message.append("============="); StringUtil.appendN('=', getName().length(), message); message.append("========================\n"); logger.error(message.toString()); fail(message.toString()); } }
/** * Compares two graph query results and returns {@code true} if they are * equal. Two graph query results are considered equal if they are isomorphic * graphs. Note that the method consumes both query results fully. * * @param result1 * the first query result to compare * @param result2 * the second query result to compare. * @return {@code true} iff the supplied graph query results are isomorphic * graphs, {@code false} otherwise. * @throws QueryEvaluationException * @see {@link Models#isomorphic(Iterable, Iterable)} */ public static boolean equals(GraphQueryResult result1, GraphQueryResult result2) throws QueryEvaluationException { Set<? extends Statement> graph1 = Iterations.asSet(result1); Set<? extends Statement> graph2 = Iterations.asSet(result2); return Models.isomorphic(graph1, graph2); }
private void testFilesEqual(String file1, String file2) throws Exception { Set<Statement> model1 = loadModel(file1); Set<Statement> model2 = loadModel(file2); // long startTime = System.currentTimeMillis(); boolean modelsEqual = Models.isomorphic(model1, model2); // long endTime = System.currentTimeMillis(); // System.out.println("Model equality checked in " + (endTime - startTime) // + "ms (" + file1 + ", " + file2 // + ")"); assertTrue(modelsEqual); }
protected final void compareGraphs(Set<Statement> queryResult, Set<Statement> expectedResult) throws Exception if (!Models.isomorphic(expectedResult, queryResult)) {
if (!Models.isomorphic(inputCollection, outputCollection)) { System.err.println("===models not equal===");
if (!Models.isomorphic(inputCollection, outputCollection)) { System.err.println("===models not equal==="); System.err.println("Expected: " + outputCollection);
if (!Models.isomorphic(inputCollection, outputCollection)) { System.err.println("===models not equal==="); System.err.println("Expected: " + outputCollection);
if (!Models.isomorphic(inputCollection, outputCollection)) { StringBuilder sb = new StringBuilder(1024); sb.append("models not equal\n");
if (!Models.isomorphic(actualStatements, expectedStatements)) {