Package org.eclipselabs.mongoemf.junit.model

Examples of org.eclipselabs.mongoemf.junit.model.PrimaryObject


  }

  @Test
  public void testUnsettableReferenceUnset() throws IOException
  {
    PrimaryObject primaryObject = ModelFactory.eINSTANCE.createPrimaryObject();
    saveObject(primaryObject);

    ResourceSet resourceSet = createResourceSet();
    Resource resource = resourceSet.getResource(primaryObject.eResource().getURI(), true);
    PrimaryObject object = (PrimaryObject) resource.getContents().get(0);
    assertFalse(object.isSetUnsettableReference());
  }
View Full Code Here


  public void testIDAttribute() throws IOException
  {
    // Setup : Create a primary object with the ID attribute set

    String id = "Attribute ID";
    PrimaryObject primaryObject = ModelFactory.eINSTANCE.createPrimaryObject();
    primaryObject.setIdAttribute(id);

    // Test : Store the object with the option to use the ID attribute as the MongoDB _id

    HashMap<String, Object> options = new HashMap<String, Object>();
    options.put(Options.OPTION_USE_ID_ATTRIBUTE_AS_PRIMARY_KEY, Boolean.TRUE);

    saveObject(primaryObject, createCollectionURI(primaryObject.eClass()), options);

    // Verify : Check that the object was stored correctly

    assertThat(EChecker.getID(primaryObject), is(id));
  }
View Full Code Here

  public void testIDAttributeMultipleObjects() throws IOException
  {
    // Setup : Create two primary objects with the ID attribute set

    String id1 = "Object 1";
    PrimaryObject primaryObject1 = ModelFactory.eINSTANCE.createPrimaryObject();
    primaryObject1.setIdAttribute(id1);

    String id2 = "Object 2";
    PrimaryObject primaryObject2 = ModelFactory.eINSTANCE.createPrimaryObject();
    primaryObject2.setIdAttribute(id2);

    // Test : Store the object with the option to use the ID attribute as the MongoDB _id

    HashMap<String, Object> options = new HashMap<String, Object>();
    options.put(Options.OPTION_USE_ID_ATTRIBUTE_AS_PRIMARY_KEY, Boolean.TRUE);
View Full Code Here

    TargetObject targetObject2 = ModelFactory.eINSTANCE.createTargetObject();
    targetObject2.setSingleAttribute("two");
    saveObject(resourceSet, targetObject2);

    PrimaryObject primaryObject = ModelFactory.eINSTANCE.createPrimaryObject();
    primaryObject.setName("junit");
    primaryObject.getMultipleContainmentReferenceProxies().add(targetObject1);
    primaryObject.getMultipleContainmentReferenceProxies().add(targetObject2);

    saveObject(resourceSet, primaryObject);

    ByteArrayOutputStream out = new ByteArrayOutputStream();
    primaryObject.eResource().save(out, null);

    ResourceSet testResourceSet = createResourceSet();

    testResourceSet.getURIConverter().getURIMap().put(URI.createURI("../TargetObject/"), targetObject1.eResource().getURI().trimSegments(1).appendSegment(""));
    Resource libraryXMI = new XMIResourceFactoryImpl().createResource(URI.createURI(temporaryFolder.newFile("model.xmi").getAbsolutePath()));
View Full Code Here

    TargetObject targetObject2 = ModelFactory.eINSTANCE.createTargetObject();
    targetObject2.setSingleAttribute("two");
    saveObject(resourceSet, targetObject2);

    PrimaryObject primaryObject = ModelFactory.eINSTANCE.createPrimaryObject();
    primaryObject.setName("junit");
    primaryObject.getMultipleContainmentReferenceProxies().add(targetObject1);
    primaryObject.getMultipleContainmentReferenceProxies().add(targetObject2);

    saveObject(resourceSet, primaryObject);

    ByteArrayOutputStream out = new ByteArrayOutputStream();
    Map<Object, Object> options = new HashMap<Object, Object>();
    options.put(XMLResource.OPTION_BINARY, Boolean.TRUE);
    primaryObject.eResource().save(out, options);

    {
      ResourceSet testResourceSet = createResourceSet();

      testResourceSet.getURIConverter().getURIMap().put(URI.createURI("../TargetObject/"), targetObject1.eResource().getURI().trimSegments(1).appendSegment(""));
View Full Code Here

    TargetObject targetObject2 = ModelFactory.eINSTANCE.createTargetObject();
    targetObject2.setSingleAttribute("two");
    saveObject(resourceSet, targetObject2);

    PrimaryObject primaryObject = ModelFactory.eINSTANCE.createPrimaryObject();
    primaryObject.setName("junit");
    primaryObject.getMultipleContainmentReferenceProxies().add(targetObject1);
    primaryObject.getMultipleContainmentReferenceProxies().add(targetObject2);

    saveObject(resourceSet, primaryObject);

    ByteArrayOutputStream out = new ByteArrayOutputStream();
    Map<Object, Object> options = new HashMap<Object, Object>();
    options.put(XMIResource.OPTION_SUPPRESS_XMI, Boolean.TRUE);
    primaryObject.eResource().save(out, options);

    {
      ResourceSet testResourceSet = createResourceSet();

      testResourceSet.getURIConverter().getURIMap().put(URI.createURI("../TargetObject/"), targetObject1.eResource().getURI().trimSegments(1).appendSegment(""));
View Full Code Here

TOP

Related Classes of org.eclipselabs.mongoemf.junit.model.PrimaryObject

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.