RestartActions { public List<Entry> getEntries() { return new ArrayList<>(actions.values()); } RestartActions(); private  RestartActions(Map<String, Entry> actions);  RestartActions(List<ConfigChangeAction> actions); RestartActions useForInternalRestart(boolean useForInternalRestart); List<Entry> getEntries(); String format(); boolean isEmpty();  }
@Test public void actions_with_multiple_reasons() { ConfigChangeActions actions = new ConfigChangeActionsBuilder(). restart(CHANGE_MSG, CLUSTER, CLUSTER_TYPE, SERVICE_TYPE, SERVICE_NAME). restart(CHANGE_MSG_2, CLUSTER, CLUSTER_TYPE, SERVICE_TYPE, SERVICE_NAME).build(); List<RestartActions.Entry> entries = actions.getRestartActions().getEntries(); assertThat(entries.size(), is(1)); assertThat(toString(entries.get(0)), equalTo("search.foo.searchnode:[baz][change,other change]")); }
@Test public void actions_with_same_service_type() { ConfigChangeActions actions = new ConfigChangeActionsBuilder(). restart(CHANGE_MSG, CLUSTER, CLUSTER_TYPE, SERVICE_TYPE, SERVICE_NAME). restart(CHANGE_MSG, CLUSTER, CLUSTER_TYPE, SERVICE_TYPE, SERVICE_NAME_2).build(); List<RestartActions.Entry> entries = actions.getRestartActions().getEntries(); assertThat(entries.size(), is(1)); assertThat(toString(entries.get(0)), equalTo("search.foo.searchnode:[baz,qux][change]")); }
@Test public void actions_with_multiple_service_types() { ConfigChangeActions actions = new ConfigChangeActionsBuilder(). restart(CHANGE_MSG, CLUSTER, CLUSTER_TYPE, SERVICE_TYPE, SERVICE_NAME). restart(CHANGE_MSG, CLUSTER, CLUSTER_TYPE, SERVICE_TYPE_2, SERVICE_NAME).build(); List<RestartActions.Entry> entries = actions.getRestartActions().getEntries(); assertThat(entries.size(), is(2)); assertThat(toString(entries.get(0)), equalTo("search.foo.distributor:[baz][change]")); assertThat(toString(entries.get(1)), equalTo("search.foo.searchnode:[baz][change]")); }
@Test public void actions_with_multiple_clusters_of_same_type() { ConfigChangeActions actions = new ConfigChangeActionsBuilder(). restart(CHANGE_MSG, CLUSTER, CLUSTER_TYPE, SERVICE_TYPE, SERVICE_NAME). restart(CHANGE_MSG, CLUSTER_2, CLUSTER_TYPE, SERVICE_TYPE, SERVICE_NAME).build(); List<RestartActions.Entry> entries = actions.getRestartActions().getEntries(); assertThat(entries.size(), is(2)); assertThat(toString(entries.get(0)), equalTo("search.bar.searchnode:[baz][change]")); assertThat(toString(entries.get(1)), equalTo("search.foo.searchnode:[baz][change]")); }
@Test public void actions_with_multiple_clusters_of_different_type() { ConfigChangeActions actions = new ConfigChangeActionsBuilder(). restart(CHANGE_MSG, CLUSTER, CLUSTER_TYPE, SERVICE_TYPE, SERVICE_NAME). restart(CHANGE_MSG, CLUSTER, CLUSTER_TYPE_2, SERVICE_TYPE, SERVICE_NAME).build(); List<RestartActions.Entry> entries = actions.getRestartActions().getEntries(); assertThat(entries.size(), is(2)); assertThat(toString(entries.get(0)), equalTo("content.foo.searchnode:[baz][change]")); assertThat(toString(entries.get(1)), equalTo("search.foo.searchnode:[baz][change]")); }