示例#1
0
  public void testPath() throws Exception {

    // root path CAR
    assertEquals("root", "/", definition.path());

    // wheels attribute
    CAttribute wheels = definition.getAttributes().get(0);
    assertEquals("wheels", "/wheels", wheels.path());

    // first WHEEL node
    CObject firstWheel = wheels.getChildren().get(0);
    assertEquals("first wheel", "/wheels[at0001]", firstWheel.path());

    // description and parts of first WHEEL
    CComplexObject firstWheelObj = (CComplexObject) firstWheel;
    CAttribute description = firstWheelObj.getAttributes().get(0);
    assertEquals("first wheel description", "/wheels[at0001]/description", description.path());
    CAttribute parts = firstWheelObj.getAttributes().get(1);
    assertEquals("first wheel parts", "/wheels[at0001]/parts", parts.path());

    // WHEEL_PART node
    CObject wheelParts = parts.getChildren().get(0);
    assertEquals("wheelPart", "/wheels[at0001]/parts[at0002]", wheelParts.path());

    // something and something_else of WHEEL_PART node
    CComplexObject wheelPartsObj = (CComplexObject) wheelParts;
    assertEquals(
        "something of WHEEL_PART",
        "/wheels[at0001]/parts[at0002]/something",
        wheelPartsObj.getAttributes().get(0).path());

    assertEquals(
        "something_else of WHEEL_PART",
        "/wheels[at0001]/parts[at0002]/something_else",
        wheelPartsObj.getAttributes().get(1).path());
  }