@Test
    public void fieldName() {
        assertEquals("userName", BeanUtils.fieldName("UserName", PropertyNamingStrategy.CamelCase.name()));
        assertEquals("userName", BeanUtils.fieldName("userName", PropertyNamingStrategy.CamelCase.name()));
        assertEquals("userName", BeanUtils.fieldName("UserName", PropertyNamingStrategy.NeverUseThisValueExceptDefaultValue.name()));

        assertEquals("UserName", BeanUtils.fieldName("UserName", PropertyNamingStrategy.PascalCase.name()));
        assertEquals("UserName", BeanUtils.fieldName("userName", PropertyNamingStrategy.PascalCase.name()));

        assertEquals("user-name", BeanUtils.fieldName("userName", PropertyNamingStrategy.LowerCaseWithDashes.name()));
        assertEquals("user-name", BeanUtils.fieldName("UserName", PropertyNamingStrategy.LowerCaseWithDashes.name()));

        assertEquals("User-Name", BeanUtils.fieldName("userName", PropertyNamingStrategy.UpperCamelCaseWithDashes.name()));
        assertEquals("User-Name", BeanUtils.fieldName("UserName", PropertyNamingStrategy.UpperCamelCaseWithDashes.name()));

        assertEquals("user-name", BeanUtils.fieldName("UserName", PropertyNamingStrategy.LowerCaseWithDashes.name()));
        assertEquals("user-name", BeanUtils.fieldName("userName", PropertyNamingStrategy.LowerCaseWithDashes.name()));

        assertEquals("USER-NAME", BeanUtils.fieldName("UserName", PropertyNamingStrategy.UpperCaseWithDashes.name()));
        assertEquals("USER-NAME", BeanUtils.fieldName("userName", PropertyNamingStrategy.UpperCaseWithDashes.name()));
        assertEquals("A-U-R-L", BeanUtils.fieldName("aURL", PropertyNamingStrategy.UpperCaseWithDashes.name()));
        assertEquals("_SOME-FIELD-NAME", BeanUtils.fieldName("_someFieldName", PropertyNamingStrategy.UpperCaseWithDashes.name()));

        assertEquals("some.field.name", BeanUtils.fieldName("someFieldName", PropertyNamingStrategy.LowerCaseWithDots.name()));
        assertEquals("user.name", BeanUtils.fieldName("userName", PropertyNamingStrategy.LowerCaseWithDots.name()));
        assertEquals("a.u.r.l", BeanUtils.fieldName("aURL", PropertyNamingStrategy.LowerCaseWithDots.name()));
        assertEquals("_some.field.name", BeanUtils.fieldName("_someFieldName", PropertyNamingStrategy.LowerCaseWithDots.name()));

        assertEquals("SOME.FIELD.NAME", BeanUtils.fieldName("someFieldName", PropertyNamingStrategy.UpperCaseWithDots.name()));
        assertEquals("USER.NAME", BeanUtils.fieldName("userName", PropertyNamingStrategy.UpperCaseWithDots.name()));
        assertEquals("A.U.R.L", BeanUtils.fieldName("aURL", PropertyNamingStrategy.UpperCaseWithDots.name()));
        assertEquals("_SOME.FIELD.NAME", BeanUtils.fieldName("_someFieldName", PropertyNamingStrategy.UpperCaseWithDots.name()));

        assertEquals("id", BeanUtils.setterName("id", "PascalCase"));
        assertEquals("Id", BeanUtils.setterName("setId", "PascalCase"));

        assertEquals("USERID", BeanUtils.setterName("setUserId", "UpperCase"));
        assertEquals("USER_ID", BeanUtils.setterName("setUserId", "UpperCaseWithUnderScores"));

        assertThrows(Exception.class, () -> BeanUtils.setterName("setUserId", "x"));
        assertThrows(Exception.class, () -> BeanUtils.getterName("setUserId", "x"));
        assertThrows(Exception.class, () -> BeanUtils.fieldName("setUserId", "x"));

        assertEquals("USER_ID", BeanUtils.getterName("getUserId", "UpperCaseWithUnderScores"));
        assertEquals("better", BeanUtils.getterName("isBetter", "KebabCase"));
        assertEquals("user-id", BeanUtils.getterName("getUserId", "KebabCase"));
        assertEquals("id", BeanUtils.getterName("id", "KebabCase"));
        assertEquals("Id", BeanUtils.getterName("id", "PascalCase"));

        TypeUtils.CHARS_UPDATER.set(TypeUtils.CACHE, null);
        assertEquals("user_id", BeanUtils.getterName("getUserId", "SnakeCase"));

        TypeUtils.CHARS_UPDATER.set(TypeUtils.CACHE, null);
        assertEquals("User Id", BeanUtils.getterName("getUserId", "UpperCamelCaseWithSpaces"));

        TypeUtils.CHARS_UPDATER.set(TypeUtils.CACHE, null);
        assertEquals("USER-ID", BeanUtils.getterName("getUserId", "UpperCaseWithDashes"));
        TypeUtils.CHARS_UPDATER.set(TypeUtils.CACHE, null);
        assertEquals("USER.ID", BeanUtils.getterName("getUserId", "UpperCaseWithDots"));
    }
note

@author kon, created on 2022/4/27T11:04.
@version 1.0.0-SNAPSHOT
core/src/test/java/com/alibaba/fastjson2/util/BeanUtilsTest.java