@Test public void givenCompositeConstraintWhenInvokedThenUseAllConstraints() { MyOne myOne = transientBuilderFactory.newTransient( MyOneComposite.class ); ArrayList<String> list = new ArrayList<String>(); list.add( "Foo" ); myOne.doSomething3( list ); }
public View2 createView2( FooModel model ) { TransientBuilder<View2> builder = transientBuilderFactory.newTransientBuilder( View2.class ); builder.use( model ); return builder.newInstance(); } }
@Test public void testWithHandlerSelfEquals2() { ObjectMethods withHandler = transientBuilderFactory.newTransient( ObjectMethods.class ); assertTrue( withHandler.equals( withHandler ) ); }
private Location createLocation( String locationName ) { TransientBuilder<Location> locationBuilder = transientBuilderFactory.newTransientBuilder( Location.class ); Location locState = locationBuilder.prototypeFor( Location.class ); locState.name().set( locationName ); return locationBuilder.newInstance(); }
@Test public void givenNonInstrumentedCompositeExpectNoTimers() { Country underTest = transientBuilderFactory.newTransient( Country1.class ); updateName( underTest, 10 ); assertThat( metricValuesProvider().timerCount( "Layer 1.Module 1.AbstractTimingCaptureTest.Country.name" ), is( 0L ) ); assertThat( metricValuesProvider().timerCount( "Layer 1.Module 1.AbstractTimingCaptureTest.Country.updateName" ), is( 0L ) ); }
public CostPerUnit toCostPer( Unit<?> unit ) { TransientBuilder<CostPerUnitComposite> builder = builderFactory.newTransientBuilder( CostPerUnitComposite.class ); builder.prototype().unit().set( unit ); return builder.newInstance(); } }
@Test public void givenInstrumentedWithAllCompositeWhenCallingUpdateNameExpectTimers() { Country underTest = transientBuilderFactory.newTransient( Country2.class ); updateName( underTest, 10 ); assertThat( metricValuesProvider().timerCount( "Layer 1.Module 1.AbstractTimingCaptureTest.Country.name" ), is( 10L ) ); assertThat( metricValuesProvider().timerCount( "Layer 1.Module 1.AbstractTimingCaptureTest.Country.updateName" ), is( 10L ) ); }
@Test( expected = ConstraintViolationException.class ) public void testURLFail() { TransientBuilder<TestCaseComposite> cb = transientBuilderFactory.newTransientBuilder( TestCaseComposite.class ); cb.prototype().url().set( "this is no url" ); }
@Test public void givenNonInstrumentedCompositeExpectNoTimers() { Country underTest = transientBuilderFactory.newTransient( Country1.class ); updateName( underTest, 10 ); assertThat( metricValuesProvider().timerCount( "Layer 1.Module 1.AbstractTimingCaptureTest.Country.name" ), is( 0L ) ); assertThat( metricValuesProvider().timerCount( "Layer 1.Module 1.AbstractTimingCaptureTest.Country.updateName" ), is( 0L ) ); }
@Test( expected = ConstraintViolationException.class ) public void testURIFail() { TransientBuilder<TestCaseComposite> cb = transientBuilderFactory.newTransientBuilder( TestCaseComposite.class ); cb.prototype().uri().set( "" ); }
@Test( expected = TestException.class ) public void invokeDeclaredPublicMethodWhichInvokesCustomExceptionThrowingMethod() throws Throwable { this.transientBuilderFactory .newTransient( TestTransient.class ) .invokeDeclaredPublicMethodThatThrowsCustomException(); }
@Test( expected = ConstraintViolationException.class ) public void testNotEmpty() { TransientBuilder<Sample> cb = transientBuilderFactory.newTransientBuilder( Sample.class ); cb.prototypeFor( Sample.class ).stuff().set( null ); } }
@Test( expected = IllegalArgumentException.class ) public void invokeBuiltinInheritedExceptionThrowingMethod() throws Throwable { this.transientBuilderFactory .newTransient( TestTransient.class ) .declaredMethodThatThrowsBuiltinInheritedException(); }
@Test public void testURIOk() { TransientBuilder<TestCaseComposite> cb = transientBuilderFactory.newTransientBuilder( TestCaseComposite.class ); cb.prototype().uri().set( "http://polygene.apache.org/path?query=string#fragment" ); }
/** * Tests that private mixins are injected correctly. */ @Test public void privateMixinFieldAndConstructorInjection() { SpeakComposite test = transientBuilderFactory.newTransient( SpeakComposite.class ); assertThat( "Speak", test.speak(), is( equalTo( "I say it works!" ) ) ); }
@Test( expected = ConstraintViolationException.class ) public void testGreaterThanFail() { TransientBuilder<TestCaseComposite> cb = transientBuilderFactory.newTransientBuilder( TestCaseComposite.class ); cb.prototype().greaterThan().set( 10 ); }
@Test public void testWithMixinHashCode() { ObjectMethods withMixin = transientBuilderFactory.newTransient( ObjectMethods.class ); checkHashCode( withMixin ); }
@Test( expected = ConstraintViolationException.class ) public void testMatchesFail() { TransientBuilder<TestCaseComposite> cb = transientBuilderFactory.newTransientBuilder( TestCaseComposite.class ); cb.prototype().matches().set( "cba" ); }
@Test public void testWithMixinSelfSame() { ObjectMethods withMixin = transientBuilderFactory.newTransient( ObjectMethods.class ); assertSame( withMixin, withMixin ); }
@Test public void testMaxLengthOk() { TransientBuilder<TestCaseComposite> cb = transientBuilderFactory.newTransientBuilder( TestCaseComposite.class ); cb.prototype().maxLength().set( "xxx" ); }