public void mapMembersSwappedAndKeptPositions() {
    Configuration testConfig = getFreshConfig();

    int origPassIdx = 0;
    Iterator<Property> it = testConfig.getMap().values().iterator();
    while (it.hasNext()) {
      if ("topLevelPassword".equals(it.next().getName())) {
        break;
      }
      origPassIdx++;
    }

    PasswordObfuscationUtility.obfuscatePasswords(DEFINITION, testConfig);

    Assert.assertTrue(
        testConfig.getSimple("topLevelPassword") instanceof ObfuscatedPropertySimple,
        "The top level password not obfuscated");

    it = testConfig.getMap().values().iterator();
    int idx = 0;
    while (it.hasNext()) {
      if ("topLevelPassword".equals(it.next().getName())) {
        Assert.assertEquals(
            idx,
            origPassIdx,
            "The topLevelPassword seems to have changed the position in the configuration map after obfuscation");
      }
      idx++;
    }
  }
  public void listMembersSwapped() {
    Configuration testConfig = getFreshConfig();

    PasswordObfuscationUtility.obfuscatePasswords(DEFINITION, testConfig);

    PropertyList list = testConfig.getList("topLevelPasswordList");

    Assert.assertNotNull(list, "Could not find the 'topLevelPasswordList'");

    int idx = 0;
    for (Property p : list.getList()) {
      Assert.assertTrue(
          p instanceof ObfuscatedPropertySimple,
          "Found a password property that was not swapped to obfuscated form");
      int value = ((PropertySimple) p).getIntegerValue();
      Assert.assertEquals(
          value, idx++, "Found an out-of-order element after obfuscation processing.");
    }
  }
  public void configurationMembersSwappedAndKeptPositions() {
    Configuration testConfig = getFreshConfig();

    // keep track of the order of the properies in the original map
    PropertyMap originalMap =
        (PropertyMap) testConfig.getList("topLevelListOfMaps").getList().get(0);
    List<Property> originalMapPropertiesInOrder =
        new ArrayList<Property>(originalMap.getMap().values());

    PasswordObfuscationUtility.obfuscatePasswords(DEFINITION, testConfig);

    PropertyList list = testConfig.getList("topLevelListOfMaps");

    PropertyMap map = (PropertyMap) list.getList().get(0);

    Assert.assertTrue(
        map.get("password") instanceof ObfuscatedPropertySimple,
        "The password in the map failed to be swapped to obfuscated form");

    // now check that the positions in the map actually didn't change
    List<Property> mapPropertiesInOrder = new ArrayList<Property>(map.getMap().values());

    Assert.assertEquals(
        mapPropertiesInOrder.size(),
        originalMapPropertiesInOrder.size(),
        "Different number of properties in the map after obfuscation");

    for (int i = 0; i < mapPropertiesInOrder.size(); ++i) {
      Property originalProp = originalMapPropertiesInOrder.get(i);
      Property prop = mapPropertiesInOrder.get(i);

      Assert.assertEquals(
          prop.getName(),
          originalProp.getName(),
          "Properties seem to be mixed up after obfuscation");
    }
  }