### Question:
InputControlResourceValidator extends GenericResourceValidator<InputControl> { @PostConstruct public void initialize() { try { PropertyDescriptor[] availableProperties = Introspector.getBeanInfo(InputControl.class).getPropertyDescriptors(); for (PropertyDescriptor descriptor : availableProperties) { if (Object.class.isAssignableFrom(descriptor.getPropertyType()) && descriptor.getReadMethod() != null && descriptor.getWriteMethod() != null) { properties.put(descriptor.getName(), descriptor); } } for (String key : inputControlTypeConfiguration.keySet()) { String required = (String) inputControlTypeConfiguration.get(key).get(PROPERTY_REQUIRED); if (required != null) { for (String definedName : required.split(PROPERTY_REQUIRED_SEPARATOR)) { if (!properties.containsKey(definedName)) { StringBuilder message = new StringBuilder("The input control type ").append(key) .append(" contains unknown property '").append(definedName).append("'\n") .append("Valid values:\n"); for (String name : properties.keySet()) { message.append("'").append(name).append("',\n"); } throw new IllegalStateException(message.toString()); } } } } } catch (IntrospectionException e) { throw new IllegalStateException("Introspection error", e); } }  @PostConstruct void initialize(); static final String PROPERTY_REQUIRED; static final String PROPERTY_REQUIRED_SEPARATOR; }### Answer:
@Test(groups = {"INIT"}) public void testInit() throws Exception { validator.initialize(); }
@Test(groups = {"INIT"}) public void testInit_requiredPropertyNotMandatory() throws Exception { when(inputControlTypeConfiguration.keySet()).thenReturn(new HashSet<String>()); validator.initialize(); }
@Test(groups = {"INIT"}) public void testInit_propertySet() throws Exception { when(inputControlTypeConfiguration.keySet()).thenReturn(new HashSet<String>(Arrays.asList("1"))); when(configuration.get(InputControlResourceValidator.PROPERTY_REQUIRED)).thenReturn("dataType"); validator.initialize(); }
@Test(groups = {"INIT"}) public void testInit_propertiesSet() throws Exception { when(inputControlTypeConfiguration.keySet()).thenReturn(new HashSet<String>(Arrays.asList("1"))); when(configuration.get(InputControlResourceValidator.PROPERTY_REQUIRED)).thenReturn("dataType;listOfValues"); validator.initialize(); }
@Test(groups = {"INIT"}, expectedExceptions = {IllegalStateException.class}) public void testInit_propertySet_unknown() throws Exception { when(inputControlTypeConfiguration.keySet()).thenReturn(new HashSet<String>(Arrays.asList("1"))); when(configuration.get(InputControlResourceValidator.PROPERTY_REQUIRED)).thenReturn("wakka"); validator.initialize(); }
@Test(groups = {"INIT"}, expectedExceptions = {IllegalStateException.class}) public void testInit_propertiesSet_unknown() throws Exception { when(inputControlTypeConfiguration.keySet()).thenReturn(new HashSet<String>(Arrays.asList("1"))); when(configuration.get(InputControlResourceValidator.PROPERTY_REQUIRED)).thenReturn("wakka;pinux"); validator.initialize(); }
@Test(groups = {"INIT"}, expectedExceptions = {IllegalStateException.class}) public void testInit_propertiesSet_one_unknown() throws Exception { when(inputControlTypeConfiguration.keySet()).thenReturn(new HashSet<String>(Arrays.asList("1"))); when(configuration.get(InputControlResourceValidator.PROPERTY_REQUIRED)).thenReturn("dataType;listOfValues;pinux"); validator.initialize(); }