Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/enable message direction filter #48

Merged
merged 1 commit into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,15 @@ protected Specification<ScenarioExecution> createSpecification(ScenarioExecution
)
);
}
if (nonNull(criteria.getScenarioMessagesDirection())) {
specification =
specification.and(
buildSpecification(
criteria.getScenarioMessagesDirection(),
root -> root.join(ScenarioExecution_.scenarioMessages, JoinType.LEFT).get(Message_.direction)
)
);
}
if (nonNull(criteria.getScenarioParametersId())) {
specification =
specification.and(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ public class ScenarioExecutionCriteria implements Serializable, Criteria {

private @Nullable LongFilter scenarioMessagesId;

private @Nullable IntegerFilter scenarioMessagesDirection;

private @Nullable LongFilter scenarioParametersId;

private @Nullable String headers;
Expand All @@ -85,6 +87,7 @@ public ScenarioExecutionCriteria(ScenarioExecutionCriteria other) {
this.status = other.status == null ? null : other.status.copy();
this.scenarioActionsId = other.scenarioActionsId == null ? null : other.scenarioActionsId.copy();
this.scenarioMessagesId = other.scenarioMessagesId == null ? null : other.scenarioMessagesId.copy();
this.scenarioMessagesDirection = other.scenarioMessagesDirection == null ? null : other.scenarioMessagesDirection.copy();
this.scenarioParametersId = other.scenarioParametersId == null ? null : other.scenarioParametersId.copy();
this.headers = other.headers;
this.scenarioMessagesPayload = other.scenarioMessagesPayload;
Expand All @@ -110,6 +113,7 @@ public boolean equals(Object o) {
.append(status, scenarioExecutionCriteria.status)
.append(scenarioActionsId, scenarioExecutionCriteria.scenarioActionsId)
.append(scenarioMessagesId, scenarioExecutionCriteria.scenarioMessagesId)
.append(scenarioMessagesDirection, scenarioExecutionCriteria.scenarioMessagesDirection)
bbortt marked this conversation as resolved.
Show resolved Hide resolved
.append(scenarioParametersId, scenarioExecutionCriteria.scenarioParametersId)
.append(headers, scenarioExecutionCriteria.headers)
.append(scenarioMessagesPayload, scenarioExecutionCriteria.scenarioMessagesPayload)
Expand All @@ -127,6 +131,7 @@ public int hashCode() {
.append(status)
.append(scenarioActionsId)
.append(scenarioMessagesId)
.append(scenarioMessagesDirection)
.append(scenarioParametersId)
.append(headers)
.append(scenarioMessagesPayload)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,29 @@ void getAllScenarioExecutionsByScenarioMessagesIsEqualToSomething() throws Excep
defaultScenarioExecutionShouldNotBeFound("scenarioMessagesId.equals=" + (scenarioMessagesId + 1));
}

@Test
@Transactional
void getAllScenarioExecutionsByScenarioMessageDirectionIsEqualToSomething() throws Exception {
Message scenarioMessages;
if (TestUtil.findAll(entityManager, Message.class).isEmpty()) {
scenarioExecutionRepository.saveAndFlush(scenarioExecution);
scenarioMessages = MessageResourceIT.createEntity(entityManager);
} else {
scenarioMessages = TestUtil.findAll(entityManager, Message.class).get(0);
}
scenarioMessages.setDirection(Message.Direction.INBOUND);
entityManager.persist(scenarioMessages);
entityManager.flush();
scenarioExecution.addScenarioMessage(scenarioMessages);
scenarioExecutionRepository.saveAndFlush(scenarioExecution);
int scenarioMessageDirection = scenarioMessages.getDirection().getId();
// Get all the scenarioExecutionList where scenarioMessagesDirection equals to scenarioMessagesDirection
defaultScenarioExecutionShouldBeFound("scenarioMessagesDirection.equals=" + scenarioMessageDirection);

// Get all the scenarioExecutionList where scenarioMessagesDirection equals to (scenarioMessagesDirection + 1)
defaultScenarioExecutionShouldNotBeFound("scenarioMessagesDirection.equals=" + (Message.Direction.UNKNOWN.getId()));
}

@Test
@Transactional
void getAllScenarioExecutionsByScenarioMessagesPayloadIsEqualToSomething() throws Exception {
Expand Down
Loading