### Question:
ConfigurationRequirement implements Serializable { @XmlTransient public final void checkAndSetSettings(T... settings) throws AlgorithmConfigurationException { checkNumberOfSettings(settings.length); this.settings = settings; } ConfigurationRequirement();  ConfigurationRequirement(String identifier);  ConfigurationRequirement(String identifier, int numberOfSettings);  ConfigurationRequirement(String identifier, int minNumberOfSettings,
                                  int maxNumberOfSettings); String getIdentifier(); Boolean isFixNumberOfSettings(); int getMinNumberOfSettings(); int getMaxNumberOfSettings(); int getNumberOfSettings(); T[] getSettings(); void setSettings(T... settings); boolean isRequired(); void setRequired(boolean required); @XmlTransient final void checkAndSetSettings(T... settings); @XmlTransient abstract ConfigurationValue build(ConfigurationFactory factory); static final int ARBITRARY_NUMBER_OF_VALUES; public T[] settings; }### Answer:
@Test public void testCheckAndSetSettingsWithWrongArray() { ConfigurationRequirementCheckBox configSpec = new ConfigurationRequirementCheckBox("parameter1", new String[3], 2); ConfigurationSettingCheckBox expectedSetting0 = mock(ConfigurationSettingCheckBox.class); ConfigurationSettingCheckBox expectedSetting1 = mock(ConfigurationSettingCheckBox.class); ConfigurationSettingCheckBox expectedSetting2 = mock(ConfigurationSettingCheckBox.class); try { configSpec.checkAndSetSettings(expectedSetting0); } catch (AlgorithmConfigurationException e) { } try { configSpec.checkAndSetSettings(expectedSetting0, expectedSetting1); } catch (AlgorithmConfigurationException e) { fail(); } try { configSpec.checkAndSetSettings(expectedSetting0, expectedSetting1, expectedSetting2); } catch (AlgorithmConfigurationException e) { } }
@Test public void testCheckAndSetSettingsWithWrongNumber() { ConfigurationRequirementListBox configSpec = new ConfigurationRequirementListBox("parameter1", new ArrayList<String>(), 2); ConfigurationSettingListBox expectedSetting0 = mock(ConfigurationSettingListBox.class); ConfigurationSettingListBox expectedSetting1 = mock(ConfigurationSettingListBox.class); ConfigurationSettingListBox expectedSetting2 = mock(ConfigurationSettingListBox.class); try { configSpec.checkAndSetSettings(expectedSetting0); } catch (AlgorithmConfigurationException e) { } try { configSpec.checkAndSetSettings(expectedSetting0, expectedSetting1); } catch (AlgorithmConfigurationException e) { fail(); } try { configSpec.checkAndSetSettings(expectedSetting0, expectedSetting1, expectedSetting2); } catch (AlgorithmConfigurationException e) { } }
@Test public void testCheckAndSetSettingsWithWrongNumberRange() { ConfigurationRequirementRelationalInput configSpec = new ConfigurationRequirementRelationalInput("parameter1", 2, 4); ConfigurationSettingRelationalInput expectedSetting0 = mock(ConfigurationSettingRelationalInput.class); ConfigurationSettingRelationalInput expectedSetting1 = mock(ConfigurationSettingRelationalInput.class); ConfigurationSettingRelationalInput expectedSetting2 = mock(ConfigurationSettingRelationalInput.class); ConfigurationSettingRelationalInput expectedSetting3 = mock(ConfigurationSettingRelationalInput.class); try { configSpec.checkAndSetSettings(expectedSetting0); } catch (AlgorithmConfigurationException e) { } try { configSpec.checkAndSetSettings(expectedSetting0, expectedSetting1); } catch (AlgorithmConfigurationException e) { fail(); } try { configSpec.checkAndSetSettings(expectedSetting0, expectedSetting1, expectedSetting2); } catch (AlgorithmConfigurationException e) { fail(); } try { configSpec.checkAndSetSettings(expectedSetting0, expectedSetting1, expectedSetting2, expectedSetting3); } catch (AlgorithmConfigurationException e) { } }