@Override public <T> TransientBuilder<T> newTransientBuilder( Class<T> mixinType ) throws NoSuchTransientTypeException { Objects.requireNonNull( mixinType, "mixinType" ); TransientDescriptor model = typeLookup.lookupTransientModel( mixinType ); if( model == null ) { throw new NoSuchTransientTypeException( mixinType.getName(), descriptor() ); } Map<AccessibleObject, Property<?>> properties = new HashMap<>(); model.state().properties().forEach( propertyModel -> { Object initialValue = propertyModel.resolveInitialValue( model.module() ); Property<?> property = new PropertyInstance<>( ( (PropertyModel) propertyModel ).getBuilderInfo(), initialValue ); properties.put( propertyModel.accessor(), property ); } ); TransientStateInstance state = new TransientStateInstance( properties ); return new TransientBuilderInstance<>( model, state, UsesInstance.EMPTY_USES ); }
@Test public void givenNoVisibilityWhenCreatingTransientExpectClearException() { try { CheckBookSlip slip = transientBuilderFactory.newTransient( CheckBookSlip.class ); fail( NoSuchTransientTypeException.class.getSimpleName() + " should have been thrown." ); } catch( NoSuchTransientTypeException e ) { String expectedString = "\tInvisible TransientComposite types are:" + System.getProperty( "line.separator" ) + "\t\t[ org.apache.polygene.test.entity.model.monetary.CheckBookSlip] in [Monetary Module] with visibility module"; assertThat( e.getMessage(), containsString( expectedString ) ); } }