Package org.libreplan.business.util.deepcopy.EntityExamples

Examples of org.libreplan.business.util.deepcopy.EntityExamples.Parent


                .next());
    }

    @Test
    public void ifNotInnmutableNorCustomCopyRecursivelyCopiesIt() {
        Parent parent = new Parent();
        EntityA entityAProperty = new EntityA();
        Date originalDate = new Date();
        entityAProperty.setDate(originalDate);
        parent.setEntityAProperty(entityAProperty);
        Parent copy = new DeepCopy().copy(parent);
        assertNotSame(parent, copy);
        assertThat(copy.getEntityAProperty().getDate(), equalTo(originalDate));
        assertNotSame(copy.getEntityAProperty().getDate(), originalDate);
    }
View Full Code Here


        assertNotSame(copy.getEntityAProperty().getDate(), originalDate);
    }

    @Test
    public void alreadyCopiedInstancesAreReused() {
        Parent parent = new Parent();
        EntityA entityA = new EntityA();
        parent.setEntityAProperty(entityA);
        entityA.setParentProperty(parent);
        Parent copy = new DeepCopy().copy(parent);
        assertSame(copy, copy.getEntityAProperty().getParentProperty());
    }
View Full Code Here

        assertSame(copy, copy.getEntityAProperty().getParentProperty());
    }

    @Test
    public void alreadyCopiedSetsAreReused() {
        Parent parent = new Parent();
        EntityA entityA = new EntityA();
        parent.setEntityAProperty(entityA);
        entityA.setParentProperty(parent);
        HashSet<Object> originalSet = new HashSet<Object>();
        parent.setSetProperty(originalSet);
        entityA.setSetProperty(originalSet);
        Parent copy = new DeepCopy().copy(parent);
        assertSame(copy.getSetProperty(), copy.getEntityAProperty()
                .getSetProperty());
    }
View Full Code Here

    }

    @Test
    public void canSpecifyReplacements() {
        DeepCopy deepCopy = new DeepCopy();
        Parent parent = new Parent();
        EntityA entityA = new EntityA();
        parent.setEntityAProperty(entityA);
        EntityA anotherEntity = new EntityA();
        deepCopy.replace(entityA, anotherEntity);
        Parent copy = deepCopy.copy(parent);
        assertSame(copy.getEntityAProperty(), anotherEntity);
    }
View Full Code Here

TOP

Related Classes of org.libreplan.business.util.deepcopy.EntityExamples.Parent

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.