Examples of MyFooContainer


Examples of org.conserve.objects.polymorphism.MyFooContainer

  {
    PersistenceManager persist = new PersistenceManager(driver, database, login, password);

    // create two FooContainerOwner objects
    FooContainerOwner one = new FooContainerOwner();
    MyFooContainer fooer = new MyFooContainer();
    fooer.setFoo("oneFooer");
    one.setFooContainer(fooer);

    FooContainerOwner two = new FooContainerOwner();
    MyExtendedFooContainer extfooer = new MyExtendedFooContainer();
    extfooer.setFoo("twoFooer");
    two.setFooContainer(extfooer);

    // save FooContainerOwner objects.
    persist.saveObject(one);
    persist.saveObject(two);
    persist.close();

    // re-open connection
    persist = new PersistenceManager(driver, database, login, password);

    // check that there are two FooContainerOwners
    List<FooContainerOwner> fooableowners = persist.getObjects(FooContainerOwner.class, new All());
    assertEquals(2, fooableowners.size());

    // check that there are two FooContainers
    List<FooContainer> fooables = persist.getObjects(FooContainer.class, new All());
    assertEquals(2, fooables.size());
    // check that there is one ExtendedFooContainer
    List<ExtendedFooContainer> extendedfooables = persist.getObjects(ExtendedFooContainer.class, new All());
    assertEquals(1, extendedfooables.size());

    FooContainerOwner searchObject = new FooContainerOwner();

    // get the first foo based on strict search
    fooer = new MyFooContainer();
    fooer.setFoo("oneFooer");
    searchObject.setFooContainer(fooer);
    fooableowners = persist.getObjects(FooContainerOwner.class, new Equal(searchObject));
    assertEquals(1, fooableowners.size());

    // get second foo based on strict search
    extfooer = new MyExtendedFooContainer();
    extfooer.setFoo("twoFooer");
    searchObject.setFooContainer(extfooer);
    fooableowners = persist.getObjects(FooContainerOwner.class, new Equal(searchObject));
    assertEquals(1, fooableowners.size());

    // check that second foo can't be gotten by strict search
    fooer.setFoo("twoFooer");
    searchObject.setFooContainer(fooer);
    fooableowners = persist.getObjects(FooContainerOwner.class, new Equal(searchObject));
    assertEquals(0, fooableowners.size());

    // get second foo based on non-strict search
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.