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

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


        assertThat(copy.getSuperClassStringProperty(), equalTo("foo"));
    }

    @Test
    public void datesAreCopied() {
        EntityA entityA = new EntityA();
        Date originalDateValue = new Date();
        entityA.setDate(originalDateValue);
        EntityA copy = new DeepCopy().copy(entityA);
        assertThat(copy.getDate(), equalTo(originalDateValue));
        assertNotSame(originalDateValue, copy.getDate());
    }
View Full Code Here


        assertNotSame(originalDateValue, copy.getDate());
    }

    @Test
    public void setsAreCopied() {
        EntityA entityA = new EntityA();
        HashSet<Object> originalSet = new HashSet<Object>(asList("test",
                2, 3, new Date()));
        entityA.setSetProperty(originalSet);
        EntityA copy = new DeepCopy().copy(entityA);
        assertEquals(originalSet, copy.getSetProperty());
        assertNotSame(originalSet, copy.getSetProperty());
    }
View Full Code Here

        assertNotSame(originalSet, copy.getSetProperty());
    }

    @Test
    public void theSetImplementationClassIsPreservedIfPossible() {
        EntityA entityA = new EntityA();
        Set<Object> originalSet = new LinkedHashSet<Object>(asList("test", 2,
                3, new Date()));
        entityA.setSetProperty(originalSet);
        EntityA copy = new DeepCopy().copy(entityA);
        assertThat(copy.getSetProperty(), instanceOf(LinkedHashSet.class));
    }
View Full Code Here

        assertThat(copy.getSetProperty(), instanceOf(LinkedHashSet.class));
    }

    @Test
    public void setsInsideSetsAreRecursivelyCopiedWithoutProblem() {
        EntityA entityA = new EntityA();
        HashSet<Object> innerSet = new HashSet<Object>(asList("bla", 3));
        HashSet<Object> originalSet = new HashSet<Object>(asList("test", 2, 3,
                new Date(), innerSet));
        entityA.setSetProperty(originalSet);
        EntityA copy = new DeepCopy().copy(entityA);
        assertEquals(originalSet, copy.getSetProperty());
        assertNotSame(originalSet, copy.getSetProperty());
    }
View Full Code Here

        assertNotSame(originalSet, copy.getSetProperty());
    }

    @Test
    public void mapsAreCopied() {
        EntityA entityA = new EntityA();
        HashMap<Object, Object> originalMap = new HashMap<Object, Object>();
        originalMap.put("aa", "blabla");
        entityA.setMapProperty(originalMap);
        EntityA copy = new DeepCopy().copy(entityA);
        assertEquals(originalMap, copy.getMapProperty());
        assertNotSame(originalMap, copy.getMapProperty());
    }
View Full Code Here

        assertNotSame(originalMap, copy.getMapProperty());
    }

    @Test
    public void mapImplementationIsPreservedIfPossible() {
        EntityA entityA = new EntityA();
        LinkedHashMap<Object, Object> mapProperty = new LinkedHashMap<Object, Object>();
        mapProperty.put("ab", "abc");
        entityA.setMapProperty(mapProperty);
        EntityA copy = new DeepCopy().copy(entityA);
        assertThat(copy.getMapProperty(), instanceOf(LinkedHashMap.class));
    }
View Full Code Here

        assertThat(copy.getMapProperty(), instanceOf(LinkedHashMap.class));
    }

    @Test
    public void listsAreCopied() {
        EntityA entityA = new EntityA();
        ArrayList<Object> originalList = new ArrayList<Object>();
        originalList.add(2);
        originalList.add(10);
        originalList.add("abla");
        entityA.setListProperty(originalList);
        EntityA copy = new DeepCopy().copy(entityA);
        assertEquals(originalList, copy.getListProperty());
        assertNotSame(originalList, copy.getListProperty());
    }
View Full Code Here

        assertNotSame(originalList, copy.getListProperty());
    }

    @Test
    public void listImplementationIsPreservedIfPossible() {
        EntityA entityA = new EntityA();
        LinkedList<Object> originalList = new LinkedList<Object>();
        originalList.add(2);
        entityA.setListProperty(originalList);
        EntityA copy = new DeepCopy().copy(entityA);
        assertThat(copy.getListProperty(), instanceOf(LinkedList.class));
    }
View Full Code Here

        assertThat(copy.getListProperty(), instanceOf(LinkedList.class));
    }

    @Test
    public void ignoredFieldsAreNotCopied() {
        EntityA entityA = new EntityA();
        entityA.setIgnoredProperty("blabla");
        EntityA copy = new DeepCopy().copy(entityA);
        assertThat(copy.getIgnoredProperty(), nullValue());
    }
View Full Code Here

        assertThat(copy.getIgnoredProperty(), nullValue());
    }

    @Test
    public void sharedFieldsAreCopiedWithTheSameReference() {
        EntityA entityA = new EntityA();
        Date originalDate = new Date();
        entityA.setSharedProperty(originalDate);
        EntityA copy = new DeepCopy().copy(entityA);
        assertSame(originalDate, copy.getSharedProperty());
    }
View Full Code Here

TOP

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

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.