001/* 002 * Copyright 2023 the original author or authors. 003 * <p> 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * <p> 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * <p> 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package de.cuioss.test.valueobjects.objects; 017 018import java.util.List; 019 020import de.cuioss.test.valueobjects.property.PropertyMetadata; 021import de.cuioss.test.valueobjects.property.PropertySupport; 022 023/** 024 * Abstraction of certain ways for creating and populating test-objects . 025 * 026 * @author Oliver Wolff 027 * @param <T> identifying the type of object to be instantiated 028 */ 029public interface ParameterizedInstantiator<T> { 030 031 /** 032 * Creates a new Object according to the given parameter, represented as 033 * {@link List} of {@link PropertySupport} 034 * 035 * @param properties to be applied to the newly created object. 036 * @param generatePropertyValues indicating whether this method should 037 * implicitly call 038 * {@link PropertySupport#generateTestValue()} or 039 * not. In case being <code>false</code> the 040 * caller must ensure this. 041 * @return a newly created object with the given properties being applied. 042 * @throws AssertionError in case the object could not be created or the 043 * properties could not been applied. 044 */ 045 T newInstance(List<PropertySupport> properties, boolean generatePropertyValues); 046 047 /** 048 * Similar to {@link #newInstance(List, boolean)} but with the difference that 049 * the caller has no control regarding the set / applied properties, that may be 050 * need for some asserts. It is some kind of any() 051 * 052 * @param properties to be applied to the newly created object. 053 * @return a newly created object with the given properties being applied. 054 * @throws AssertionError in case the object could not be created or the 055 * properties could not been applied. 056 */ 057 T newInstance(List<PropertyMetadata> properties); 058 059 /** 060 * @return the runtime information associated with this 061 * {@link ParameterizedInstantiator} 062 */ 063 RuntimeProperties getRuntimeProperties(); 064 065 /** 066 * @return a new instance of the object with only required attributes set. 067 */ 068 T newInstanceMinimal(); 069 070 /** 071 * @return a new instance of the object with all attributes set. 072 */ 073 T newInstanceFull(); 074}