use of org.iobserve.model.test.storage.two.Two in project iobserve-analysis by research-iobserve.
the class EvalProxyDBTest method test.
@Test
public void test() throws IOException, DBException {
new File(EvalProxyDBTest.MODEL_ONE).delete();
// create model
final Root modelOne = TestModelData.createModelOne();
final Two modelTwo = TestModelData.createModelTwo();
final Registry resourceRegistry = Resource.Factory.Registry.INSTANCE;
final Map<String, Object> map = resourceRegistry.getExtensionToFactoryMap();
map.put("*", new XMIResourceFactoryImpl());
final ResourceSet resourceSet = new ResourceSetImpl();
resourceSet.setResourceFactoryRegistry(resourceRegistry);
// put in resources
final Resource resourceOne = resourceSet.createResource(URI.createFileURI(EvalProxyDBTest.MODEL_ONE));
resourceOne.getContents().add(modelOne);
final Resource resourceTwo = resourceSet.createResource(URI.createFileURI(EvalProxyDBTest.MODEL_TWO));
resourceTwo.getContents().add(modelTwo);
// save models
resourceOne.save(null);
resourceTwo.save(null);
// store in DB
final Neo4JModelResource<Root> dbResourceOne = ModelProviderTestUtils.prepareResource("testStoreGraphCreate1", this.prefix, TwoPackage.eINSTANCE);
dbResourceOne.storeModelPartition(modelOne);
final Neo4JModelResource<Two> dbResourceTwo = ModelProviderTestUtils.prepareResource("testStoreGraphCreate2", this.prefix, TwoPackage.eINSTANCE);
dbResourceTwo.storeModelPartition(modelTwo);
// retrieve model two
final Two retrievedModelTwo = dbResourceTwo.getModelRootNode(Two.class, TwoPackage.Literals.TWO);
this.checkProxies("A", retrievedModelTwo);
ModelNeo4JUtil.printModel(retrievedModelTwo);
}
use of org.iobserve.model.test.storage.two.Two in project iobserve-analysis by research-iobserve.
the class ECoreNeo4JTest method createWithReferenceThenUpdate.
@Test
public void createWithReferenceThenUpdate() throws Exception {
final Neo4JModelResource<Root> oneResource = ModelProviderTestUtils.prepareResource("createWithReferenceThenUpdate-one", this.prefix, OnePackage.eINSTANCE);
final Neo4JModelResource<Two> twoResource = ModelProviderTestUtils.prepareResource("createWithReferenceThenUpdate-two", this.prefix, TwoPackage.eINSTANCE);
oneResource.storeModelPartition(this.modelOne);
twoResource.storeModelPartition(this.modelTwo);
this.modelTwo.getLinks().add(TestModelData.createLink(TestModelData.SECOND_OTHER));
twoResource.updatePartition(this.modelTwo);
final Two two = twoResource.getModelRootNode(Two.class, TwoPackage.Literals.TWO);
Assert.assertThat("Different number of links", two.getLinks().size(), Is.is(this.modelTwo.getLinks().size()));
for (int i = 0; i < two.getLinks().size(); i++) {
final Link newLink = two.getLinks().get(i);
final Link oldLink = this.modelTwo.getLinks().get(i);
oneResource.resolve(newLink.getReference());
Assert.assertThat("Links differ", newLink.getReference().getName(), Is.is(oldLink.getReference().getName()));
}
}
use of org.iobserve.model.test.storage.two.Two in project iobserve-analysis by research-iobserve.
the class EvalProxyTest method checkProxies.
private void checkProxies(final String label, final Resource resource) {
System.out.println("Step " + label);
for (final EObject o : resource.getContents()) {
if (o instanceof Two) {
for (final EObject l : ((Two) o).getLinks()) {
if (l instanceof Link) {
final Other ref = ((Link) l).getReference();
System.out.println("Link " + ref.getName() + " " + ref.eIsProxy() + " -- " + ((BasicEObjectImpl) ref).eProxyURI());
}
}
}
}
}
use of org.iobserve.model.test.storage.two.Two in project iobserve-analysis by research-iobserve.
the class EvalProxyTest method test.
@Test
public void test() throws IOException {
new File(EvalProxyTest.MODEL_ONE).delete();
new File(EvalProxyTest.MODEL_X_ONE).delete();
// create model
final Root modelOne = TestModelData.createModelOne();
final Two modelTwo = TestModelData.createModelTwo();
final Registry resourceRegistry = Resource.Factory.Registry.INSTANCE;
final Map<String, Object> map = resourceRegistry.getExtensionToFactoryMap();
map.put("*", new XMIResourceFactoryImpl());
final ResourceSet resourceSet = new ResourceSetImpl();
resourceSet.setResourceFactoryRegistry(resourceRegistry);
// put in resources
final Resource resourceOne = resourceSet.createResource(URI.createFileURI(EvalProxyTest.MODEL_ONE));
resourceOne.getContents().add(modelOne);
final Resource resourceTwo = resourceSet.createResource(URI.createFileURI(EvalProxyTest.MODEL_TWO));
resourceTwo.getContents().add(modelTwo);
// save models
resourceOne.save(null);
resourceTwo.save(null);
this.rename(EvalProxyTest.MODEL_ONE, EvalProxyTest.MODEL_X_ONE);
TwoPackage.eINSTANCE.eClass();
OnePackage.eINSTANCE.eClass();
// read model two
final Registry resourceRegistry2 = Resource.Factory.Registry.INSTANCE;
final Map<String, Object> map2 = resourceRegistry2.getExtensionToFactoryMap();
map2.put("*", new XMIResourceFactoryImpl());
final ResourceSet resourceSet2 = new ResourceSetImpl();
resourceSet2.setResourceFactoryRegistry(resourceRegistry2);
final Resource resourceTwo2 = resourceSet2.getResource(URI.createFileURI(EvalProxyTest.MODEL_TWO), true);
resourceTwo2.load(resourceSet2.getLoadOptions());
// check proxies
this.checkProxies("A", resourceTwo2);
// read model one
this.rename(EvalProxyTest.MODEL_X_ONE, EvalProxyTest.MODEL_ONE);
final Resource resourceOne2 = resourceSet2.getResource(URI.createFileURI(EvalProxyTest.MODEL_ONE), true);
resourceTwo2.load(resourceSet2.getLoadOptions());
resourceOne2.load(resourceSet2.getLoadOptions());
// check proxies
this.checkProxies("B", resourceTwo2);
// resolve proxies
for (final Resource a : resourceSet2.getResources()) {
System.out.println("resource " + a.getURI());
}
EcoreUtil.resolveAll(resourceTwo2);
// check proxies
this.checkProxies("C", resourceTwo2);
// do it again
final Registry resourceRegistry3 = Resource.Factory.Registry.INSTANCE;
final Map<String, Object> map3 = resourceRegistry2.getExtensionToFactoryMap();
map3.put("*", new XMIResourceFactoryImpl());
final ResourceSet resourceSet3 = new ResourceSetImpl();
resourceSet3.setResourceFactoryRegistry(resourceRegistry3);
final Resource resourceTwo3 = resourceSet3.getResource(URI.createFileURI(EvalProxyTest.MODEL_TWO), true);
resourceTwo3.load(resourceSet3.getLoadOptions());
// check proxies
this.checkProxies("D", resourceTwo3);
final Resource resourceOne3 = resourceSet3.getResource(URI.createFileURI(EvalProxyTest.MODEL_ONE), true);
resourceOne3.load(resourceSet3.getLoadOptions());
// check proxies
this.checkProxies("E", resourceTwo3);
}
use of org.iobserve.model.test.storage.two.Two in project iobserve-analysis by research-iobserve.
the class TestModelData method createModelTwo.
/**
* Create Model two.
*
* @return returns model two
*/
public static Two createModelTwo() {
final Two modelTwo = TwoFactory.eINSTANCE.createTwo();
modelTwo.getLinks().add(TestModelData.createLink(TestModelData.FIRST_OTHER));
return modelTwo;
}
Aggregations