public BindableDefinitionAdapter newBindableDefinitionAdapter() { return new BackendBindableDefinitionAdapter(definitionUtils); }
@Override public String getCategory(final T definition) { Class<?> type = definition.getClass(); try { return getFieldValue(definition, propertyCategoryFieldNames.get(type)); } catch (IllegalAccessException e) { LOG.error("Error obtaining category for Definition with id " + getId(definition)); } return null; }
@Before public void setUp() { super.setUp(); tested = new BackendBindableDefinitionAdapter(utils); tested.setBindings(metaPropertyTypeClasses, baseTypes, propertySetsFieldNames, propertiesFieldNames, propertyGraphFactoryFieldNames, propertyIdFieldNames, propertyLabelsFieldNames, propertyTitleFieldNames, propertyCategoryFieldNames, propertyDescriptionFieldNames, propertyNameFields); propertyNameFields.put(instance.getClass(), FooTestBean.FOO_PROPERTY_NAME); propertiesFieldNames.put(instance.getClass(), Stream.of(FooTestBean.FOO_PROPERTY_NAME).collect(Collectors.toSet())); }
@Test public void getNameField() { final Optional nameField = tested.getNameField(instance); assertEquals(nameField.get(), instance.fooProperty); }
@Test public void getPropertyByName() { final Optional property = tested.getProperty(instance, FooTestBean.FOO_PROPERTY_NAME); assertEquals(property.get(), instance.fooProperty); } }
@Override public Set<?> getPropertySets(final T definition) { Class<?> type = definition.getClass(); Set<String> fields = propertySetsFieldNames.get(type); try { return getFieldValues(definition, fields); } catch (IllegalAccessException e) { LOG.error("Error obtaining property sets for Definition with id " + getId(definition)); } return Collections.emptySet(); }
@Override public String getTitle(final T definition) { Class<?> type = definition.getClass(); try { return getFieldValue(definition, propertyTitleFieldNames.get(type)); } catch (IllegalAccessException e) { LOG.error("Error obtaining title for Definition with id " + getId(definition)); } return null; }
@Override public String getDescription(final T definition) { Class<?> type = definition.getClass(); try { return getFieldValue(definition, propertyDescriptionFieldNames.get(type)); } catch (IllegalAccessException e) { LOG.error("Error obtaining description for Definition with id " + getId(definition)); } return null; }
@Override public Set<String> getLabels(final T definition) { Class<?> type = definition.getClass(); try { return getFieldValue(definition, propertyLabelsFieldNames.get(type)); } catch (IllegalAccessException e) { LOG.error("Error obtaining labels for Definition with id " + getId(definition)); } return Collections.emptySet(); }
@Override protected Set<?> getBindProperties(final T definition) { Class<?> type = definition.getClass(); Set<String> fields = propertiesFieldNames.get(type); try { if (null != fields) { return getFieldValues(definition, fields); } } catch (IllegalAccessException e) { LOG.error("Error obtaining properties for Definition with id " + getId(definition)); } return Collections.emptySet(); }