use of com.amazon.dataprepper.plugins.processor.aggregate.AggregateActionInput in project data-prepper by opensearch-project.
the class PutAllAggregateActionTest method handleEvent_with_non_empty_groupState_should_combine_Event_with_groupState_correctly.
@Test
void handleEvent_with_non_empty_groupState_should_combine_Event_with_groupState_correctly() {
combineAggregateAction = createObjectUnderTest();
final AggregateActionInput aggregateActionInput = new AggregateActionTestUtils.TestAggregateActionInput();
final GroupState groupState = aggregateActionInput.getGroupState();
groupState.putAll(events.get(0).toMap());
final GroupState expectedGroupState = new AggregateActionTestUtils.TestGroupState();
expectedGroupState.putAll(groupState);
expectedGroupState.putAll(events.get(1).toMap());
final AggregateActionResponse aggregateActionResponse = combineAggregateAction.handleEvent(events.get(1), aggregateActionInput);
assertThat(aggregateActionResponse.getEvent(), equalTo(null));
assertThat(groupState, equalTo(expectedGroupState));
}
use of com.amazon.dataprepper.plugins.processor.aggregate.AggregateActionInput in project data-prepper by opensearch-project.
the class PutAllAggregateActionTest method concludeGroup_should_return_groupState_As_An_Event_correctly.
@Test
void concludeGroup_should_return_groupState_As_An_Event_correctly() {
combineAggregateAction = createObjectUnderTest();
final AggregateActionInput aggregateActionInput = new AggregateActionTestUtils.TestAggregateActionInput();
final GroupState groupState = aggregateActionInput.getGroupState();
for (final Map<String, Object> eventMap : eventMaps) {
groupState.putAll(eventMap);
}
final Optional<Event> result = combineAggregateAction.concludeGroup(aggregateActionInput);
assertThat(result.isPresent(), equalTo(true));
assertThat(result.get().getMetadata().getEventType(), equalTo(PutAllAggregateAction.EVENT_TYPE));
assertThat(result.get().toMap(), equalTo(groupState));
}
use of com.amazon.dataprepper.plugins.processor.aggregate.AggregateActionInput in project data-prepper by opensearch-project.
the class PutAllAggregateActionTest method handleEvent_with_empty_group_state_should_return_correct_AggregateResponse_and_add_event_to_groupState.
@Test
void handleEvent_with_empty_group_state_should_return_correct_AggregateResponse_and_add_event_to_groupState() {
combineAggregateAction = createObjectUnderTest();
final AggregateActionInput aggregateActionInput = new AggregateActionTestUtils.TestAggregateActionInput();
final AggregateActionResponse aggregateActionResponse = combineAggregateAction.handleEvent(events.get(0), aggregateActionInput);
assertThat(aggregateActionResponse.getEvent(), equalTo(null));
assertThat(aggregateActionInput.getGroupState(), equalTo(events.get(0).toMap()));
}
use of com.amazon.dataprepper.plugins.processor.aggregate.AggregateActionInput in project data-prepper by opensearch-project.
the class RemoveDuplicatesAggregateActionTest method concludeGroup_with_non_empty_groupState_returns_empty_Optional.
@Test
void concludeGroup_with_non_empty_groupState_returns_empty_Optional() {
removeDuplicatesAggregateAction = createObjectUnderTest();
final AggregateActionInput aggregateActionInput = new AggregateActionTestUtils.TestAggregateActionInput();
final GroupState groupState = aggregateActionInput.getGroupState();
groupState.put(UUID.randomUUID().toString(), UUID.randomUUID().toString());
final Optional<Event> result = removeDuplicatesAggregateAction.concludeGroup(aggregateActionInput);
assertThat(result.isPresent(), equalTo(false));
}
use of com.amazon.dataprepper.plugins.processor.aggregate.AggregateActionInput in project data-prepper by opensearch-project.
the class RemoveDuplicatesAggregateActionTest method concludeGroup_with_empty_groupState_returns_empty_Optional.
@Test
void concludeGroup_with_empty_groupState_returns_empty_Optional() {
removeDuplicatesAggregateAction = createObjectUnderTest();
final AggregateActionInput aggregateActionInput = new AggregateActionTestUtils.TestAggregateActionInput();
final Optional<Event> result = removeDuplicatesAggregateAction.concludeGroup(aggregateActionInput);
assertThat(result.isPresent(), equalTo(false));
}
Aggregations