ImmutableList<PayloadDefinition> validatePayloads(List<PayloadDefinition> payloads) {
    for (PayloadDefinition p : payloads) {
      checkArgument(p.hasName(), "Parsed payload does not have a name.");
      checkArgument(
          p.getInterpretationEnvironment()
              != PayloadGeneratorConfig.InterpretationEnvironment
                  .INTERPRETATION_ENVIRONMENT_UNSPECIFIED,
          "Parsed payload does not have an interpretation_environment.");
      checkArgument(
          p.getExecutionEnvironment()
              != PayloadGeneratorConfig.ExecutionEnvironment.EXECUTION_ENVIRONMENT_UNSPECIFIED,
          "Parsed payload does not have an exeuction_environment.");
      checkArgument(
          !p.getVulnerabilityTypeList().isEmpty(),
          "Parsed payload has no entries for vulnerability_type.");
      checkArgument(p.hasPayloadString(), "Parsed payload does not have a payload_string.");

      if (p.getUsesCallbackServer().getValue()) {
        checkArgument(
            p.getPayloadString().getValue().contains("$TSUNAMI_PAYLOAD_TOKEN_URL"),
            "Parsed payload uses callback server but $TSUNAMI_PAYLOAD_TOKEN_URL not found in"
                + " payload_string.");
      } else {
        checkArgument(
            p.getValidationType() != PayloadValidationType.VALIDATION_TYPE_UNSPECIFIED,
            "Parsed payload has no validation_type and does not use the callback server.");

        if (p.getValidationType() == PayloadValidationType.VALIDATION_REGEX) {
          checkArgument(
              p.hasValidationRegex(),
              "Parsed payload has no validation_regex but uses PayloadValidationType.REGEX");
        }
      }
    }

    return ImmutableList.copyOf(payloads);
  }
@Test
  public void validatePayloads_withoutExecutionEnvironment_throwsException() throws IOException {
    PayloadDefinition p = goodCallbackDefinition.clearExecutionEnvironment().build();

    Throwable thrown =
        assertThrows(
            IllegalArgumentException.class, () -> module.validatePayloads(ImmutableList.of(p)));
    assertThat(thrown).hasMessageThat().contains("exeuction_environment");
  }