Skip to content

Commit

Permalink
GH-4544 core/model java test cases changed
Browse files Browse the repository at this point in the history
Signed-off-by: Jerven Bolleman <[email protected]>
  • Loading branch information
JervenBolleman committed May 22, 2023
1 parent 2e6fea7 commit d95f112
Show file tree
Hide file tree
Showing 12 changed files with 99 additions and 99 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
*******************************************************************************/
package org.eclipse.rdf4j.model.datatypes;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

import org.eclipse.rdf4j.model.IRI;
import org.eclipse.rdf4j.model.base.CoreDatatype;
Expand Down Expand Up @@ -260,15 +260,15 @@ public void testParseFloat() {
public void testCompareDateTimeStamp() {
int sameOffset = XMLDatatypeUtil.compare("2019-12-06T00:00:00Z", "2019-12-06T00:00:00+00:00",
XSD.DATETIMESTAMP);
assertTrue("Not the same", sameOffset == 0);
assertTrue(sameOffset == 0, "Not the same");

int offset1 = XMLDatatypeUtil.compare("2019-12-06T14:00:00+02:00", "2019-12-06T13:00:00+02:00",
XSD.DATETIMESTAMP);
assertTrue("Wrong order", offset1 > 0);
assertTrue(offset1 > 0, "Wrong order");

int offset2 = XMLDatatypeUtil.compare("2019-12-06T12:00:00+02:00", "2019-12-06T13:00:00-04:00",
XSD.DATETIMESTAMP);
assertTrue("Wrong order", offset2 < 0);
assertTrue(offset2 < 0, "Wrong order");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
*******************************************************************************/
package org.eclipse.rdf4j.model.impl;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;

import java.util.HashSet;
import java.util.Set;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
*******************************************************************************/
package org.eclipse.rdf4j.model.util;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

import org.eclipse.rdf4j.model.Model;
import org.eclipse.rdf4j.model.impl.LinkedHashModel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*******************************************************************************/
package org.eclipse.rdf4j.model.util;

import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;

import java.util.HashSet;
import java.util.Set;
Expand Down Expand Up @@ -41,12 +41,12 @@ public void setUp() throws Exception {
@Test
public void testCollector() {
Model m = stmts.stream().collect(ModelCollector.toModel());
assertEquals("Number of statements does not match", m.size(), nrStmts);
assertEquals(m.size(), nrStmts, "Number of statements does not match");
}

@Test
public void testCollectorParallel() {
Model m = stmts.parallelStream().collect(ModelCollector.toModel());
assertEquals("Number of statements does not match", m.size(), nrStmts);
assertEquals(m.size(), nrStmts, "Number of statements does not match");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
package org.eclipse.rdf4j.model.util;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

import java.util.Optional;
Expand Down Expand Up @@ -81,7 +81,7 @@ public void testModelsIsomorphic() {
// add same statement again
model2.add(foo, RDF.TYPE, bar);

assertTrue("Duplicate statement should not be considered", Models.isomorphic(model1, model2));
assertTrue(Models.isomorphic(model1, model2), "Duplicate statement should not be considered");

// two identical statements with bnodes added.
model1.add(foo, RDF.TYPE, VF.createBNode());
Expand Down Expand Up @@ -461,22 +461,22 @@ public void testConvertReificationToRDFStar() {
Model referenceRDFStarModel = RDFStarTestHelper.createRDFStarModel();

Model rdfStarModel1 = Models.convertReificationToRDFStar(VF, reificationModel);
assertTrue("RDF reification conversion to RDF-star with explicit VF, model-to-model",
Models.isomorphic(rdfStarModel1, referenceRDFStarModel));
assertTrue(Models.isomorphic(rdfStarModel1, referenceRDFStarModel),
"RDF reification conversion to RDF-star with explicit VF, model-to-model");

Model rdfStarModel2 = Models.convertReificationToRDFStar(reificationModel);
assertTrue("RDF reification conversion to RDF-star with implicit VF, model-to-model",
Models.isomorphic(rdfStarModel2, referenceRDFStarModel));
assertTrue(Models.isomorphic(rdfStarModel2, referenceRDFStarModel),
"RDF reification conversion to RDF-star with implicit VF, model-to-model");

Model rdfStarModel3 = new TreeModel();
Models.convertReificationToRDFStar(VF, reificationModel, (Consumer<Statement>) rdfStarModel3::add);
assertTrue("RDF reification conversion to RDF-star with explicit VF, model-to-consumer",
Models.isomorphic(rdfStarModel3, referenceRDFStarModel));
assertTrue(Models.isomorphic(rdfStarModel3, referenceRDFStarModel),
"RDF reification conversion to RDF-star with explicit VF, model-to-consumer");

Model rdfStarModel4 = new TreeModel();
Models.convertReificationToRDFStar(reificationModel, rdfStarModel4::add);
assertTrue("RDF reification conversion to RDF-star with implicit VF, model-to-consumer",
Models.isomorphic(rdfStarModel4, referenceRDFStarModel));
assertTrue(Models.isomorphic(rdfStarModel4, referenceRDFStarModel),
"RDF reification conversion to RDF-star with implicit VF, model-to-consumer");
}

@Test
Expand All @@ -486,22 +486,22 @@ public void testConvertIncompleteReificationToRDFStar() {
Model incompleteReificationModel = RDFStarTestHelper.createIncompleteRDFReificationModel();

Model rdfStarModel1 = Models.convertReificationToRDFStar(VF, incompleteReificationModel);
assertTrue("Incomplete RDF reification conversion to RDF-star with explicit VF, model-to-model",
Models.isomorphic(rdfStarModel1, incompleteReificationModel));
assertTrue(Models.isomorphic(rdfStarModel1, incompleteReificationModel),
"Incomplete RDF reification conversion to RDF-star with explicit VF, model-to-model");

Model rdfStarModel2 = Models.convertReificationToRDFStar(incompleteReificationModel);
assertTrue("Incomplete RDF reification conversion to RDF-star with implicit VF, model-to-model",
Models.isomorphic(rdfStarModel2, incompleteReificationModel));
assertTrue(Models.isomorphic(rdfStarModel2, incompleteReificationModel),
"Incomplete RDF reification conversion to RDF-star with implicit VF, model-to-model");

Model rdfStarModel3 = new TreeModel();
Models.convertReificationToRDFStar(VF, incompleteReificationModel, (Consumer<Statement>) rdfStarModel3::add);
assertTrue("Incomplete RDF reification conversion to RDF-star with explicit VF, model-to-consumer",
Models.isomorphic(rdfStarModel3, incompleteReificationModel));
assertTrue(Models.isomorphic(rdfStarModel3, incompleteReificationModel),
"Incomplete RDF reification conversion to RDF-star with explicit VF, model-to-consumer");

Model rdfStarModel4 = new TreeModel();
Models.convertReificationToRDFStar(incompleteReificationModel, rdfStarModel4::add);
assertTrue("Incomplete RDF reification conversion to RDF-star with implicit VF, model-to-consumer",
Models.isomorphic(rdfStarModel4, incompleteReificationModel));
assertTrue(Models.isomorphic(rdfStarModel4, incompleteReificationModel),
"Incomplete RDF reification conversion to RDF-star with implicit VF, model-to-consumer");
}

@Test
Expand All @@ -510,22 +510,22 @@ public void testConvertRDFStarToReification() {
Model referenceModel = RDFStarTestHelper.createRDFReificationModel();

Model reificationModel1 = Models.convertRDFStarToReification(VF, rdfStarModel);
assertTrue("RDF-star conversion to reification with explicit VF, model-to-model",
Models.isomorphic(reificationModel1, referenceModel));
assertTrue(Models.isomorphic(reificationModel1, referenceModel),
"RDF-star conversion to reification with explicit VF, model-to-model");

Model reificationModel2 = Models.convertRDFStarToReification(rdfStarModel);
assertTrue("RDF-star conversion to reification with implicit VF, model-to-model",
Models.isomorphic(reificationModel2, referenceModel));
assertTrue(Models.isomorphic(reificationModel2, referenceModel),
"RDF-star conversion to reification with implicit VF, model-to-model");

Model reificationModel3 = new TreeModel();
Models.convertRDFStarToReification(VF, rdfStarModel, (Consumer<Statement>) reificationModel3::add);
assertTrue("RDF-star conversion to reification with explicit VF, model-to-consumer",
Models.isomorphic(reificationModel3, referenceModel));
assertTrue(Models.isomorphic(reificationModel3, referenceModel),
"RDF-star conversion to reification with explicit VF, model-to-consumer");

Model reificationModel4 = new TreeModel();
Models.convertRDFStarToReification(rdfStarModel, reificationModel4::add);
assertTrue("RDF-star conversion to reification with explicit VF, model-to-consumer",
Models.isomorphic(reificationModel4, referenceModel));
assertTrue(Models.isomorphic(reificationModel4, referenceModel),
"RDF-star conversion to reification with explicit VF, model-to-consumer");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
*******************************************************************************/
package org.eclipse.rdf4j.model.util;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.util.Collection;
import java.util.Collections;
Expand Down Expand Up @@ -269,7 +269,7 @@ public final void testWrapPut() throws Exception {
Map<String, String> testMap = Namespaces.wrap(testSet);

String put1 = testMap.put(testPrefix1, testName1);
assertNull("Should have returned null from put on an empty backing set", put1);
assertNull(put1, "Should have returned null from put on an empty backing set");
assertEquals(1, testSet.size());
assertTrue(testSet.contains(new SimpleNamespace(testPrefix1, testName1)));
assertTrue(testMap.containsKey(testPrefix1));
Expand All @@ -293,7 +293,7 @@ public final void testWrapPut() throws Exception {
assertFalse(testMap.containsValue(testName2));

String put3 = testMap.put(testPrefix1, testName1);
assertNull("Should have returned null from put on an empty backing set", put3);
assertNull(put3, "Should have returned null from put on an empty backing set");
assertEquals(1, testSet.size());
assertTrue(testSet.contains(new SimpleNamespace(testPrefix1, testName1)));
assertTrue(testMap.containsKey(testPrefix1));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
*******************************************************************************/
package org.eclipse.rdf4j.model.util;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.CALLS_REAL_METHODS;
import static org.mockito.Mockito.atLeastOnce;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

package org.eclipse.rdf4j.model.util;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.CALLS_REAL_METHODS;
import static org.mockito.Mockito.atLeastOnce;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

import org.eclipse.rdf4j.model.Model;
import org.eclipse.rdf4j.model.Resource;
Expand Down Expand Up @@ -92,19 +92,19 @@ public void testRDFStarReification() {

Model convertedModel1 = new LinkedHashModel();
rdfStarModel.forEach((s) -> Statements.convertRDFStarToReification(s, convertedModel1::add));
assertTrue("RDF-star conversion to reification with implicit VF",
Models.isomorphic(reifiedModel, convertedModel1));
assertTrue(Models.isomorphic(reifiedModel, convertedModel1),
"RDF-star conversion to reification with implicit VF");

Model convertedModel2 = new LinkedHashModel();
rdfStarModel.forEach((s) -> Statements.convertRDFStarToReification(vf, s, convertedModel2::add));
assertTrue("RDF-star conversion to reification with explicit VF",
Models.isomorphic(reifiedModel, convertedModel2));
assertTrue(Models.isomorphic(reifiedModel, convertedModel2),
"RDF-star conversion to reification with explicit VF");

Model convertedModel3 = new LinkedHashModel();
rdfStarModel.forEach((s) -> Statements.convertRDFStarToReification(vf, (t) -> vf.createBNode(t.stringValue()),
s, convertedModel3::add));
assertTrue("RDF-star conversion to reification with explicit VF and custom BNode mapping",
Models.isomorphic(reifiedModel, convertedModel3));
assertTrue(Models.isomorphic(reifiedModel, convertedModel3),
"RDF-star conversion to reification with explicit VF and custom BNode mapping");
}

@Test
Expand All @@ -113,8 +113,8 @@ public void testTripleToResourceMapper() {
vf.createLiteral("data"));
Triple t2 = vf.createTriple(vf.createIRI("http://example.com/1"), vf.createIRI("http://example.com/2"),
vf.createLiteral("data"));
assertEquals("Identical triples must produce the same blank node",
Statements.TRIPLE_BNODE_MAPPER.apply(t1), Statements.TRIPLE_BNODE_MAPPER.apply(t2));
assertEquals(Statements.TRIPLE_BNODE_MAPPER.apply(t1), Statements.TRIPLE_BNODE_MAPPER.apply(t2),
"Identical triples must produce the same blank node");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
*******************************************************************************/
package org.eclipse.rdf4j.model.util;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

import org.junit.jupiter.api.Test;

Expand Down Expand Up @@ -48,35 +48,35 @@ public void testIsCorrectURISplit() throws Exception {
@Test
public void testIsValidURIReference() throws Exception {
assertTrue(URIUtil.isValidURIReference("http://example.org/foo/bar/"));
assertTrue("whitespace should be allowed",
URIUtil.isValidURIReference("http://example.org/foo/bar with a lot of space/"));
assertTrue("unwise chars should be allowed",
URIUtil.isValidURIReference("http://example.org/foo/bar/unwise{<characters>}"));
assertTrue("query params in single quotes should be allowed",
URIUtil.isValidURIReference("http://example.org/foo/bar?query='blah'"));
assertTrue("query params in double quotes should be allowed",
URIUtil.isValidURIReference("http://example.org/foo/bar?query=\"blah\"&foo=bar"));
assertTrue("short simple urns should be allowed", URIUtil.isValidURIReference("urn:p1"));
assertTrue("Escaped special char should be allowed",
URIUtil.isValidURIReference("http://example.org/foo\\u00ea/bar/"));
assertTrue("fragment identifier should be allowed",
URIUtil.isValidURIReference("http://example.org/foo/bar#fragment1"));
assertTrue("Unescaped special char should be allowed",
URIUtil.isValidURIReference("http://example.org/foo®/bar/"));
assertFalse("control char should not be allowed",
URIUtil.isValidURIReference("http://example.org/foo\u0001/bar/"));
assertFalse("relative uri should fail", URIUtil.isValidURIReference("foo/bar/"));
assertFalse("single column is not a valid uri", URIUtil.isValidURIReference(":"));
assertTrue("reserved char is allowed in non-conflicting spot",
URIUtil.isValidURIReference("http://foo.com/b!ar/"));
assertFalse("reserved char should not be allowed in conflicting spot",
URIUtil.isValidURIReference("http;://foo.com/bar/"));
assertTrue(URIUtil.isValidURIReference("http://example.org/foo/bar with a lot of space/"),
"whitespace should be allowed");
assertTrue(URIUtil.isValidURIReference("http://example.org/foo/bar/unwise{<characters>}"),
"unwise chars should be allowed");
assertTrue(URIUtil.isValidURIReference("http://example.org/foo/bar?query='blah'"),
"query params in single quotes should be allowed");
assertTrue(URIUtil.isValidURIReference("http://example.org/foo/bar?query=\"blah\"&foo=bar"),
"query params in double quotes should be allowed");
assertTrue(URIUtil.isValidURIReference("urn:p1"), "short simple urns should be allowed");
assertTrue(URIUtil.isValidURIReference("http://example.org/foo\\u00ea/bar/"),
"Escaped special char should be allowed");
assertTrue(URIUtil.isValidURIReference("http://example.org/foo/bar#fragment1"),
"fragment identifier should be allowed");
assertTrue(URIUtil.isValidURIReference("http://example.org/foo®/bar/"),
"Unescaped special char should be allowed");
assertFalse(URIUtil.isValidURIReference("http://example.org/foo\u0001/bar/"),
"control char should not be allowed");
assertFalse(URIUtil.isValidURIReference("foo/bar/"), "relative uri should fail");
assertFalse(URIUtil.isValidURIReference(":"), "single column is not a valid uri");
assertTrue(URIUtil.isValidURIReference("http://foo.com/b!ar/"),
"reserved char is allowed in non-conflicting spot");
assertFalse(URIUtil.isValidURIReference("http;://foo.com/bar/"),
"reserved char should not be allowed in conflicting spot");
}

@Test
public void controlCharacterInURI() {
assertFalse("URI containing Unicode control char should be invalid",
URIUtil.isValidURIReference("http://example.org/foo\u001F/bar/"));
assertFalse(URIUtil.isValidURIReference("http://example.org/foo\u001F/bar/"),
"URI containing Unicode control char should be invalid");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
import static org.eclipse.rdf4j.model.util.Values.literal;
import static org.eclipse.rdf4j.model.util.Values.namespace;
import static org.eclipse.rdf4j.model.util.Values.triple;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.fail;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.fail;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;

Expand Down
Loading

0 comments on commit d95f112

Please sign in to comment.