Package org.optaplanner.core.impl.testdata.domain.extended

Examples of org.optaplanner.core.impl.testdata.domain.extended.TestdataExtendedEntity


        SolutionCloner<TestdataSolution> cloner = createSolutionCloner(solutionDescriptor);

        TestdataValue val1 = new TestdataValue("1");
        TestdataValue val2 = new TestdataValue("2");
        TestdataValue val3 = new TestdataValue("3");
        TestdataExtendedEntity a = new TestdataExtendedEntity("a", val1, null);
        TestdataExtendedEntity b = new TestdataExtendedEntity("b", val1, "extraObjectOnEntity");
        TestdataExtendedEntity c = new TestdataExtendedEntity("c", val3);
        TestdataExtendedEntity d = new TestdataExtendedEntity("d", val3, c);
        c.setExtraObject(d);

        TestdataExtendedSolution original = new TestdataExtendedSolution("solution", "extraObjectOnSolution");
        List<TestdataValue> valueList = Arrays.asList(val1, val2, val3);
        original.setValueList(valueList);
        List<TestdataEntity> originalEntityList = Arrays.<TestdataEntity>asList(a, b, c, d);
        original.setEntityList(originalEntityList);

        TestdataExtendedSolution clone = (TestdataExtendedSolution) cloner.cloneSolution(original);

        assertNotSame(original, clone);
        assertCode("solution", clone);
        assertEquals("extraObjectOnSolution", clone.getExtraObject());
        assertSame(valueList, clone.getValueList());

        List<TestdataEntity> cloneEntityList = clone.getEntityList();
        assertNotSame(originalEntityList, cloneEntityList);
        assertEquals(4, cloneEntityList.size());
        TestdataExtendedEntity cloneA = (TestdataExtendedEntity) cloneEntityList.get(0);
        TestdataExtendedEntity cloneB = (TestdataExtendedEntity) cloneEntityList.get(1);
        TestdataExtendedEntity cloneC = (TestdataExtendedEntity) cloneEntityList.get(2);
        TestdataExtendedEntity cloneD = (TestdataExtendedEntity) cloneEntityList.get(3);
        assertEntityClone(a, cloneA, "a", "1");
        assertEquals(null, cloneA.getExtraObject());
        assertEntityClone(b, cloneB, "b", "1");
        assertEquals("extraObjectOnEntity", cloneB.getExtraObject());
        assertEntityClone(c, cloneC, "c", "3");
        assertEquals(cloneD, cloneC.getExtraObject());
        assertEntityClone(d, cloneD, "d", "3");
        assertEquals(cloneC, cloneD.getExtraObject());

        b.setValue(val2);
        assertCode("2", b.getValue());
        // Clone remains unchanged
        assertCode("1", cloneB.getValue());
View Full Code Here

TOP

Related Classes of org.optaplanner.core.impl.testdata.domain.extended.TestdataExtendedEntity

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.