Search in sources :

Example 86 with BeanWrapperImpl

use of org.springframework.beans.BeanWrapperImpl in project walkmod-core by walkmod.

the class ConfigurationImpl method populate.

public void populate(Object element, Map<?, ?> parameters) {
    if (element != null) {
        BeanWrapper bw = new BeanWrapperImpl(element);
        if (this.parameters != null) {
            bw.setPropertyValues(this.parameters);
        }
        bw.setPropertyValues(parameters);
    }
}
Also used : BeanWrapper(org.springframework.beans.BeanWrapper) BeanWrapperImpl(org.springframework.beans.BeanWrapperImpl)

Example 87 with BeanWrapperImpl

use of org.springframework.beans.BeanWrapperImpl in project syncope by apache.

the class KeyPropertyColumn method populateItem.

@Override
public void populateItem(final Item<ICellPopulator<T>> item, final String componentId, final IModel<T> rowModel) {
    BeanWrapper bwi = new BeanWrapperImpl(rowModel.getObject());
    Object obj = bwi.getPropertyValue(getPropertyExpression());
    item.add(new Label(componentId, StringUtils.EMPTY));
    item.add(new AttributeModifier("title", obj.toString()));
    item.add(new AttributeModifier("class", "fa fa-key"));
    item.add(new AttributeModifier("style", "display: table-cell; text-align: center;"));
}
Also used : BeanWrapper(org.springframework.beans.BeanWrapper) BeanWrapperImpl(org.springframework.beans.BeanWrapperImpl) Label(org.apache.wicket.markup.html.basic.Label) AttributeModifier(org.apache.wicket.AttributeModifier)

Example 88 with BeanWrapperImpl

use of org.springframework.beans.BeanWrapperImpl in project alien4cloud by alien4cloud.

the class EqualsAndHashCodeAutoTest method doTest.

private void doTest(Class<?> clazz, Object[][] allFieldValues, Object[][] testFieldValues, String[] fieldNames, int start, int end, int index) throws IllegalAccessException, InstantiationException {
    if (index == fieldNames.length) {
        Object instance = clazz.newInstance();
        Object equalInstance = clazz.newInstance();
        Object otherInstance = clazz.newInstance();
        BeanWrapper instanceWrapper = new BeanWrapperImpl(instance);
        BeanWrapper equalInstanceWrapper = new BeanWrapperImpl(equalInstance);
        BeanWrapper otherInstanceWrapper = new BeanWrapperImpl(otherInstance);
        // set field values
        for (int i = 0; i < fieldNames.length; i++) {
            String fieldName = fieldNames[i];
            if (clazz.equals(PropertyDefinition.class) && fieldNames[i].equals("defaultValue")) {
                fieldName = "default";
            }
            instanceWrapper.setPropertyValue(fieldName, testFieldValues[i][0]);
            equalInstanceWrapper.setPropertyValue(fieldName, testFieldValues[i][0]);
            otherInstanceWrapper.setPropertyValue(fieldName, testFieldValues[i][1]);
        }
        // Two instances that are the same must have the same hashcode (but two different instance may have the same hashcode).
        Assert.assertEquals(instance.hashCode(), equalInstance.hashCode());
        Assert.assertTrue(instance.equals(equalInstance));
    } else {
        // recursive prepare a set of field values to test so we test all combinations
        for (int i = start; i < end && end - i + 1 >= fieldNames.length - index; i++) {
            testFieldValues[index] = allFieldValues[i];
            doTest(clazz, allFieldValues, testFieldValues, fieldNames, i + 1, end, index + 1);
        }
    }
}
Also used : BeanWrapper(org.springframework.beans.BeanWrapper) BeanWrapperImpl(org.springframework.beans.BeanWrapperImpl) PropertyDefinition(org.alien4cloud.tosca.model.definitions.PropertyDefinition) GreaterThanConstraint(org.alien4cloud.tosca.model.definitions.constraints.GreaterThanConstraint) LengthConstraint(org.alien4cloud.tosca.model.definitions.constraints.LengthConstraint) LessOrEqualConstraint(org.alien4cloud.tosca.model.definitions.constraints.LessOrEqualConstraint) EqualConstraint(org.alien4cloud.tosca.model.definitions.constraints.EqualConstraint) LessThanConstraint(org.alien4cloud.tosca.model.definitions.constraints.LessThanConstraint) MaxLengthConstraint(org.alien4cloud.tosca.model.definitions.constraints.MaxLengthConstraint) ValidValuesConstraint(org.alien4cloud.tosca.model.definitions.constraints.ValidValuesConstraint) InRangeConstraint(org.alien4cloud.tosca.model.definitions.constraints.InRangeConstraint) PatternConstraint(org.alien4cloud.tosca.model.definitions.constraints.PatternConstraint) MinLengthConstraint(org.alien4cloud.tosca.model.definitions.constraints.MinLengthConstraint) GreaterOrEqualConstraint(org.alien4cloud.tosca.model.definitions.constraints.GreaterOrEqualConstraint)

