static void checkValidCollectionName(String databaseName, String collectionName) {
    String fullCollectionName = databaseName + "." + collectionName;
    if (collectionName.length() < MIN_COLLECTION_NAME_LENGTH) {
      throw new IllegalArgumentException("Collection name cannot be empty.");
    }
    if (fullCollectionName.length() > MAX_COLLECTION_NAME_LENGTH) {
      throw new IllegalArgumentException(
          "Collection name "
              + fullCollectionName
              + " cannot be longer than "
              + MAX_COLLECTION_NAME_LENGTH
              + " characters, including the database name and dot.");
    }
    if (ILLEGAL_COLLECTION_CHARS.matcher(collectionName).find()) {
      throw new IllegalArgumentException(
          "Collection name "
              + collectionName
              + " is not a valid name. Only letters, numbers, hyphens, underscores and exclamation points are allowed.");
    }
    if (collectionName.charAt(0) != '_' && !Character.isLetter(collectionName.charAt(0))) {
      throw new IllegalArgumentException(
          "Collection name " + collectionName + " must start with a letter or an underscore.");
    }
    String illegalKeyword = "system.";
    if (collectionName.startsWith(illegalKeyword)) {
      throw new IllegalArgumentException(
          "Collection name "
              + collectionName
              + " cannot start with the prefix \""
              + illegalKeyword
              + "\".");
    }
  }
@Test
  public void testCheckValidCollectionNameThrowsErrorWhenNameIsTooLong() {
    assertThrows(
        IllegalArgumentException.class,
        () -> checkValidCollectionName(StringUtils.repeat("a", 1), StringUtils.repeat("b", 100)));
    assertThrows(
        IllegalArgumentException.class,
        () -> checkValidCollectionName(StringUtils.repeat("a", 50), StringUtils.repeat("b", 50)));
    assertThrows(
        IllegalArgumentException.class,
        () -> checkValidCollectionName(StringUtils.repeat("a", 100), StringUtils.repeat("b", 1)));
  }