Testing String Utility Map Key Transformations in Arthas
This test suite validates the StringUtils functionality in Arthas Spring Boot, specifically focusing on key-transformation operations in map structures. The tests verify the proper handling of dash-containing keys and their conversion to camelCase format.
Test Coverage Overview
Implementation Analysis
Technical Details
Best Practices Demonstrated
alibaba/arthas
arthas-spring-boot-starter/src/test/java/com/alibaba/arthas/spring/StringUtilsTest.java
package com.alibaba.arthas.spring;
import java.util.HashMap;
import java.util.Map;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.Test;
/**
*
* @author hengyunabc 2020-06-24
*
*/
public class StringUtilsTest {
@Test
public void test() {
Map<String, String> map = new HashMap<String, String>();
map.put("telnet-port", "" + 9999);
map.put("aaa--bbb", "fff");
map.put("123", "123");
map.put("123-", "123");
map.put("123-abc", "123");
map.put("xxx-", "xxx");
map = StringUtils.removeDashKey(map);
Assertions.assertThat(map).containsEntry("telnetPort", "" + 9999);
Assertions.assertThat(map).containsEntry("aaa-Bbb", "fff");
Assertions.assertThat(map).containsEntry("123", "123");
Assertions.assertThat(map).containsEntry("123-", "123");
Assertions.assertThat(map).containsEntry("123Abc", "123");
Assertions.assertThat(map).containsEntry("xxx-", "xxx");
}
}