Search in sources :

Example 1 with AggregateActionResponse

use of com.amazon.dataprepper.plugins.processor.aggregate.AggregateActionResponse 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));
}
Also used : AggregateActionInput(com.amazon.dataprepper.plugins.processor.aggregate.AggregateActionInput) AggregateActionResponse(com.amazon.dataprepper.plugins.processor.aggregate.AggregateActionResponse) GroupState(com.amazon.dataprepper.plugins.processor.aggregate.GroupState) Test(org.junit.jupiter.api.Test)

Example 2 with AggregateActionResponse

use of com.amazon.dataprepper.plugins.processor.aggregate.AggregateActionResponse 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()));
}
Also used : AggregateActionInput(com.amazon.dataprepper.plugins.processor.aggregate.AggregateActionInput) AggregateActionResponse(com.amazon.dataprepper.plugins.processor.aggregate.AggregateActionResponse) Test(org.junit.jupiter.api.Test)

Example 3 with AggregateActionResponse

use of com.amazon.dataprepper.plugins.processor.aggregate.AggregateActionResponse in project data-prepper by opensearch-project.

the class RemoveDuplicatesAggregateActionTest method handleEvent_with_empty_groupState_returns_expected_AggregateResponse_and_modifies_groupState.

@Test
void handleEvent_with_empty_groupState_returns_expected_AggregateResponse_and_modifies_groupState() {
    removeDuplicatesAggregateAction = createObjectUnderTest();
    final AggregateActionInput aggregateActionInput = new AggregateActionTestUtils.TestAggregateActionInput();
    final GroupState groupState = aggregateActionInput.getGroupState();
    final AggregateActionResponse aggregateActionResponse = removeDuplicatesAggregateAction.handleEvent(testEvent, aggregateActionInput);
    assertThat(aggregateActionResponse.getEvent(), equalTo(testEvent));
    assertThat(groupState, equalTo(expectedGroupState));
}
Also used : AggregateActionInput(com.amazon.dataprepper.plugins.processor.aggregate.AggregateActionInput) AggregateActionResponse(com.amazon.dataprepper.plugins.processor.aggregate.AggregateActionResponse) GroupState(com.amazon.dataprepper.plugins.processor.aggregate.GroupState) Test(org.junit.jupiter.api.Test)

Example 4 with AggregateActionResponse

use of com.amazon.dataprepper.plugins.processor.aggregate.AggregateActionResponse in project data-prepper by opensearch-project.

the class RemoveDuplicatesAggregateActionTest method handleEvent_with_non_empty_groupState_returns_expected_AggregateResponse_and_does_not_modify_groupState.

@Test
void handleEvent_with_non_empty_groupState_returns_expected_AggregateResponse_and_does_not_modify_groupState() {
    removeDuplicatesAggregateAction = createObjectUnderTest();
    final AggregateActionInput aggregateActionInput = new AggregateActionTestUtils.TestAggregateActionInput();
    final GroupState groupState = aggregateActionInput.getGroupState();
    groupState.put(RemoveDuplicatesAggregateAction.GROUP_STATE_HAS_EVENT, true);
    final AggregateActionResponse aggregateActionResponse = removeDuplicatesAggregateAction.handleEvent(testEvent, aggregateActionInput);
    assertThat(aggregateActionResponse.getEvent(), equalTo(null));
    assertThat(groupState, equalTo(expectedGroupState));
}
Also used : AggregateActionInput(com.amazon.dataprepper.plugins.processor.aggregate.AggregateActionInput) AggregateActionResponse(com.amazon.dataprepper.plugins.processor.aggregate.AggregateActionResponse) GroupState(com.amazon.dataprepper.plugins.processor.aggregate.GroupState) Test(org.junit.jupiter.api.Test)

Aggregations

AggregateActionInput (com.amazon.dataprepper.plugins.processor.aggregate.AggregateActionInput)4 AggregateActionResponse (com.amazon.dataprepper.plugins.processor.aggregate.AggregateActionResponse)4 Test (org.junit.jupiter.api.Test)4 GroupState (com.amazon.dataprepper.plugins.processor.aggregate.GroupState)3