}
@Test
public void saveRdfServiceTest() throws JSONException, IOException{
String id = "rdf-test";
ServiceRegistry registry = new ServiceRegistry(new GRefineJsonUtilitiesImpl(),null);
GRefineServiceManager manager = new GRefineServiceManager(registry, dir);
Model m = ModelFactory.createDefaultModel();
ReconciliationService service = new RdfReconciliationService(id,id, new QueryEndpointImpl(new LarqSparqlQueryFactory(),
new DumpQueryExecutor(m)), 0);
manager.addAndSaveService(service);
assertTrue(registry.hasService(id));
//verify service is saved
registry = new ServiceRegistry(new GRefineJsonUtilitiesImpl(),null);
//verify no service
assertFalse(registry.hasService(id));
File file = new File(dir,"services");
//verify saved
assertTrue(file.exists());
FileInputStream in = new FileInputStream(file);
registry.loadFromFile(in);
//verify service is loaded
ReconciliationService service2 = registry.getService(id, null);
verifyCorrectService(service2, service);
//verify service is not initialized
ReconciliationRequest request = new ReconciliationRequest("query", 10);
String msg = "";
try{
service2.reconcile(request);
}catch(RuntimeException e){
msg = e.getMessage();
}
assertTrue(msg.equals("Model is not loaded"));
FileInputStream modelIn = new FileInputStream(new File(dir,id + ".ttl"));
ReconciliationService service3 = registry.getService(id, modelIn);
assertTrue(service3.reconcile(request).getResults().isEmpty());
}