Package org.eclipselabs.mongoemf.junit.model

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


  {
    // Setup : Create a primary object with a containment reference to a target object.

    ResourceSet resourceSet = createResourceSet();

    TargetObject targetObject = ModelFactory.eINSTANCE.createTargetObject();
    targetObject.setSingleAttribute("junit");

    PrimaryObject primaryObject = ModelFactory.eINSTANCE.createPrimaryObject();
    primaryObject.setName("junit");
    primaryObject.setSingleContainmentReferenceProxies(targetObject);
View Full Code Here


    // Setup : Create a primary object with a cross-document containment reference to a target
    // object.

    ResourceSet resourceSet = createResourceSet();

    TargetObject targetObject = ModelFactory.eINSTANCE.createTargetObject();
    targetObject.setSingleAttribute("junit");
    saveObject(resourceSet, targetObject);

    PrimaryObject primaryObject = ModelFactory.eINSTANCE.createPrimaryObject();
    primaryObject.setName("junit");
    primaryObject.setSingleContainmentReferenceProxies(targetObject);
    saveObject(resourceSet, primaryObject);

    // Test : Delete the target object and reload the primary object

    targetObject.eResource().delete(null);
    ResourceSet testResourceSet = createResourceSet();
    Resource resource = testResourceSet.getResource(primaryObject.eResource().getURI(), true);

    // Verify : Check that the object was stored correctly.
View Full Code Here

    // Setup : Create a primary object and two target objects for the feature map.

    PrimaryObject primaryObject = ModelFactory.eINSTANCE.createPrimaryObject();
    primaryObject.setName("junit");

    TargetObject targetObject1 = ModelFactory.eINSTANCE.createTargetObject();
    targetObject1.setSingleAttribute("one");

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

    primaryObject.getFeatureMapReferenceType1().add(targetObject1);
    primaryObject.getFeatureMapReferenceType2().add(targetObject2);

    assertThat(primaryObject.getFeatureMapReferenceCollection().size(), is(2));
View Full Code Here

    PrimaryObject primaryObject = ModelFactory.eINSTANCE.createPrimaryObject();
    primaryObject.setName("junit");

    {
      TargetObject targetObject = ModelFactory.eINSTANCE.createTargetObject();
      targetObject.setSingleAttribute("one");
      saveObject(resourceSet, targetObject);
      primaryObject.setSingleContainmentReferenceProxies(targetObject);
      targetObject.eResource().unload();
    }
    {
      TargetObject targetObject = ModelFactory.eINSTANCE.createTargetObject();
      targetObject.setSingleAttribute("one");
      saveObject(resourceSet, targetObject);
      primaryObject.setSingleNonContainmentReference(targetObject);
      targetObject.eResource().unload();
    }
    {
      TargetObject targetObject = ModelFactory.eINSTANCE.createTargetObject();
      targetObject.setSingleAttribute("one");
      saveObject(resourceSet, targetObject);
      primaryObject.getMultipleContainmentReferenceProxies().add(targetObject);
      targetObject.eResource().unload();
    }
    {
      TargetObject targetObject = ModelFactory.eINSTANCE.createTargetObject();
      targetObject.setSingleAttribute("one");
      saveObject(resourceSet, targetObject);
      primaryObject.getMultipleNonContainmentReference().add(targetObject);
      targetObject.eResource().unload();
    }
    {
      PrimaryObject targetObject = ModelFactory.eINSTANCE.createPrimaryObject();
      targetObject.setName("target");
      saveObject(targetObject);
      primaryObject.setContainmentReferenceSameCollectioin(targetObject);
      targetObject.eResource().unload();
    }

    saveObject(resourceSet, primaryObject);

    // Verify that proxies aren't resolved as a result of saving to Mongo DB.
View Full Code Here

  @Test
  public void testQueryWithInvalidOperator() throws IOException
  {
    // Setup : Create and save a target object.

    TargetObject targetObject = org.eclipselabs.mongoemf.junit.model.ModelFactory.eINSTANCE.createTargetObject();
    targetObject.setSingleAttribute("junit");
    saveObject(targetObject);

    // Test : Query for the object using an invalid operator - this can happen if you forget to
    // enclose the value in ''

    ResourceSet resourceSet = createResourceSet();
    Resource resource = resourceSet.getResource(createCollectionURI(targetObject.eClass()).appendQuery(URI.encodeQuery("singleAttribute==4d", false)), true);

    // Verify : The query should not return any results;

    ECollection eCollection = (ECollection) resource.getContents().get(0);
    assertThat(eCollection.getValues().size(), is(0));
View Full Code Here

  @Test
  public void testTargetObjectWithSingleAttribute() throws IOException
  {
    // Setup : Create a target object with the single attribute set.

    TargetObject targetObject = ModelFactory.eINSTANCE.createTargetObject();
    targetObject.setSingleAttribute("junit");

    // Test : Store the object to MongoDB

    saveObject(targetObject);
View Full Code Here

  @Test
  public void testTargetObjectWithArrayAttribute() throws IOException
  {
    // Setup : Create a target object with the array attribute set.

    TargetObject targetObject = ModelFactory.eINSTANCE.createTargetObject();
    targetObject.getArrayAttribute().add("one");
    targetObject.getArrayAttribute().add("two");

    // Test : Store the object to MongoDB

    saveObject(targetObject);
View Full Code Here

  @Test
  public void testTargetObjectUpdateSingleAttribute() throws IOException
  {
    // Setup : Create a target object with the single attribute set and store it to the database.

    TargetObject targetObject = ModelFactory.eINSTANCE.createTargetObject();
    targetObject.setSingleAttribute("junit");
    saveObject(targetObject);

    // Test : Update the attribute and store it back to the database

    targetObject.setSingleAttribute("green");
    targetObject.eResource().save(null);

    // Verify : Check that the object was stored correctly and there is only one object in the
    // collection.

    EChecker.checkObject(targetObject, createResourceSet());
    assertThat(getCollection(targetObject.eClass()).getCount(), is(1L));
  }
View Full Code Here

  @Test
  public void testTargetObjectUpdateArrayAttribute() throws IOException
  {
    // Setup : Create a target object with an array attribute set and store it to the database.

    TargetObject targetObject = ModelFactory.eINSTANCE.createTargetObject();
    targetObject.getArrayAttribute().add("one");
    saveObject(targetObject);

    // Test : Update the attribute and store it back to the database

    targetObject.getArrayAttribute().add("two");
    targetObject.eResource().save(null);

    // Verify : Check that the object was stored correctly and there is only one object in the
    // collection.

    EChecker.checkObject(targetObject, createResourceSet());
    assertThat(getCollection(targetObject.eClass()).getCount(), is(1L));
  }
View Full Code Here

  @Test(expected = IOException.class)
  public void testShortURI() throws IOException
  {
    // Setup : Create a target object to save.

    TargetObject targetObject = ModelFactory.eINSTANCE.createTargetObject();
    targetObject.setSingleAttribute("junit");

    // Test : Save the target object with a short (invalid) URI

    saveObject(targetObject, createObjectURI(targetObject.eClass(), new ObjectId()).appendSegment(""), null);
  }
View Full Code Here

TOP

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

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.