Skip to content
Permalink
Browse files
format
  • Loading branch information
mbenson committed Jan 2, 2014
1 parent 7a9348e commit a2190ff2182e6bae35cfabe21aa83f8fc9ad2505
Showing 1 changed file with 24 additions and 21 deletions.
@@ -46,16 +46,17 @@ public void testDefaultAnnotation()
@Test
public void testStubbedAnnotation()
{
final CustomAnnotation customAnnotation =
AnnotationBuilder.of(CustomAnnotation.class).train(new AnnotationTrainer<CustomAnnotation>()
{
@Override
protected void train(CustomAnnotation trainee)
final CustomAnnotation customAnnotation = AnnotationBuilder.of(CustomAnnotation.class)
.train(new AnnotationTrainer<CustomAnnotation>()
{
when(trainee.someType()).thenReturn(Object.class).when(trainee.finiteValues())
.thenReturn(FiniteValues.ONE, FiniteValues.THREE).when(trainee.annString()).thenReturn("hey");
}
}).build();
@Override
protected void train(CustomAnnotation trainee)
{
when(trainee.someType()).thenReturn(Object.class).when(trainee.finiteValues())
.thenReturn(FiniteValues.ONE, FiniteValues.THREE).when(trainee.annString())
.thenReturn("hey");
}
}).build();

assertEquals(CustomAnnotation.class, customAnnotation.annotationType());
assertEquals("hey", customAnnotation.annString());
@@ -66,16 +67,16 @@ protected void train(CustomAnnotation trainee)
@Test
public void testNestedStubbedAnnotation()
{
final NestingAnnotation nestingAnnotation =
AnnotationBuilder.of(NestingAnnotation.class).train(new AnnotationTrainer<NestingAnnotation>()
{
@Override
protected void train(NestingAnnotation trainee)
final NestingAnnotation nestingAnnotation = AnnotationBuilder.of(NestingAnnotation.class)
.train(new AnnotationTrainer<NestingAnnotation>()
{
when(trainee.child()).thenStub(CustomAnnotation.class).when(trainee.somethingElse())
.thenReturn("somethingElse");
}
}).build();
@Override
protected void train(NestingAnnotation trainee)
{
when(trainee.child()).thenStub(CustomAnnotation.class).when(trainee.somethingElse())
.thenReturn("somethingElse");
}
}).build();

assertEquals("", nestingAnnotation.child().annString());
assertEquals(0, nestingAnnotation.child().finiteValues().length);
@@ -91,8 +92,9 @@ public void testMemberMap()
members.put("finiteValues", FiniteValues.values());
members.put("someType", Object.class);

final CustomAnnotation customAnnotation = AnnotationBuilder.of(CustomAnnotation.class).withMembers(members).build();

final CustomAnnotation customAnnotation = AnnotationBuilder.of(CustomAnnotation.class).withMembers(members)
.build();

assertNotNull(customAnnotation);
assertEquals(CustomAnnotation.class, customAnnotation.annotationType());
assertEquals("foo", customAnnotation.annString());
@@ -103,7 +105,8 @@ public void testMemberMap()
@Test(expected = IllegalArgumentException.class)
public void testBadMemberMap()
{
AnnotationBuilder.of(CustomAnnotation.class).withMembers(Collections.singletonMap("annString", Integer.valueOf(100)));
AnnotationBuilder.of(CustomAnnotation.class).withMembers(
Collections.singletonMap("annString", Integer.valueOf(100)));
}

public @interface NestingAnnotation

0 comments on commit a2190ff

Please sign in to comment.