if (this.skipObjCTests) {
System.out.println("C tests have been disabled.");
return;
}
Cat cat = new Cat();
Circle face = new Circle();
face.setRadius(20);
cat.setFace(face);
Triangle ear = new Triangle();
ear.setBase(5);
ear.setHeight(10);
ear.setId("earId");
cat.setEars(Arrays.asList(ear, ear));
// The eyes are the same as the ears, but so it needs to be for this test.
cat.setEyes(new Triangle[] {ear, ear});
Line noseLine = new Line();
noseLine.setId("noseId");
Line mouthLine = new Line();
mouthLine.setId("mouthLine");
cat.setNose(noseLine);
cat.setMouth(mouthLine);
cat.setWhiskers(Arrays.asList(noseLine, mouthLine));
cat = processThroughXml(cat);
face = cat.getFace();
assertEquals(20, face.getRadius());
assertEquals(2, cat.getEars().size());
Triangle[] ears = cat.getEars().toArray(new Triangle[2]);
assertSame("referential integrity should have been preserved (same object for ears)", ears[0], ears[1]);
assertEquals(5, ears[0].getBase());
assertEquals(10, ears[0].getHeight());
assertEquals("earId", ears[0].getId());
Triangle[] eyes = cat.getEyes();
assertEquals(2, eyes.length);
assertNotSame(eyes[0], eyes[1]);
assertEquals(5, eyes[0].getBase());
assertEquals(10, eyes[0].getHeight());
assertEquals("earId", eyes[0].getId());
assertEquals(5, eyes[1].getBase());
assertEquals(10, eyes[1].getHeight());
assertEquals("earId", eyes[1].getId());
assertTrue("The ears should be the same object as one of the eyes (preserve referential integrity).", ears[0] == eyes[0] || ears[0] == eyes[1]);
Line nose = cat.getNose();
assertEquals("noseId", nose.getId());
Line mouth = cat.getMouth();
assertEquals("mouthLine", mouth.getId());
assertTrue("The nose line should also be one of the whiskers (preserve referential integrity)", cat.getWhiskers().contains(nose));
assertTrue("The mouth line should also be one of the whiskers (preserve referential integrity)", cat.getWhiskers().contains(mouth));
}