@Test
public void shouldGetAllPropertiesOnJavaBean() throws Exception {
Status status = Status.INFO;
int code = 121;
I18n msg = CommonI18n.argumentMayNotBeEmpty;
Object[] params = new Object[] {"argName"};
String resource = "The source";
String location = "The place to be";
Throwable throwable = null;
Problem problem = new Problem(status, code, msg, params, resource, location, throwable);
Reflection reflection = new Reflection(Problem.class);
List<Property> props = reflection.getAllPropertiesOn(problem);
Map<String, Property> propsByName = reflection.getAllPropertiesByNameOn(problem);
assertThat(props.size(), is(8));
assertThat(propsByName.size(), is(8));
assertThat(props.containsAll(propsByName.values()), is(true));
Property property = propsByName.remove("status");
assertThat(property.getName(), is("status"));
assertThat(property.getLabel(), is("Status"));
assertThat(property.getType().equals(Status.class), is(true));
assertThat(property.isReadOnly(), is(true));
assertThat(property, is(findProperty(property.getName(), props)));
assertValue(reflection, problem, property, status);
property = propsByName.remove("code");
assertThat(property.getName(), is("code"));
assertThat(property.getLabel(), is("Code"));
assertThat(property.getType().equals(Integer.TYPE), is(true));
assertThat(property.isReadOnly(), is(true));
assertValue(reflection, problem, property, code);
property = propsByName.remove("message");
assertThat(property.getName(), is("message"));
assertThat(property.getLabel(), is("Message"));
assertThat(property.getType().equals(I18n.class), is(true));
assertThat(property.isReadOnly(), is(true));
assertValue(reflection, problem, property, msg);
property = propsByName.remove("messageString");
assertThat(property.getName(), is("messageString"));
assertThat(property.getLabel(), is("Message String"));
assertThat(property.getType().equals(String.class), is(true));
assertThat(property.isReadOnly(), is(true));
assertValue(reflection, problem, property, msg.text(params));
property = propsByName.remove("parameters");
assertThat(property.getName(), is("parameters"));
assertThat(property.getLabel(), is("Parameters"));
assertThat(property.getType().equals(Object[].class), is(true));