### Question:
KaptchaPlugin extends StatefullPlugin implements RegistrationPlugin, ExtendedPlugin { @Override protected Map<PluginProperty, String> applyConfiguration(List<PluginProperty> properties) throws PluginConfigurationException { int width = 0; int height = 0; int length = 0; String possibleSymbols = ""; for (PluginProperty property : properties) { try { switch (property.getName()) { case WIDTH_PROPERTY: width = Integer.valueOf(property.getValue()); break; case HEIGHT_PROPERTY: height = Integer.valueOf(property.getValue()); break; case LENGTH_PROPERTY: length = Integer.valueOf(property.getValue()); break; case POSSIBLE_SYMBOLS_PROPERTY: possibleSymbols = property.getValue(); break; } } catch (NumberFormatException ex) { LOGGER.error(property.getValue() + " is not valid value for property " + property.getName(), ex); } } if (width < 1 || height < 1 || length < 1 || possibleSymbols.length() < 1) { throw new PluginConfigurationException( "Can't apply configuration: Width, height, length and possible symbols properties should not be empty."); } service = new KaptchaPluginService(width, height, length, possibleSymbols); pluginProperties = properties; return new HashMap<>(); }  @Override boolean supportsJCommuneVersion(String version); @Override String getName(); @Override List<PluginProperty> getConfiguration(); @Override List<PluginProperty> getDefaultConfiguration(); @Override String translateLabel(String code, Locale locale); @Override Map<String, String> registerUser(UserDto userDto, Long pluginId); @Override Map<String, String> validateUser(UserDto userDto, Long pluginId); @Override String getHtml(HttpServletRequest request, String pluginId, Locale locale); @Override Object doAction(String pluginId, String action, HttpServletRequest request, HttpServletResponse response);  }### Answer:
@Test public void applyConfigurationWithCorrectValuesShouldBeSuccessful() throws PluginConfigurationException { List<PluginProperty> properties = new ArrayList<>(); properties.add(new PluginProperty(KaptchaPlugin.WIDTH_PROPERTY, PluginProperty.Type.INT, "400")); properties.add(new PluginProperty(KaptchaPlugin.HEIGHT_PROPERTY, PluginProperty.Type.INT, "400")); properties.add(new PluginProperty(KaptchaPlugin.LENGTH_PROPERTY, PluginProperty.Type.INT, "4")); properties.add(new PluginProperty(KaptchaPlugin.POSSIBLE_SYMBOLS_PROPERTY, PluginProperty.Type.STRING, "0123456789")); Map<PluginProperty, String> errors = kaptchaPlugin.applyConfiguration(properties); assertEquals(errors.size(), 0); }
@Test(expectedExceptions = PluginConfigurationException.class) public void applyConfigurationWithInvalidPropertiesShouldBeFailed() throws PluginConfigurationException { List<PluginProperty> properties = new ArrayList<>(); properties.add(new PluginProperty(KaptchaPlugin.WIDTH_PROPERTY, PluginProperty.Type.INT, "400")); properties.add(new PluginProperty(KaptchaPlugin.HEIGHT_PROPERTY, PluginProperty.Type.INT, "400")); properties.add(new PluginProperty(KaptchaPlugin.LENGTH_PROPERTY, PluginProperty.Type.INT, "ABC4")); kaptchaPlugin.applyConfiguration(properties); }