mirror of
https://github.com/alibaba/testable-mock.git
synced 2026-08-19 09:43:29 +08:00
feat: support generate class with dollar in name
This commit is contained in:
@@ -85,7 +85,7 @@ public class ConstructionUtil {
|
||||
|
||||
private static String getClassName(Type clazz) {
|
||||
if (clazz instanceof Class) {
|
||||
return ((Class<?>)clazz).getName().replace(DOLLAR, DOT);
|
||||
return ((Class<?>)clazz).getCanonicalName();
|
||||
}
|
||||
return clazz.toString();
|
||||
}
|
||||
|
||||
@@ -47,6 +47,10 @@ class ConstructionUtilTest {
|
||||
public abstract P getByMap(Map<String, P> m);
|
||||
}
|
||||
|
||||
public interface StringMap extends Map<String, Object> {}
|
||||
|
||||
public interface Inner$Interface {}
|
||||
|
||||
@Test
|
||||
void should_generate_empty_interface() throws Exception {
|
||||
EmptyInterface ins = ConstructionUtil.generateSubClassOf(EmptyInterface.class);
|
||||
@@ -71,6 +75,18 @@ class ConstructionUtilTest {
|
||||
assertNotNull(ins);
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_generate_typed_interface() throws Exception {
|
||||
StringMap ins = ConstructionUtil.generateSubClassOf(StringMap.class);
|
||||
assertNotNull(ins);
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_generate_name_with_dollar() throws Exception {
|
||||
Inner$Interface ins = ConstructionUtil.generateSubClassOf(Inner$Interface.class);
|
||||
assertNotNull(ins);
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_get_class_name() throws Exception {
|
||||
// common class, e.g. String
|
||||
|
||||
Reference in New Issue
Block a user