/**
   * Test that null list of value(s) cannot be put into a {@code PackageGenerationParameters} object
   */
  @Test(expected = IllegalArgumentException.class)
  public void testSetNullValuesListOnParams() {
    PackageGenerationParameters parameters = new PackageGenerationParameters();

    // Test add an empty list values:
    List<String> paramValues = null;
    parameters.addParam(BagItParameterNames.CONTACT_EMAIL, paramValues);
  }
  /** Test adding single-value parameter */
  @Test
  public void testAddSingleValueParameters() {
    PackageGenerationParameters parameters = new PackageGenerationParameters();

    String paramValue = "*****@*****.**";

    parameters.addParam(BagItParameterNames.CONTACT_EMAIL, paramValue);

    assertNotNull(parameters.getParam(BagItParameterNames.CONTACT_EMAIL));
    assertEquals(paramValue, parameters.getParam(BagItParameterNames.CONTACT_EMAIL, 0));
  }
  @Test
  public void testEquals() {
    PackageGenerationParameters parametersOne = new PackageGenerationParameters();

    List<String> paramValues = new ArrayList<>();
    paramValues.add("Willard Poopa-doodle");
    parametersOne.addParam(BagItParameterNames.CONTACT_NAME, paramValues);

    paramValues = new ArrayList<>();
    paramValues.add("*****@*****.**");
    parametersOne.addParam(BagItParameterNames.CONTACT_EMAIL, paramValues);

    paramValues = new ArrayList<>();
    paramValues.add("org.dataconservancy.packaging.format:borem");
    parametersOne.addParam(BagItParameterNames.PACKAGE_FORMAT_ID, paramValues);

    PackageGenerationParameters parametersTwo = new PackageGenerationParameters();

    paramValues = new ArrayList<>();
    paramValues.add("Willard Poopa-doodle");
    parametersTwo.addParam(BagItParameterNames.CONTACT_NAME, paramValues);

    paramValues = new ArrayList<>();
    paramValues.add("*****@*****.**");
    parametersTwo.addParam(BagItParameterNames.CONTACT_EMAIL, paramValues);

    paramValues = new ArrayList<>();
    paramValues.add("org.dataconservancy.packaging.format:borem");
    parametersTwo.addParam(BagItParameterNames.PACKAGE_FORMAT_ID, paramValues);

    assertEquals(parametersOne, parametersTwo);
  }
  /** Test getting a specific parameter value. */
  @Test
  public void testGetParamValue() {
    PackageGenerationParameters parameters = new PackageGenerationParameters();

    // Test add an empty list values:
    List<String> paramValues = new ArrayList<>();
    paramValues.add(null);
    paramValues.add("*****@*****.**");
    paramValues.add("*****@*****.**");
    parameters.addParam(BagItParameterNames.CONTACT_EMAIL, paramValues);

    assertNotNull(parameters.getParam(BagItParameterNames.CONTACT_EMAIL));
    assertTrue(paramValues.containsAll(parameters.getParam(BagItParameterNames.CONTACT_EMAIL)));

    assertEquals(paramValues.get(2), parameters.getParam(BagItParameterNames.CONTACT_EMAIL, 1));
  }
  /**
   * Test that information can be put in and retrieved from a {@code PackageGenerationParameters}
   * object
   */
  @Test
  public void testAddAndGetParams() {
    PackageGenerationParameters parameters = new PackageGenerationParameters();
    Map<String, List<String>> addedParameters = new HashMap<>();

    List<String> paramValues = new ArrayList<>();
    paramValues.add("Willard Poopa-doodle");
    parameters.addParam(BagItParameterNames.CONTACT_NAME, paramValues);
    addedParameters.put(BagItParameterNames.CONTACT_NAME, paramValues);

    paramValues = new ArrayList<>();
    paramValues.add("*****@*****.**");
    parameters.addParam(BagItParameterNames.CONTACT_EMAIL, paramValues);
    addedParameters.put(BagItParameterNames.CONTACT_EMAIL, paramValues);

    paramValues = new ArrayList<>();
    paramValues.add("org.dataconservancy.packaging.format:borem");
    parameters.addParam(BagItParameterNames.PACKAGE_FORMAT_ID, paramValues);
    addedParameters.put(BagItParameterNames.PACKAGE_FORMAT_ID, paramValues);

    // assert that there are 3 entry in the parameters map.
    assertEquals(3, parameters.getKeys().size());
    assertEquals(addedParameters.keySet(), parameters.getKeys());

    for (String key : addedParameters.keySet()) {
      assertEquals(addedParameters.get(key), parameters.getParam(key));
    }
  }
  /** Test adding additional value to existing parameter */
  @Test
  public void testAddValueToExistingParameters() {
    PackageGenerationParameters parameters = new PackageGenerationParameters();

    String paramValue = "*****@*****.**";
    parameters.addParam(BagItParameterNames.CONTACT_EMAIL, paramValue);

    assertNotNull(parameters.getParam(BagItParameterNames.CONTACT_EMAIL));
    assertEquals(paramValue, parameters.getParam(BagItParameterNames.CONTACT_EMAIL, 0));
    assertEquals(1, parameters.getParam(BagItParameterNames.CONTACT_EMAIL).size());

    String additionalParamValue = "*****@*****.**";
    parameters.addParam(BagItParameterNames.CONTACT_EMAIL, additionalParamValue);
    assertEquals(2, parameters.getParam(BagItParameterNames.CONTACT_EMAIL).size());
    assertTrue(parameters.getParam(BagItParameterNames.CONTACT_EMAIL).contains(paramValue));
    assertTrue(
        parameters.getParam(BagItParameterNames.CONTACT_EMAIL).contains(additionalParamValue));
  }
  /** Test that empty and null values get removed from parameters values. */
  @Test
  public void testEmptyNullValuesGetWeededOut() {
    PackageGenerationParameters parameters = new PackageGenerationParameters();

    // Test add an empty list values:
    List<String> paramValues = new ArrayList<>();
    paramValues.add(null);
    paramValues.add(" ");
    paramValues.add("*****@*****.**");
    parameters.addParam(BagItParameterNames.CONTACT_EMAIL, paramValues);

    assertNotNull(parameters.getParam(BagItParameterNames.CONTACT_EMAIL));
    assertTrue(paramValues.containsAll(parameters.getParam(BagItParameterNames.CONTACT_EMAIL)));

    assertEquals(1, parameters.getParam(BagItParameterNames.CONTACT_EMAIL).size());
    assertEquals(paramValues.get(2), parameters.getParam(BagItParameterNames.CONTACT_EMAIL, 0));
  }
  @Test
  public void testOverride() {
    PackageGenerationParameters parametersOne = new PackageGenerationParameters();

    String contactOne = "Willard Poopa-doodle";
    String contactTwo = "Some Random Guy";

    String emailOne = "*****@*****.**";
    String emailTwo = "*****@*****.**";

    String formatId = "org.dataconservancy.packaging.format:borem";

    List<String> paramValues = new ArrayList<>();
    paramValues.add(contactOne);
    parametersOne.addParam(BagItParameterNames.CONTACT_NAME, paramValues);

    paramValues = new ArrayList<>();
    paramValues.add(emailOne);
    parametersOne.addParam(BagItParameterNames.CONTACT_EMAIL, paramValues);

    paramValues = new ArrayList<>();
    paramValues.add(formatId);
    parametersOne.addParam(BagItParameterNames.PACKAGE_FORMAT_ID, paramValues);

    PackageGenerationParameters parametersTwo = new PackageGenerationParameters();

    paramValues = new ArrayList<>();
    paramValues.add(contactTwo);
    parametersTwo.addParam(BagItParameterNames.CONTACT_NAME, paramValues);

    paramValues = new ArrayList<>();
    paramValues.add(emailTwo);
    parametersTwo.addParam(BagItParameterNames.CONTACT_EMAIL, paramValues);

    parametersOne.overrideParams(parametersTwo);

    assertEquals(contactTwo, parametersOne.getParam(BagItParameterNames.CONTACT_NAME).get(0));
    assertEquals(emailTwo, parametersOne.getParam(BagItParameterNames.CONTACT_EMAIL).get(0));
    assertEquals(formatId, parametersOne.getParam(BagItParameterNames.PACKAGE_FORMAT_ID).get(0));
  }
  @Test
  public void testRemoveParam() {
    PackageGenerationParameters parametersOne = new PackageGenerationParameters();

    List<String> paramValues = new ArrayList<>();
    paramValues.add("Willard Poopa-doodle");
    parametersOne.addParam(BagItParameterNames.CONTACT_NAME, paramValues);

    paramValues = new ArrayList<>();
    paramValues.add("*****@*****.**");
    parametersOne.addParam(BagItParameterNames.CONTACT_EMAIL, paramValues);

    paramValues = new ArrayList<>();
    paramValues.add("org.dataconservancy.packaging.format:borem");
    parametersOne.addParam(BagItParameterNames.PACKAGE_FORMAT_ID, paramValues);

    // make sure the above params were added
    assertTrue(parametersOne.getKeys().contains(BagItParameterNames.CONTACT_NAME));
    assertTrue(parametersOne.getKeys().contains(BagItParameterNames.CONTACT_EMAIL));
    assertTrue(parametersOne.getKeys().contains(BagItParameterNames.PACKAGE_FORMAT_ID));

    // remove one param
    parametersOne.removeParam(BagItParameterNames.PACKAGE_FORMAT_ID);

    // make sure that the remove params is no longer there.
    assertTrue(parametersOne.getKeys().contains(BagItParameterNames.CONTACT_NAME));
    assertTrue(parametersOne.getKeys().contains(BagItParameterNames.CONTACT_EMAIL));
    assertFalse(parametersOne.getKeys().contains(BagItParameterNames.PACKAGE_FORMAT_ID));

    // make sure that attempt to remove param that doesn't exist does not cause exception
    // remove one param
    parametersOne.removeParam(BagItParameterNames.PACKAGE_FORMAT_ID);

    // make sure that the remove params is no longer there.
    assertTrue(parametersOne.getKeys().contains(BagItParameterNames.CONTACT_NAME));
    assertTrue(parametersOne.getKeys().contains(BagItParameterNames.CONTACT_EMAIL));
  }