### Question:
DefaultValuesInstanceProvider implements RandomGen.InstanceProvider<GENERATED_INSTANCE> { @Override public GENERATED_INSTANCE provideInstance() { try { return getInstanceFromAnyConstructor(); } catch (Exception exception) { throw new InstanceCreationException( "Failed to instantiate " + mClass.getSimpleName() + ". Try providing a ValuesInstanceProvider.", exception); } } DefaultValuesInstanceProvider(Class<GENERATED_INSTANCE> pClass); @Override GENERATED_INSTANCE provideInstance();  }### Answer:
@Test public void givenConstructorWithParametersWhenProvideInstanceThenReturnsInstanceWithDefaultValues() { mCut = new DefaultValuesInstanceProvider<>(TestClassWithFields.class); TestClassWithFields result = (TestClassWithFields) mCut.provideInstance(); assertEquals(0, result.getByteField()); assertEquals(0, result.getShortField()); assertEquals(0, result.getIntField()); assertEquals(0, result.getLongField()); assertEquals(0, result.getFloatField(), 0f); assertEquals(0, result.getDoubleField(), 0d); assertFalse(result.isBooleanField()); assertNull(result.getStringField()); assertNull(result.getObject()); assertNull(result.getObjects()); }
@Test public void givenNoDefinedConstructorWhenProvideInstanceThenReturnsInstance() { mCut = new DefaultValuesInstanceProvider<>(TestClassWithNoConstructor.class); TestClassWithNoConstructor result = (TestClassWithNoConstructor) mCut.provideInstance(); assertNotNull(result); }
@Test public void givenPublicConstructorWithNoParametersWhenProvideInstanceThenUsesConstructor() { mCut = new DefaultValuesInstanceProvider<>(TestClassWithNoFields.class); TestClassWithNoFields result = (TestClassWithNoFields) mCut.provideInstance(); assertTrue(result.isSet()); }