Skip to content

Commit

Permalink
Fixed more tests that broke because of new API.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rafael Winterhalter committed Jan 4, 2016
1 parent 82fdc6f commit 1843d42
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 8 deletions.
Expand Up @@ -1915,6 +1915,7 @@ public Builder define(String property, TypeDescription typeDescription) {
* @param <T> The enumeration type. * @param <T> The enumeration type.
* @return A builder with the additional class property. * @return A builder with the additional class property.
*/ */
@SuppressWarnings("unchecked")
public <T extends Enum<?>> Builder defineEnumerationArray(String property, Class<T> enumerationType, T... value) { public <T extends Enum<?>> Builder defineEnumerationArray(String property, Class<T> enumerationType, T... value) {
EnumerationDescription[] enumerationDescription = new EnumerationDescription[value.length]; EnumerationDescription[] enumerationDescription = new EnumerationDescription[value.length];
int index = 0; int index = 0;
Expand Down Expand Up @@ -1965,6 +1966,7 @@ public Builder defineEnumerationArray(String property, TypeDescription enumerati
* @param <T> The annotation type. * @param <T> The annotation type.
* @return A builder with the additional annotation property. * @return A builder with the additional annotation property.
*/ */
@SuppressWarnings("unchecked")
public <T extends Annotation> Builder defineAnnotationArray(String property, Class<T> annotationType, T... annotation) { public <T extends Annotation> Builder defineAnnotationArray(String property, Class<T> annotationType, T... annotation) {
return defineAnnotationArray(property, return defineAnnotationArray(property,
new TypeDescription.ForLoadedType(annotationType), new TypeDescription.ForLoadedType(annotationType),
Expand Down
Expand Up @@ -76,10 +76,22 @@ protected Resolver(Collection<? extends T> modifierContributors) {
this.modifierContributors = modifierContributors; this.modifierContributors = modifierContributors;
} }


public static <S extends ModifierContributor> Resolver<S> of(S... modifierContributor) { public static Resolver<ForType> of(ForType... modifierContributor) {
return of(Arrays.asList(modifierContributor)); return of(Arrays.asList(modifierContributor));
} }


public static Resolver<ForField> of(ForField... modifierContributor) {
return of(Arrays.asList(modifierContributor));
}

public static Resolver<ForMethod> of(ForMethod... modifierContributor) {
return of(Arrays.asList(modifierContributor));
}

public static Resolver<ForParameter> of(ForParameter... modifierContributor) {
return Resolver.of(Arrays.asList(modifierContributor));
}

public static <S extends ModifierContributor> Resolver<S> of(Collection<? extends S> modifierContributors) { public static <S extends ModifierContributor> Resolver<S> of(Collection<? extends S> modifierContributors) {
return new Resolver<S>(modifierContributors); return new Resolver<S>(modifierContributors);
} }
Expand Down
Expand Up @@ -1740,7 +1740,7 @@ public MethodDefinition<U> annotateMethod(Collection<? extends AnnotationDescrip
token.getReturnType(), token.getReturnType(),
token.getParameterTokens(), token.getParameterTokens(),
token.getExceptionTypes(), token.getExceptionTypes(),
token.getAnnotations(), CompoundList.of(token.getAnnotations(), new ArrayList<AnnotationDescription>(annotations)),
token.getDefaultValue())).new AnnotationAdapter(handler, methodAttributeAppenderFactory, methodTransformer); token.getDefaultValue())).new AnnotationAdapter(handler, methodAttributeAppenderFactory, methodTransformer);
} }


Expand Down
Expand Up @@ -33,9 +33,6 @@ public class ConstructorStrategyDefaultTest {
@Mock @Mock
private MethodRegistry methodRegistry; private MethodRegistry methodRegistry;


@Mock
private MethodAttributeAppender.Factory methodAttributeAppenderFactory;

@Mock @Mock
private InstrumentedType instrumentedType; private InstrumentedType instrumentedType;


Expand Down Expand Up @@ -77,7 +74,7 @@ public void testImitateSuperTypeStrategy() throws Exception {
assertThat(ConstructorStrategy.Default.IMITATE_SUPER_TYPE.inject(methodRegistry), is(methodRegistry)); assertThat(ConstructorStrategy.Default.IMITATE_SUPER_TYPE.inject(methodRegistry), is(methodRegistry));
verify(methodRegistry).append(any(LatentMatcher.class), verify(methodRegistry).append(any(LatentMatcher.class),
any(MethodRegistry.Handler.class), any(MethodRegistry.Handler.class),
eq(methodAttributeAppenderFactory), eq(MethodAttributeAppender.ForInstrumentedMethod.INSTANCE),
eq(MethodTransformer.NoOp.INSTANCE)); eq(MethodTransformer.NoOp.INSTANCE));
verifyNoMoreInteractions(methodRegistry); verifyNoMoreInteractions(methodRegistry);
verify(instrumentedType, atLeastOnce()).getSuperType(); verify(instrumentedType, atLeastOnce()).getSuperType();
Expand All @@ -93,7 +90,7 @@ public void testImitateSuperTypePublicStrategy() throws Exception {
assertThat(ConstructorStrategy.Default.IMITATE_SUPER_TYPE_PUBLIC.inject(methodRegistry), is(methodRegistry)); assertThat(ConstructorStrategy.Default.IMITATE_SUPER_TYPE_PUBLIC.inject(methodRegistry), is(methodRegistry));
verify(methodRegistry).append(any(LatentMatcher.class), verify(methodRegistry).append(any(LatentMatcher.class),
any(MethodRegistry.Handler.class), any(MethodRegistry.Handler.class),
eq(methodAttributeAppenderFactory), eq(MethodAttributeAppender.ForInstrumentedMethod.INSTANCE),
eq(MethodTransformer.NoOp.INSTANCE)); eq(MethodTransformer.NoOp.INSTANCE));
verifyNoMoreInteractions(methodRegistry); verifyNoMoreInteractions(methodRegistry);
verify(instrumentedType, atLeastOnce()).getSuperType(); verify(instrumentedType, atLeastOnce()).getSuperType();
Expand All @@ -110,7 +107,7 @@ public void testDefaultConstructorStrategy() throws Exception {
assertThat(ConstructorStrategy.Default.DEFAULT_CONSTRUCTOR.inject(methodRegistry), is(methodRegistry)); assertThat(ConstructorStrategy.Default.DEFAULT_CONSTRUCTOR.inject(methodRegistry), is(methodRegistry));
verify(methodRegistry).append(any(LatentMatcher.class), verify(methodRegistry).append(any(LatentMatcher.class),
any(MethodRegistry.Handler.class), any(MethodRegistry.Handler.class),
eq(methodAttributeAppenderFactory), eq(MethodAttributeAppender.NoOp.INSTANCE),
eq(MethodTransformer.NoOp.INSTANCE)); eq(MethodTransformer.NoOp.INSTANCE));
verifyNoMoreInteractions(methodRegistry); verifyNoMoreInteractions(methodRegistry);
verify(instrumentedType, atLeastOnce()).getSuperType(); verify(instrumentedType, atLeastOnce()).getSuperType();
Expand Down
Binary file not shown.

0 comments on commit 1843d42

Please sign in to comment.