RefeedActionsFormatter { public String format() { StringBuilder builder = new StringBuilder(); for (RefeedActions.Entry entry : actions.getEntries()) { if (entry.allowed()) builder.append("(allowed) "); builder.append(entry.name() + ": Consider removing data and re-feed document type '" + entry.getDocumentType() + "' in cluster '" + entry.getClusterName() + "' because:\n"); int counter = 1; for (String message : entry.getMessages()) { builder.append(" " + (counter++) + ") " + message + "\n"); } } return builder.toString(); } RefeedActionsFormatter(RefeedActions actions); String format();  }
@Test public void formatting_of_single_action() { RefeedActions actions = new ConfigChangeActionsBuilder(). refeed(CHANGE_ID, false, CHANGE_MSG, DOC_TYPE, CLUSTER, SERVICE_NAME). build().getRefeedActions(); assertEquals("change-id: Consider removing data and re-feed document type 'music' in cluster 'foo' because:\n" + " 1) change\n", new RefeedActionsFormatter(actions).format()); }
@Test public void formatting_of_multiple_actions() { RefeedActions actions = new ConfigChangeActionsBuilder(). refeed(CHANGE_ID, false, CHANGE_MSG, DOC_TYPE, CLUSTER, SERVICE_NAME). refeed(CHANGE_ID, false, CHANGE_MSG_2, DOC_TYPE, CLUSTER, SERVICE_NAME). refeed(CHANGE_ID_2, false, CHANGE_MSG_2, DOC_TYPE, CLUSTER, SERVICE_NAME). refeed(CHANGE_ID_2, true, CHANGE_MSG_2, DOC_TYPE, CLUSTER, SERVICE_NAME). refeed(CHANGE_ID, false, CHANGE_MSG_2, DOC_TYPE_2, CLUSTER, SERVICE_NAME). build().getRefeedActions(); assertEquals("change-id: Consider removing data and re-feed document type 'book' in cluster 'foo' because:\n" + " 1) other change\n" + "change-id: Consider removing data and re-feed document type 'music' in cluster 'foo' because:\n" + " 1) change\n" + " 2) other change\n" + "other-change-id: Consider removing data and re-feed document type 'music' in cluster 'foo' because:\n" + " 1) other change\n" + "(allowed) other-change-id: Consider removing data and re-feed document type 'music' in cluster 'foo' because:\n" + " 1) other change\n", new RefeedActionsFormatter(actions).format()); }