/*
 * Copyright (c) 2015 The University of Auckland
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * Authors: Ping Zhao (pzha291@aucklanduni.ac.nz)
 * Created: 2015-06-10
 * Last Updated: --
 */
package edu.uoa.cs.master.cloudmanufacturingnlp.semanticwebrules.sparql;

import java.util.Map;

import com.hp.hpl.jena.query.Query;
import com.hp.hpl.jena.query.QueryExecution;
import com.hp.hpl.jena.query.QueryExecutionFactory;
import com.hp.hpl.jena.query.QueryFactory;
import com.hp.hpl.jena.query.ResultSet;
import com.hp.hpl.jena.query.ResultSetFormatter;
import com.hp.hpl.jena.rdf.model.InfModel;

import edu.uoa.cs.master.cloudmanufacturingnlp.semanticwebrules.SemanticWebRulesTest;
import edu.uoa.cs.master.cloudmanufacturingnlp.util.Constants;

/**
 * @author pingz
 *
 */
public class SparqlTest extends SemanticWebRulesTest {

	/**
	 * @param expectedValue
	 * @param infModel
	 */
	@Override
	public void testRules(final Map<String, Integer> expectedValue, final InfModel infModel) {
		final String objectName = expectedValue.keySet().iterator().next();
		final String queryString = String.format("PREFIX manuservice: <%s> ", Constants.Ontology.NS_MC)
				+ String.format("SELECT ?partner WHERE { ?partner manuservice:hasAccessTo manuservice:%s }", objectName);

		final Query query = QueryFactory.create(queryString);
		final QueryExecution queryExecution = QueryExecutionFactory.create(query, infModel);

		final ResultSet resultSet = queryExecution.execSelect();
		ResultSetFormatter.out(System.out, resultSet, query);

		queryExecution.close();
	}
}

@@ -795,24 +795,85 @@
 .sparql;%0D%0A%0D%0A
+import static org.assertj.core.api.Assertions.assertThat;%0D%0A%0D%0A
 import java.
@@ -2158,16 +2158,160 @@
 ry);%0D%0A%0D%0A
+%09%09final Integer expectedNumber = expectedValue.values().iterator().next();%0D%0A%09%09assertThat(resultSet.getRowNumber()).isSameAs(expectedNumber);%0D%0A%0D%0A
 %09%09queryE

Fix an unit test by adding assertion.