@Test
public void directFeedAttributeOverriding() throws Exception
{
// Check the original query and attribute values contained in the XML
final ProcessingResult result = post(KEY_KACZYNSKI,
ImmutableMap.<String, Object> of());
assertThatClusters(result.getClusters()).isNotEmpty();
assertThat(result.getAttribute(AttributeNames.QUERY)).isEqualTo("kaczyński");
assertThat(result.getAttribute("DocumentAssigner.exactPhraseAssignment"))
.isEqualTo(true);
final int initialClusterCount = result.getClusters().size();
// Override query
final String otherQuery = "other query";
final ProcessingResult overriddenQueryResult = post(KEY_KACZYNSKI,
ImmutableMap.<String, Object> of(AttributeNames.QUERY, otherQuery));
assertThat(overriddenQueryResult.getAttribute(AttributeNames.QUERY)).isEqualTo(
otherQuery);
// Override some attributes
final ProcessingResult overriddenAttributesResult = post(KEY_KACZYNSKI,
ImmutableMap.<String, Object> of("LingoClusteringAlgorithm.desiredClusterCountBase", "5"));
assertThat(overriddenAttributesResult.getClusters().size()).isNotEqualTo(
initialClusterCount);
// Note the string instead of an integer here. The reason for this is that the
// attributes get passed as a string POST parameters and the controller echoes
// input attributes to output exactly in the form they were provided, from string
// type conversion is performed only for the purposes of binding to the
// component's fields.
assertThat(
overriddenAttributesResult
.getAttribute("LingoClusteringAlgorithm.desiredClusterCountBase")).isEqualTo("5");
}