Skip to content

Commit

Permalink
* Modified key used by RawConstructor to allow for 'mix-in' (instead …
Browse files Browse the repository at this point in the history
…of constructor name use <init>).

* Updated test cases for key change...now have 100% coverage.
  • Loading branch information
blangel committed Apr 26, 2012
1 parent adaee3b commit ede6a6f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 14 deletions.
Expand Up @@ -24,7 +24,7 @@ public RawConstructor(ResolvedType context, Constructor<?> constructor)
*/
public MethodKey createKey()
{
String name = _constructor.getName();
String name = "<init>"; // do not use _constructor.getName() to allow for 'mix-ins'
Class<?>[] argTypes = _constructor.getParameterTypes(); // return of Constructor#getParameterTypes will never be null
return new MethodKey(name, argTypes);
}
Expand Down
Expand Up @@ -144,18 +144,13 @@ public void resolveConstructors() {
ResolvedConstructor resolvedConstructor = resolvedConstructors[0];
assertNull(resolvedConstructor.get(Marker.class));

// TODO - there's no way of making a mix-in constructor unless the key used for constructor is changed
// TODO - to disregard the name as constructor's are not overridden

// members = new ResolvedTypeWithMembers(typeResolver,
// new AnnotationConfiguration.StdConfiguration(AnnotationInclusion.INCLUDE_AND_INHERIT), mixinCandidateHierarchicType,
// new HierarchicType[] { mixinAHierarchicType, mixinCandidateHierarchicType }, null, null, null);
// resolvedConstructors = members.resolveConstructors();
// assertEquals(1, resolvedConstructors.length);
// resolvedConstructor = resolvedConstructors[0];
// annotations = (Annotations) annotationsField.get(resolvedConstructor);
// assertEquals(1, annotations.size());
// assertNotNull(annotations.get(Marker.class));
members = new ResolvedTypeWithMembers(typeResolver,
new AnnotationConfiguration.StdConfiguration(AnnotationInclusion.INCLUDE_AND_INHERIT), mixinCandidateHierarchicType,
new HierarchicType[] { mixinAHierarchicType, mixinCandidateHierarchicType }, null, null, null);
resolvedConstructors = members.resolveConstructors();
assertEquals(1, resolvedConstructors.length);
resolvedConstructor = resolvedConstructors[0];
assertNotNull(resolvedConstructor.get(Marker.class));
}

@Test
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/com/fasterxml/classmate/TestReadme.java
Expand Up @@ -42,7 +42,7 @@ public static class SomeOtherClass {
public void someMethod() { }
}

@Test
@Test @SuppressWarnings("serial")
public void resolvingClasses() {
TypeResolver typeResolver = new TypeResolver();
ResolvedType listType = typeResolver.resolve(List.class);
Expand Down
Expand Up @@ -39,6 +39,7 @@ public void createKey() {
RawConstructor rawConstructor = new RawConstructor(new ResolvedObjectType(Object.class, null, null, ResolvedType.NO_TYPES), stringConstructor);
MethodKey methodKey = rawConstructor.createKey();
assertNotNull(methodKey);
assertEquals("<init>()", methodKey.toString());
}

@Test
Expand Down

0 comments on commit ede6a6f

Please sign in to comment.