LearnerGraph grA = buildLearnerGraph(graphA,name+"A",configNesting,converter);
LearnerGraph grB = buildLearnerGraph(graphB,name+"B",configNesting,converter);
grA.setIDNumbers();grB.setIDNumbers();
GD<CmpVertex,CmpVertex,LearnerGraphCachedData,LearnerGraphCachedData> gd = new GD<CmpVertex,CmpVertex,LearnerGraphCachedData,LearnerGraphCachedData>();
ChangesRecorder rec1 = new ChangesRecorder(null);
ChangesDisplay rec2 = new ChangesDisplay(rec1);
ChangesCounter<CmpVertex,CmpVertex,LearnerGraphCachedData,LearnerGraphCachedData> rec3 = new ChangesCounter<CmpVertex,CmpVertex,LearnerGraphCachedData,LearnerGraphCachedData>(grA,grB,rec2);
ChangesRecorder rec4 = new ChangesRecorder(rec3);
ChangesDisplay rec5 = new ChangesDisplay(rec4);
ChangesCounter<CmpVertex,CmpVertex,LearnerGraphCachedData,LearnerGraphCachedData> rec6 = new ChangesCounter<CmpVertex,CmpVertex,LearnerGraphCachedData,LearnerGraphCachedData>(grA,grB,rec5);
ChangesRecorder rec7 = new ChangesRecorder(rec6);
ChangesDisplay rec8 = new ChangesDisplay(rec7);
ChangesCounter<CmpVertex,CmpVertex,LearnerGraphCachedData,LearnerGraphCachedData> rec9 = new ChangesCounter<CmpVertex,CmpVertex,LearnerGraphCachedData,LearnerGraphCachedData>(grA,grB,rec8);
{// compute GD and check that changes recorded by rec9 are correct.
LearnerGraph graph1 = buildLearnerGraph(graphA,name+"A",configNesting,converter);
ChangesRecorder.applyGD(graph1, gd.computeGDToXML(grA, grB, threadNumber, TestGD.createDoc(), rec9,configNesting), converter);
Assert.assertNull(WMethod.checkM(graph1, grB));Assert.assertEquals(grB.getStateNumber(),graph1.getStateNumber());
}
{// check that changes propagated to rec7 are correct.
LearnerGraph graph2 = buildLearnerGraph(graphA,name+"A",configNesting,converter);
ChangesRecorder.applyGD(graph2, rec7.writeGD(TestGD.createDoc()), converter);
Assert.assertNull(WMethod.checkM(graph2, grB));Assert.assertEquals(grB.getStateNumber(),graph2.getStateNumber());
}
{// check that changes propagated to rec4 are correct.
LearnerGraph graph3 = buildLearnerGraph(graphA,name+"A",configNesting,converter);
ChangesRecorder.applyGD(graph3, rec4.writeGD(TestGD.createDoc()), converter);
Assert.assertNull(WMethod.checkM(graph3, grB));Assert.assertEquals(grB.getStateNumber(),graph3.getStateNumber());
}
{// check that changes propagated to rec1 are correct.
LearnerGraph graph4 = buildLearnerGraph(graphA,name+"A",configNesting,converter);
ChangesRecorder.applyGD(graph4, rec1.writeGD(TestGD.createDoc()), converter);
Assert.assertNull(WMethod.checkM(graph4, grB));Assert.assertEquals(grB.getStateNumber(),graph4.getStateNumber());
}
String displayResult = rec8.toString();
Assert.assertEquals(displayResult,rec5.toString());Assert.assertEquals(displayResult, rec2.toString());
int added = rec9.getAdded(),removed = rec9.getRemoved();String result = rec9.toString();
Assert.assertEquals(added,rec6.getAdded());Assert.assertEquals(removed,rec6.getRemoved());Assert.assertEquals(result,rec6.toString());
Assert.assertEquals(added,rec3.getAdded());Assert.assertEquals(removed,rec3.getRemoved());Assert.assertEquals(result,rec3.toString());