### Question:
ReindexingTaskFactory implements TaskFactory { public static Integer getConfigInteger(Map<String, Object> taskConfig, String propertyName, boolean isMandatory) throws TaskConfigurationException { if (taskConfig == null) throw new TaskConfigurationException(propertyName + " configuration property must be defined"); Object val = taskConfig.get(propertyName); if (val instanceof Integer) { return (Integer) val; } boolean isEmpty = val == null || val.toString().trim().isEmpty(); if (isMandatory && isEmpty) { throw new TaskConfigurationException(propertyName + " configuration property must be defined"); } if (!isMandatory && isEmpty) { return null; } try { return new Integer(val.toString().trim()); } catch (NumberFormatException e) { throw new TaskConfigurationException(propertyName + " configuration property must be a number"); } }  @Override List<String> listSupportedTaskTypes(); @Override Task createTask(String taskType, Map<String, Object> taskConfig); static String getMandatoryConfigString(Map<String, Object> taskConfig, String propertyName); static String[] getMandatoryConfigStringArray(Map<String, Object> taskConfig, String propertyName); static String[] getConfigStringArray(Map<String, Object> taskConfig, String propertyName); static Integer getConfigInteger(Map<String, Object> taskConfig, String propertyName, boolean isMandatory); static final String CFG_PROJECT_ID_VALUE; static final String CFG_PROJECT_ID_TYPE; static final String CFG_CONTRIBUTOR_ID_VALUE; static final String CFG_CONTRIBUTOR_ID_TYPE; static final String CFG_SYS_CONTENT_TYPE; static final String CFG_PROJECT_CODE; static final String CFG_CONTRIBUTOR_CODE; }### Answer:
@Test public void testGetConfigInteger() throws TaskConfigurationException { String PROP_NAME = "testproperty"; Map<String, Object> taskConfig = new HashMap<>(); Assert.assertNull(ReindexingTaskFactory.getConfigInteger(taskConfig, PROP_NAME, false)); taskConfig.put(PROP_NAME, new Integer(1)); Assert.assertEquals(new Integer(1), ReindexingTaskFactory.getConfigInteger(taskConfig, PROP_NAME, false)); taskConfig.put(PROP_NAME, "1"); Assert.assertEquals(new Integer(1), ReindexingTaskFactory.getConfigInteger(taskConfig, PROP_NAME, false)); }
@Test(expected = TaskConfigurationException.class) public void testGetConfigIntegerMissingValue() throws TaskConfigurationException { ReindexingTaskFactory.getConfigInteger(new HashMap<String, Object>(), "property", true); }
@Test(expected = TaskConfigurationException.class) public void testGetConfigIntegerBadValue() throws TaskConfigurationException { String PROP_NAME = "testproperty"; Map<String, Object> taskConfig = new HashMap<>(); taskConfig.put(PROP_NAME, "badvalue"); ReindexingTaskFactory.getConfigInteger(taskConfig, PROP_NAME, false); }