### Question:
BurstableConstructor { public static TestConstructor findSingle(Class<?> cls) { final TestConstructor[] constructors = findAll(cls); if (constructors.length == 0) { throw new IllegalStateException(cls.getName() + " requires at least 1 public constructor"); } else if (constructors.length == 1) { return constructors[0]; } else { throw new IllegalStateException("Class " + cls.getName() + " has too many parameterized constructors. " + "Should only be 1 (with enum variations)."); } } private  BurstableConstructor(); static TestConstructor findSingle(Class<?> cls);  }### Answer:
@Test public void noConstructor() { TestConstructor ctor = BurstableConstructor.findSingle(None.class); assertThat(ctor.getVariationTypes()).isEmpty(); }
@Test public void emptyConstructorMultipleFields() { TestConstructor ctor = BurstableConstructor.findSingle(MultipleFields.class); assertThat(ctor.getVariationTypes()).containsOnly(First.class, Second.class); }
@Test public void singleParameterizedConstructorWithField() { thrown.expectMessage( "has a parameterized constructor, so cannot also be parameterized on fields"); BurstableConstructor.findSingle(OneWithField.class); }
@Test public void privateAnnotatedField() { TestConstructor ctor = BurstableConstructor.findSingle(PrivateField.class); assertThat(ctor.getVariationTypes()).containsExactly(First.class); }
@Test public void inheritedField() { TestConstructor ctor = BurstableConstructor.findSingle(InheritedField.class); assertThat(ctor.getVariationTypes()).containsOnly(First.class, Second.class); }
@Test public void StaticField() { thrown.expect(IllegalStateException.class); thrown.expectMessage("Burstable field must not be static"); BurstableConstructor.findSingle(StaticField.class); }
@Test public void finalField() { thrown.expect(IllegalStateException.class); thrown.expectMessage("Burstable field must not be final"); BurstableConstructor.findSingle(FinalField.class); }
@Test public void notAnEnumField() { TestConstructor ctor = BurstableConstructor.findSingle(NotAnEnumField.class); assertThat(ctor.getVariationTypes()).containsExactly(Object.class); }
@Test public void unannotatedField() { TestConstructor ctor = BurstableConstructor.findSingle(UnannotatedField.class); assertThat(ctor.getVariationTypes()).containsExactly(Second.class); }
@Test public void defaultConstructor() { TestConstructor ctor = BurstableConstructor.findSingle(Default.class); assertThat(ctor.getVariationTypes()).isEmpty(); }
@Test public void singleParameterizedConstructor() { TestConstructor ctor = BurstableConstructor.findSingle(One.class); assertThat(ctor.getVariationTypes()).containsExactly(First.class); }
@Test public void defaultAndParameterizedConstructor() { thrown.expect(IllegalStateException.class); thrown.expectMessage("too many parameterized constructors"); BurstableConstructor.findSingle(DefaultAndOne.class); }
@Test public void nonPublic() { thrown.expect(IllegalStateException.class); thrown.expectMessage("requires at least 1 public constructor"); BurstableConstructor.findSingle(NonPublicConstructor.class); }
@Test public void tooMany() { thrown.expect(IllegalStateException.class); thrown.expectMessage( "has too many parameterized constructors. Should only be 1 (with enum variations)."); BurstableConstructor.findSingle(TooMany.class); }
@Test public void nonEnumInConstructor() { TestConstructor ctor = BurstableConstructor.findSingle(NonEnumInConstructor.class); assertThat(ctor.getVariationTypes()).containsExactly(Object.class); }
@Test public void notAnEnumInConstructor() { TestConstructor ctor = BurstableConstructor.findSingle(NotAnEnumInConstructor.class); assertThat(ctor.getVariationTypes()).containsExactly(Object.class); }
@Test public void defaultConstructorWithField() { TestConstructor ctor = BurstableConstructor.findSingle(DefaultWithField.class); assertThat(ctor.getVariationTypes()).containsExactly(First.class); }
@Test public void singleEmptyConstructorWithField() { TestConstructor ctor = BurstableConstructor.findSingle(NoneWithField.class); assertThat(ctor.getVariationTypes()).containsExactly(First.class); }