@Test public void givenCompositeConstraintWhenInvokedThenUseAllConstraints() { MyOne myOne = transientBuilderFactory.newTransient( MyOneComposite.class ); ArrayList<String> list = new ArrayList<String>(); list.add( "Foo" ); myOne.doSomething3( list ); }
@Test public void testWithHandlerSelfEquals2() { ObjectMethods withHandler = transientBuilderFactory.newTransient( ObjectMethods.class ); assertTrue( withHandler.equals( withHandler ) ); }
@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 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 = TestException.class ) public void invokeDeclaredPublicMethodWhichInvokesCustomExceptionThrowingMethod() throws Throwable { this.transientBuilderFactory .newTransient( TestTransient.class ) .invokeDeclaredPublicMethodThatThrowsCustomException(); }
@Test( expected = IllegalArgumentException.class ) public void invokeBuiltinInheritedExceptionThrowingMethod() throws Throwable { this.transientBuilderFactory .newTransient( TestTransient.class ) .declaredMethodThatThrowsBuiltinInheritedException(); }
@Test( expected = IllegalArgumentException.class ) public void constraintOnMethodParameter() throws SecurityException, NoSuchMethodException { TestComposite test = transientBuilderFactory.newTransient( TestComposite.class ); test.someMethod( null ); }
@Test public void testModuleConcerns() { transientBuilderFactory.newTransient( Foo.class ).test( "Foo", 42 ); assertThat( "Concern has executed", ok, equalTo( true ) ); }
@Test public void testAssemblyTypesDefaultMixin() { FooComposite composite = transientBuilderFactory.newTransient( FooComposite.class ); assertThat( "Default mixin has executed", ( (Foo) composite ).test( "Foo", 42 ), equalTo( "Foo 42" ) ); }
@Test( expected = ConstraintViolationException.class ) public void givenInvalidHostNameWhenSettingPropertyExpectConstrainViolation() throws Exception { SomeValue someValue = transientBuilderFactory.newTransient( SomeValue.class ); someValue.hostPort().set( "1:2:3_i:1234" ); }
@Test public void givenValidListHostPortWhenSettingPropertyExpectSuccess() throws Exception { SomeValue someValue = transientBuilderFactory.newTransient( SomeValue.class ); someValue.hostPort().set( "habba.zout.com:1234,12.34.56.78:1234" ); }
@Test public void givenAnAppliesToWhenAnnotationIsOnMixinTypeExpectConcernInInvocationStack() throws Exception { Some some = transientBuilderFactory.newTransient( Some.class ); Assert.assertEquals( ",,..", some.doStuff2() ); }
@Test public void givenLocalHostWithSmallPortWhenSettingPropertyExpectSuccess() throws Exception { SomeValue someValue = transientBuilderFactory.newTransient( SomeValue.class ); someValue.hostPort().set( "localhost:9" ); }
@Test( expected = ConstraintViolationException.class ) public void givenInvalidListHostNameWhenSettingPropertyExpectConstrainViolation() throws Exception { SomeValue someValue = transientBuilderFactory.newTransient( SomeValue.class ); someValue.hostPort().set( "1.2.3.4:12,1:2:3_i:1234" ); }
@Test( expected = ConstraintViolationException.class ) public void givenInvalidPortNumberWhenSettingPropertyExpectConstrainViolation() throws Exception { SomeValue someValue = transientBuilderFactory.newTransient( SomeValue.class ); someValue.hostPort().set( "1.2.3.4:123456" ); }
@Test public void defaultMethodsGenericSideEffects() { DefaultMethodsGenericSideEffects composite = transientBuilderFactory.newTransient( DefaultMethodsGenericSideEffects.class ); assertThat( composite.sayHello( "John" ), equalTo( "Hello, John!" ) ); assertThat( composite.sayHello( "John" ), equalTo( "Hello, John!" ) ); assertThat( composite.sayHello( "John" ), equalTo( "Hello, John!" ) ); assertThat( DefaultMethodsGenericSideEffect.count, equalTo( 3 ) ); } }
@Test public void givenCompositeToUsesWhenInstantiatingExpectException() { Hello hello = transientBuilderFactory.newTransient( Hello.class ); hello.name().set( "World" ); Speaker speaker = objectFactory.newObject( Speaker.class, hello ); assertThat( speaker.speak(), equalTo( "Hello, World!" ) ); }
@Test public void givenTransientWithRuntimeMixinsWhenAssembledExpectCorrectComposition() throws ActivationException { SingletonAssembler singletonAssembler = new SingletonAssembler( module -> module.transients( SayWhat.class ).withMixins( SayThisMixin.class, SayThatMixin.class ) ); SayWhat value = singletonAssembler.transientBuilderFactory().newTransient( SayWhat.class ); assertThat( value.sayThis(), equalTo( "this" ) ); assertThat( value.sayThat(), equalTo( "that" ) ); }
@Test public void givenAnAppliesToWhenAnnotationIsOnMixinImplementationExpectConcernInInvocationStack() throws Exception { Some some = transientBuilderFactory.newTransient( Some.class ); Assert.assertEquals( ",", some.doStuff1() ); Assert.assertEquals( ",,..", some.doStuff2() ); Assert.assertEquals( ",,,", some.doStuff3() ); }
@Test public void givenTransientWithRuntimeMixinOverrideWhenAssembledExpectCorrectComposition() throws ActivationException { SingletonAssembler singletonAssembler = new SingletonAssembler( module -> module.transients( SayWhere.class ).withMixins( SayHereMixin.class ) ); SayWhere value = singletonAssembler.transientBuilderFactory().newTransient( SayWhere.class ); assertThat( value.sayHere(), equalTo( "here" ) ); assertThat( value.sayThere(), nullValue() ); }