@Test public void shouldUseAnnotationsOnClassFieldsForProperties() throws Exception { SomeStructure structure = new SomeStructure(); structure.setCount(33); structure.setIdentifier("This is the identifier value"); Reflection reflection = new Reflection(SomeStructure.class); List<Property> props = reflection.getAllPropertiesOn(structure); Map<String, Property> propsByName = reflection.getAllPropertiesByNameOn(structure); assertThat(props.size(), is(3)); assertThat(propsByName.size(), is(3)); Property property = propsByName.remove("identifier"); assertThat(property.getName(), is("identifier")); assertThat(property.getLabel(), is(CommonI18n.noMoreContent.text())); assertThat(property.getDescription(), is(CommonI18n.nullActivityMonitorTaskName.text())); assertThat(property.getCategory(), is(CommonI18n.noMoreContent.text())); assertThat(property.getType().equals(String.class), is(true)); assertThat(property.isReadOnly(), is(false)); assertThat(property, is(findProperty(property.getName(), props))); assertValue(reflection, structure, property, structure.getIdentifier()); property = propsByName.remove("count"); assertThat(property.getName(), is("count")); assertThat(property.getLabel(), is("Count")); assertThat(property.getDescription(), is("This is the count")); assertThat(property.getCategory(), is("")); assertThat(property.getType().equals(Integer.TYPE), is(true)); assertThat(property.isReadOnly(), is(false)); assertValue(reflection, structure, property, structure.getCount()); property = propsByName.remove("onFire"); assertThat(property.getName(), is("onFire")); assertThat(property.getLabel(), is("On Fire")); assertThat(property.getDescription(), is("")); assertThat(property.getCategory(), is("")); assertThat(property.getType().equals(Boolean.TYPE), is(true)); assertThat(property.isReadOnly(), is(true)); assertValue(reflection, structure, property, structure.isOnFire()); }
public ManagedProperty(Property property, String currentValue) { this.setName(property.getName()); this.setLabel(property.getLabel()); this.setDescription(property.getDescription()); this.value = currentValue; }