package org.wikipathways.wp2rdf;

import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.pathvisio.core.model.ConverterException;

public class WP101Test extends AbstractConvertorTest {

	@BeforeClass
	public static void createModel() throws ConverterException {
		loadModelAsWPRDF("WP101_79360.gpml", "WP101", "79360");
	}

	@Test
	public void noIdentifierURIs() throws Exception {
		String sparql = ResourceHelper.resourceAsString("structure/noIdentifierURIs.rq");
		StringMatrix table = SPARQLHelper.sparql(model, sparql);
		Assert.assertNotNull(table);
		Assert.assertEquals("Data nodes with a 'noIdentifier' URI:\n" + table, 0, table.getRowCount());
	}

	@Test
	public void nodesHaveTypedParents() throws Exception {
		String sparql = ResourceHelper.resourceAsString("structure/nodesHaveTypedParents.rq");
		StringMatrix table = SPARQLHelper.sparql(model, sparql);
		Assert.assertNotNull(table);
		Assert.assertEquals("Parents of DataNodes should be typed: " + table, 0, table.getRowCount());
	}

}

@@ -1029,10 +1029,663 @@
 ));%0A%09%7D%0A%0A
+%09@Test%0A%09public void whitespaceIdentifiers() throws Exception %7B%0A%09%09String sparql = ResourceHelper.resourceAsString(%22xrefs/allIdentifiers.rq%22);%0A%09%09StringMatrix table = SPARQLHelper.sparql(model, sparql);%0A%09%09Assert.assertNotNull(table);%0A%09%09Assert.assertNotSame(0, table.getRowCount());%0A%09%09String errors = %22%22;%0A%09%09int errorCount = 0;%0A%09%09for (int i=1; i%3C=table.getRowCount(); i++) %7B%0A%09%09%09if (table.get(i, %22identifier%22).trim().length() == 0) %7B%0A%09%09%09%09errors += table.get(i, %22pathway%22) + %22 %22 + table.get(i, %22label%22) + %22%5Cn%22;%0A%09%09%09%09errorCount++;%0A%09%09%09%7D%0A%09%09%7D%0A%09%09Assert.assertEquals(%0A%09%09%09%22Unexpected identifiers that only consist of whitespace:%5Cn%22 + errors,%0A%09%09%090, errorCount%0A%09%09);%0A%09%7D%0A%0A
 %7D%0A

Test for whitespace identifiers, which must not end up in the WPRDF