ReadJsonArrayHeadersFilter extends AbstractHeaderEntryFilter { public static ReadJsonArrayHeadersFilter getInstance(final Map<String, HeaderDefinition> headerDefinitions) { return new ReadJsonArrayHeadersFilter(checkNotNull(headerDefinitions, "headerDefinitions")); } private  ReadJsonArrayHeadersFilter(final Map<String, HeaderDefinition> headerDefinitions); static ReadJsonArrayHeadersFilter getInstance(final Map<String, HeaderDefinition> headerDefinitions);  }
@Test public void filterNonJsonArrayValue() { final String value = "bar"; final ReadJsonArrayHeadersFilter underTest = ReadJsonArrayHeadersFilter.getInstance(headerDefinitions); assertThat(underTest.apply("foo", value)).isEqualTo(value); }
@Test public void filterJsonArrayValueBasedOnCommaSeparatedList() { final List<AcknowledgementRequest> acknowledgementRequests = Lists.list( AcknowledgementRequest.of(AcknowledgementLabel.of("foo")), AcknowledgementRequest.of(AcknowledgementLabel.of("bar"))); final JsonArray acknowledgementRequestsJsonArray = acknowledgementRequests.stream() .map(AcknowledgementRequest::toString) .map(JsonValue::of) .collect(JsonCollectors.valuesToArray()); final String expectedArrayValue = acknowledgementRequestsJsonArray.toString(); final String commaSeparatedRequestedAcks = "foo,bar"; final ReadJsonArrayHeadersFilter underTest = ReadJsonArrayHeadersFilter.getInstance(headerDefinitions); final String filteredValue = underTest.apply(HEADER_DEFINITION.getKey(), commaSeparatedRequestedAcks); assertThat(filteredValue).isEqualTo(expectedArrayValue); }
@Test public void filterJsonArrayValueBasedOnEmptyString() { final JsonArray emptyJsonArray = JsonArray.empty(); final String expected = emptyJsonArray.toString(); final ReadJsonArrayHeadersFilter underTest = ReadJsonArrayHeadersFilter.getInstance(headerDefinitions); final String filtered = underTest.apply(HEADER_DEFINITION.getKey(), ""); assertThat(filtered).isEqualTo(expected); }