Skip to content

feat: flamingock test support foundation#751

Merged
dieppa merged 4 commits into
developfrom
feature/flamingock-test-support-foundation
Dec 8, 2025
Merged

feat: flamingock test support foundation#751
dieppa merged 4 commits into
developfrom
feature/flamingock-test-support-foundation

Conversation

@davidfrigolet

Copy link
Copy Markdown
Contributor

feat: flamingock test support foundation

Comment on lines +64 to +66
public static AuditEntryExpectation STARTED(String taskId) {
return new AuditEntryExpectation().withTaskId(taskId).withState(AuditEntry.Status.STARTED);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have STARTED in here to make it easier to the user.
STRTED really is an intermediate state that we use, but we want to make it easier to the user. He probably only cares about APPLIED, ROLLED_BACK, FAILED, ROLLBACK_FAILED

Comment on lines +84 to +102
@Deprecated
public static AuditEntryExpectation started(String changeId) {
return STARTED(changeId);
}

@Deprecated
public static AuditEntryExpectation applied(String changeId) {
return APPLIED(changeId);
}

@Deprecated
public static AuditEntryExpectation failed(String changeId) {
return FAILED(changeId);
}

@Deprecated
public static AuditEntryExpectation rolledBack(String changeId) {
return ROLLED_BACK(changeId);
}

@dieppa dieppa Dec 5, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why deprecated if we are creating this class? Let's remove all of these ones

private boolean shouldVerifyExecutionMillis = false;
private boolean shouldVerifyExecutionHostname = false;

AuditEntryExpectation() {}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be private

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I would have the constructor
private AuditEntryExpectation(String changeId, AuditEntry.Status status)

Comment on lines +60 to +62
public static AuditEntryExpectation auditEntry() {
return new AuditEntryExpectation();
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this, the minimum we require is state(given by the static constructors(APPLIED, FAILED, etc)) and the id

Comment on lines +117 to +120
public AuditEntryExpectation withTaskId(String taskId) {
this.expectedTaskId = taskId;
return this;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can remove this because it should always be created with static constructors(APPLIED, FAILED, etc)

Comment on lines +36 to +40
if (changes != null) {
for (Class<?> c : changes) {
applied.add(c);
}
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can simply do applied.addAll(Arrays.asList(changes));

the same to the other methods

Comment on lines +18 to +28
import java.util.function.Consumer;
import java.util.List;
import io.flamingock.internal.common.core.audit.AuditEntry;

public interface WhenStage {
ThenStage thenExpectAuditSequenceStrict(AuditEntryExpectation... expectations);
ThenStage thenExpectException(Class<? extends Throwable> exceptionClass, Consumer<Throwable> validator);
ThenStage thenInspectAuditEntries(Consumer<List<AuditEntry>> validator);

void verify();
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This interface( and the implementation class) is not needed.

with the current API we can verify nothing, because it allows

FlamingockTestSupport
  .given(builder)
//...
  .whenRun()
  .verify();

So first thing would be removing the method verify from here.

But this interface only makes sense if we want to have more than one when action, however by definition there should only be one action. So this interface gives nothing really.

My suggestion is removing this interface(and the implementation class) and the whenRun method in the GivenStage interface returns directly a ThenStage

Comment on lines +24 to +27
ThenStage thenExpectAuditSequenceStrict(AuditEntryExpectation... expectations);
ThenStage thenExpectException(Class<? extends Throwable> exceptionClass, Consumer<Throwable> validator);
ThenStage thenInspectAuditEntries(Consumer<List<AuditEntry>> validator);
void verify();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add javadoc in here so the user is clear on what is the expectation in each case is, when they are evaluated and what verify does

Comment thread settings.gradle.kts Outdated



include("core:flamingock-test-support") No newline at end of file

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be removed

Comment on lines +18 to +23
public interface GivenStage {
GivenStage andAppliedChanges(Class<?>... changes);
GivenStage andFailedChanges(Class<?>... changes);
GivenStage andRolledbackChanges(Class<?>... changes);
WhenStage whenRun();
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Javadoc

@dieppa
dieppa merged commit 8ba0fbe into develop Dec 8, 2025
4 checks passed
@dieppa
dieppa deleted the feature/flamingock-test-support-foundation branch February 9, 2026 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants