@Test
  public void extractingAll() throws Exception {
    TextFileInputMetaInjection injection = new TextFileInputMetaInjection(new TextFileInputMeta());
    List<StepInjectionMetaEntry> metadata = injection.getStepInjectionMetadataEntries();
    List<StepInjectionMetaEntry> extracted = injection.extractStepMetadataEntries();

    assertEquals(metadata.size(), extracted.size());
    for (StepInjectionMetaEntry metaEntry : metadata) {
      assertNotNull(metaEntry.getKey(), StepInjectionUtil.findEntry(extracted, metaEntry.getKey()));
    }
  }
  private static void assertInjected(
      List<StepInjectionMetaEntry> fields, List<StepInjectionMetaEntry> toBeInjected) {
    Map<String, StepInjectionMetaEntry> map =
        new HashMap<String, StepInjectionMetaEntry>(fields.size());
    for (StepInjectionMetaEntry field : fields) {
      map.put(field.getKey(), field);
    }

    for (StepInjectionMetaEntry entry : toBeInjected) {
      StepInjectionMetaEntry field = map.get(entry.getKey());
      assertNotNull(entry.getKey(), field);

      Object value = field.getValue();
      if (value == null) {
        assertNull(entry.getKey(), entry.getValue());
      } else {
        assertEquals(entry.getKey(), entry.getValue(), value);
      }
    }
  }
  public void injectStepMetadataEntries(List<StepInjectionMetaEntry> metadata) {
    for (StepInjectionMetaEntry entry : metadata) {
      KettleAttributeInterface attr = findAttribute(entry.getKey());

      // Set top level attributes...
      //
      if (entry.getValueType() != ValueMetaInterface.TYPE_NONE) {

        if (entry.getKey().equals("SCHEMA")) {
          schemaName = (String) entry.getValue();
        } else if (entry.getKey().equals("TABLE")) {
          tableName = (String) entry.getValue();
        } else if (entry.getKey().equals("LOADACTION")) {
          loadAction = (String) entry.getValue();
        } else if (entry.getKey().equals("PSQLPATH")) {
          setPsqlpath((String) entry.getValue());
        } else if (entry.getKey().equals("DBNAMEOVERRIDE")) {
          dbNameOverride = (String) entry.getValue();
        } else if (entry.getKey().equals("ENCLOSURE")) {
          enclosure = (String) entry.getValue();
        } else if (entry.getKey().equals("DELIMITER")) {
          delimiter = (String) entry.getValue();
        } else if (entry.getKey().equals("STOPONERROR")) {
          stopOnError = (Boolean) entry.getValue();
        } else {
          throw new RuntimeException(
              "Unhandled metadata injection of attribute: "
                  + attr.toString()
                  + " - "
                  + attr.getDescription());
        }
      } else {
        // The data sets...
        //
        if (attr.getKey().equals("MAPPINGS")) {
          List<StepInjectionMetaEntry> selectMappings = entry.getDetails();

          fieldTable = new String[selectMappings.size()];
          fieldStream = new String[selectMappings.size()];
          dateMask = new String[selectMappings.size()];

          for (int row = 0; row < selectMappings.size(); row++) {
            StepInjectionMetaEntry selectField = selectMappings.get(row);

            List<StepInjectionMetaEntry> fieldAttributes = selectField.getDetails();
            // CHECKSTYLE:Indentation:OFF
            for (int i = 0; i < fieldAttributes.size(); i++) {
              StepInjectionMetaEntry fieldAttribute = fieldAttributes.get(i);
              KettleAttributeInterface fieldAttr = findAttribute(fieldAttribute.getKey());

              String attributeValue = (String) fieldAttribute.getValue();
              if (fieldAttr.getKey().equals("STREAMNAME")) {
                getFieldStream()[row] = attributeValue;
              } else if (fieldAttr.getKey().equals("FIELDNAME")) {
                getFieldTable()[row] = attributeValue;
              } else if (fieldAttr.getKey().equals("DATEMASK")) {
                getDateMask()[row] = attributeValue;
              } else {
                throw new RuntimeException(
                    "Unhandled metadata injection of attribute: "
                        + fieldAttr.toString()
                        + " - "
                        + fieldAttr.getDescription());
              }
            }
          }
        }
        if (!Const.isEmpty(getFieldStream())) {
          for (int i = 0; i < getFieldStream().length; i++) {
            logDetailed(
                "row "
                    + Integer.toString(i)
                    + ": stream="
                    + getFieldStream()[i]
                    + " : table="
                    + getFieldTable()[i]);
          }
        }
      }
    }
  }