### Question:
AbstractCheckDescriptor { protected String formatEntityList(LinkedHashSet<String> entities) { if (entities == null || entities.isEmpty()) { return ""; } final StringBuilder formatted = new StringBuilder(StringUtils.join(entities, ", ")); if (entities.size() > 1) { formatted.replace(formatted.lastIndexOf(","), formatted.lastIndexOf(",") + 1, " and"); } return formatted.toString(); } protected  AbstractCheckDescriptor(CheckDescription description); Set<String> getApplicableServices(); List<CheckQualification> getQualifications(); final boolean isApplicable(PrereqCheckRequest request); abstract void perform(PrerequisiteCheck prerequisiteCheck, PrereqCheckRequest request); CheckDescription getDescription(); PrereqCheckType getType(); boolean isRequired(UpgradeType upgradeType);  }### Answer:
@Test public void testFormatEntityList() { AbstractCheckDescriptor check = new TestCheckImpl(PrereqCheckType.HOST); Assert.assertEquals("", check.formatEntityList(null)); final LinkedHashSet<String> failedOn = new LinkedHashSet<>(); Assert.assertEquals("", check.formatEntityList(failedOn)); failedOn.add("host1"); Assert.assertEquals("host1", check.formatEntityList(failedOn)); failedOn.add("host2"); Assert.assertEquals("host1 and host2", check.formatEntityList(failedOn)); failedOn.add("host3"); Assert.assertEquals("host1, host2 and host3", check.formatEntityList(failedOn)); check = new TestCheckImpl(PrereqCheckType.CLUSTER); Assert.assertEquals("host1, host2 and host3", check.formatEntityList(failedOn)); check = new TestCheckImpl(PrereqCheckType.SERVICE); Assert.assertEquals("host1, host2 and host3", check.formatEntityList(failedOn)); check = new TestCheckImpl(null); Assert.assertEquals("host1, host2 and host3", check.formatEntityList(failedOn)); }