Example 89 with BeanWrapperImpl

use of org.springframework.beans.BeanWrapperImpl in project alien4cloud by alien4cloud.

the class RestStepsDefinitions method register.

@And("^I register \"(.*?)\" as \"(.*?)\"$")
public void register(String propertyPath, String key) throws Throwable {
    RestResponse restResponse = JsonUtil.read(Context.getInstance().getRestResponse());
    Object value = restResponse;
    if (!"null".equals(propertyPath)) {
        BeanWrapper beanWrapper = new BeanWrapperImpl(restResponse);
        value = beanWrapper.getPropertyValue(propertyPath);
    }
    REGISTRY.put(key, value);
}
Also used : BeanWrapper(org.springframework.beans.BeanWrapper) BeanWrapperImpl(org.springframework.beans.BeanWrapperImpl) RestResponse(alien4cloud.rest.model.RestResponse) And(cucumber.api.java.en.And)

Example 90 with BeanWrapperImpl

use of org.springframework.beans.BeanWrapperImpl in project alien4cloud by alien4cloud.

the class CollectionParser method objectFromTuple.

private T objectFromTuple(NodeTuple tuple, ParsingContextExecution context) {
    String key = ParserUtils.getScalar(tuple.getKeyNode(), context);
    T value;
    value = valueParser.parse(tuple.getValueNode(), context);
    if (value != null) {
        BeanWrapper valueWrapper = new BeanWrapperImpl(value);
        valueWrapper.setPropertyValue(keyPath, key);
    }
    return value;
}
Also used : BeanWrapper(org.springframework.beans.BeanWrapper) BeanWrapperImpl(org.springframework.beans.BeanWrapperImpl)

Aggregations

BeanWrapperImpl (org.springframework.beans.BeanWrapperImpl)113 BeanWrapper (org.springframework.beans.BeanWrapper)75 Test (org.junit.jupiter.api.Test)32 NumberTestBean (org.springframework.beans.testfixture.beans.NumberTestBean)21 BooleanTestBean (org.springframework.beans.testfixture.beans.BooleanTestBean)20 Test (org.junit.Test)19 ITestBean (org.springframework.beans.testfixture.beans.ITestBean)17 IndexedTestBean (org.springframework.beans.testfixture.beans.IndexedTestBean)17 TestBean (org.springframework.beans.testfixture.beans.TestBean)17 PropertyDescriptor (java.beans.PropertyDescriptor)14 PropertyEditorSupport (java.beans.PropertyEditorSupport)14 Assertions.assertThatIllegalArgumentException (org.assertj.core.api.Assertions.assertThatIllegalArgumentException)14 MutablePropertyValues (org.springframework.beans.MutablePropertyValues)12 HashSet (java.util.HashSet)11 BeansException (org.springframework.beans.BeansException)9 ArrayList (java.util.ArrayList)5 Map (java.util.Map)5 BeanCreationException (org.springframework.beans.factory.BeanCreationException)5 ConstructorArgumentValues (org.springframework.beans.factory.config.ConstructorArgumentValues)5 IOException (java.io.IOException)4