@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; }
@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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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 compareGraphs(Set<Statement> queryResult, Set<Statement> expectedResult) throws Exception if (!Models.isomorphic(expectedResult, queryResult)) {
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); }
if (!Models.isomorphic(actualStatements, expectedStatements)) {
/** * Compares the models in the default contexts of the two supplied repositories and returns true if they * are equal. Models are equal if they contain the same set of statements. bNodes IDs are not relevant for * model equality, they are mapped from one model to the other by using the attached properties. Note that * the method pulls the entire default context of both repositories into main memory. Use with caution. */ public static boolean equals(Repository rep1, Repository rep2) throws RepositoryException { // Fetch statements from rep1 and rep2 Set<Statement> model1, model2; try (RepositoryConnection con1 = rep1.getConnection()) { model1 = Iterations.asSet(con1.getStatements(null, null, null, true)); } try (RepositoryConnection con2 = rep2.getConnection()) { model2 = Iterations.asSet(con2.getStatements(null, null, null, true)); } return Models.isomorphic(model1, model2); }
public static void assertRDFFilesIsomorphic(File expected, File actual, RDFFormat format) throws Exception { final RDFFormat expectedFormat; final RDFFormat actualFormat; if (format == null) { final RDFParserRegistry registry = RDFParserRegistry.getInstance(); expectedFormat = registry.getFileFormatForFileName(expected.getName()).orElse(null); actualFormat = registry.getFileFormatForFileName(actual.getName()).orElse(null); assertNotNull("Can't guess the expected file format", expectedFormat); assertNotNull("Can't guess the actual file format", actualFormat); } else { expectedFormat = format; actualFormat = format; } final Model expectedModel; final Model actualModel; try (final InputStream expectedStream = new FileInputStream(expected); final InputStream actualStream = new FileInputStream(actual)) { expectedModel = Rio.parse(expectedStream, "base://", expectedFormat); actualModel = Rio.parse(actualStream, "base://", actualFormat); } assertTrue("RDF files are not isomorphic", Models.isomorphic(expectedModel, actualModel)); }
/** * Compares the models in the default contexts of the two supplied repositories and returns true if they * are equal. Models are equal if they contain the same set of statements. bNodes IDs are not relevant for * model equality, they are mapped from one model to the other by using the attached properties. Note that * the method pulls the entire default context of both repositories into main memory. Use with caution. */ public static boolean equals(Repository rep1, Repository rep2) throws RepositoryException { // Fetch statements from rep1 and rep2 Set<Statement> model1, model2; RepositoryConnection con1 = rep1.getConnection(); try { model1 = Iterations.asSet(con1.getStatements(null, null, null, true)); } finally { con1.close(); } RepositoryConnection con2 = rep2.getConnection(); try { model2 = Iterations.asSet(con2.getStatements(null, null, null, true)); } finally { con2.close(); } return Models.isomorphic(model1, model2); }