@Test public void testFormatEntityList() { AbstractCheckDescriptor check = new TestCheckImpl(PrereqCheckType.HOST); Assert.assertEquals("", check.formatEntityList(null)); final LinkedHashSet<String> failedOn = new LinkedHashSet<String>(); 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)); }
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(); }
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(); } }
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); }
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); boolean isApplicable(PrereqCheckRequest request); boolean isApplicable(PrereqCheckRequest request, List<String> requiredServices, boolean requiredAll); abstract void perform(PrerequisiteCheck prerequisiteCheck, PrereqCheckRequest request); CheckDescription getDescription(); PrereqCheckType getType(); boolean isRequired(UpgradeType upgradeType); boolean isStackUpgradeAllowedToBypassPreChecks(); }
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); boolean isApplicable(PrereqCheckRequest request); boolean isApplicable(PrereqCheckRequest request, List<String> requiredServices, boolean requiredAll); abstract void perform(PrerequisiteCheck prerequisiteCheck, PrereqCheckRequest request); CheckDescription getDescription(); PrereqCheckType getType(); boolean isRequired(UpgradeType upgradeType); boolean isStackUpgradeAllowedToBypassPreChecks();  }