/** Test If we have only the required values. */
  @Test(dataProvider = "persistentSearchChangeTypeData")
  public void checkRequiredValuesTest(Map<Integer, String> exceptedValues) throws Exception {
    // Retrieve the values
    PersistentSearchChangeType[] vals = PersistentSearchChangeType.values();

    // Check if we have the correct number
    assertEquals(vals.length, exceptedValues.size());

    // Check if we have the correct int value
    for (PersistentSearchChangeType val : vals) {
      assertTrue(exceptedValues.containsKey(val.intValue()));
    }
  }
  /** Test int to type. */
  @Test(dataProvider = "persistentSearchChangeTypeData")
  public void checkIntToTypeTest(Map<Integer, String> exceptedValues) throws Exception {
    Set<Integer> keys = exceptedValues.keySet();

    Set<PersistentSearchChangeType> expectedTypes = new HashSet<>(4);

    for (int i = 1; i <= 15; i++) {
      expectedTypes.clear();
      for (int key : keys) {
        if ((i & key) != 0) {
          expectedTypes.add(PersistentSearchChangeType.valueOf(key));
        }
      }
      Set<PersistentSearchChangeType> returnTypes = PersistentSearchChangeType.intToTypes(i);
      assertEquals(expectedTypes.size(), returnTypes.size());
      for (PersistentSearchChangeType type : expectedTypes) {
        assertTrue(returnTypes.contains(type));
      }
    }

    // We should have an exception
    try {
      PersistentSearchChangeType.intToTypes(0);
      fail();
    } catch (LDAPException expected) {
      assertEquals(
          expected.getMessage(),
          "The provided integer value indicated that there were no persistent search change types, which is not allowed");
    }

    // We should have an exception
    int i = 16;
    try {
      PersistentSearchChangeType.intToTypes(i);
      fail();
    } catch (LDAPException expected) {
      assertEquals(
          expected.getMessage(),
          "The provided integer value "
              + i
              + " was outside the range of acceptable values for an encoded change type set");
    }
  }