use of org.geneontology.minerva.server.handler.ModelARTHandler.ModelARTResult in project minerva by geneontology.
the class ARTHandlerTest method getStoredModel.
public static ModelARTResult getStoredModel(String modelId) throws URISyntaxException, IOException {
URIBuilder builder = new URIBuilder("http://127.0.0.1:6800/search/stored");
builder.addParameter("id", "gomodel:" + modelId);
URI artUrl = builder.build();
String json_result = getJsonStringFromUri(artUrl);
Gson g = new Gson();
ModelARTResult result = g.fromJson(json_result, ModelARTResult.class);
LOGGER.info("Model Stored Model " + json_result);
return result;
}
use of org.geneontology.minerva.server.handler.ModelARTHandler.ModelARTResult in project minerva by geneontology.
the class ARTHandlerTest method testGetModel.
@Test
public final void testGetModel() throws URISyntaxException, IOException, OWLOntologyStorageException, OWLOntologyCreationException, RepositoryException, UnknownIdentifierException {
// get a hold of a test model
String mid = "5fbeae9c00000008";
final String modelId = "http://model.geneontology.org/" + mid;
M3BatchResponse response = BatchTestTools.getModel(handler, modelId, false);
ModelARTResult result = getStoredModel(mid);
// Repeat it after
response = BatchTestTools.getModel(handler, modelId, false);
assertFalse("Model should not be modified", response.data.modifiedFlag);
assertTrue("Active Model should be the same as stored model", equalJsonSize(result.getActiveModel(), result.getStoredModel()));
// Set up m3Batch response to compare active models
JsonModel m3JsonModel = m3ResponseToJsonModel(response);
assertTrue("Active Model should be the same as m3Batch active model", equalJsonSize(result.getActiveModel(), m3JsonModel));
}
use of org.geneontology.minerva.server.handler.ModelARTHandler.ModelARTResult in project minerva by geneontology.
the class ARTHandlerTest method testStoredModelModified.
@Test
public final void testStoredModelModified() throws URISyntaxException, IOException, OWLOntologyStorageException, OWLOntologyCreationException, RepositoryException, UnknownIdentifierException {
// get a hold of a test model
String mid = "5fbeae9c00000008";
final String modelId = "http://model.geneontology.org/" + mid;
M3Request r = BatchTestTools.addIndividual(modelId, "GO:0003674");
List<M3Request> batch = Collections.singletonList(r);
M3BatchResponse response = handler.m3Batch("test-user", Collections.emptySet(), "test-intention", "foo-packet-id", batch.toArray(new M3Request[batch.size()]), false, true);
// Get the model
response = BatchTestTools.getModel(handler, modelId, false);
ModelARTResult result = getStoredModel(mid);
// Repeat
response = BatchTestTools.getModel(handler, modelId, false);
int activeIndividualCount = result.getActiveModel().individuals.length;
int storedIndividualCount = result.getStoredModel().individuals.length;
assertTrue("Model should be modified", response.data.modifiedFlag);
assertFalse("Active model should not be the same as stored model", equalJsonSize(result.getActiveModel(), result.getStoredModel()));
// Since we added one individual
assertTrue("Active individuals should be one more stored individual count", activeIndividualCount == storedIndividualCount + 1);
// Set up m3Batch response to compare active models
JsonModel m3JsonModel = m3ResponseToJsonModel(response);
assertTrue("Active Model should be the same as m3Batch active model", equalJsonSize(result.getActiveModel(), m3JsonModel));
// Store the model
response = storeModel(modelId);
result = getStoredModel(mid);
assertFalse("Model should not be modified", response.data.modifiedFlag);
assertTrue("Active model should be the same as stored model", equalJsonSize(result.getActiveModel(), result.getStoredModel()));
// Set up m3Batch response to compare active models
m3JsonModel = m3ResponseToJsonModel(response);
assertTrue("Active Model should be the same as m3Batch active model", equalJsonSize(result.getActiveModel(), m3JsonModel));
// After store active should be equal to stored
storedIndividualCount = result.getStoredModel().individuals.length;
assertTrue("Active individuals should be one more stored individual count", activeIndividualCount == storedIndividualCount);
// Get the model
response = BatchTestTools.getModel(handler, modelId, false);
assertFalse("Model should not be modified", response.data.modifiedFlag);
// Set up m3Batch response to compare active models
m3JsonModel = m3ResponseToJsonModel(response);
assertTrue("Active Model should be the same as m3Batch active model", equalJsonSize(result.getActiveModel(), m3JsonModel));
}
use of org.geneontology.minerva.server.handler.ModelARTHandler.ModelARTResult in project minerva by geneontology.
the class ARTHandlerTest method testStoredModelReset.
@Test
public final void testStoredModelReset() throws URISyntaxException, IOException, OWLOntologyStorageException, OWLOntologyCreationException, RepositoryException, UnknownIdentifierException {
// get a hold of a test model
String mid = "5fbeae9c00000008";
final String modelId = "http://model.geneontology.org/" + mid;
M3Request r = BatchTestTools.addIndividual(modelId, "GO:0003674");
List<M3Request> batch = Collections.singletonList(r);
M3BatchResponse response = handler.m3Batch("test-user", Collections.emptySet(), "test-intention", "foo-packet-id", batch.toArray(new M3Request[batch.size()]), false, true);
// Reset the model
response = resetModel(modelId);
// Get the model
response = BatchTestTools.getModel(handler, modelId, false);
ModelARTResult result = getStoredModel(mid);
assertFalse("Model should not be modified", response.data.modifiedFlag);
assertTrue("Active Model should be the same as stored model", equalJsonSize(result.getActiveModel(), result.getStoredModel()));
// Set up m3Batch response to compare active models
JsonModel m3JsonModel = m3ResponseToJsonModel(response);
assertTrue("Active Model should be the same as m3Batch active model", equalJsonSize(result.getActiveModel(), m3JsonModel));
}
Aggregations