feat: flamingock test support foundation#751
Conversation
| public static AuditEntryExpectation STARTED(String taskId) { | ||
| return new AuditEntryExpectation().withTaskId(taskId).withState(AuditEntry.Status.STARTED); | ||
| } |
There was a problem hiding this comment.
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
| @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); | ||
| } |
There was a problem hiding this comment.
Why deprecated if we are creating this class? Let's remove all of these ones
| private boolean shouldVerifyExecutionMillis = false; | ||
| private boolean shouldVerifyExecutionHostname = false; | ||
|
|
||
| AuditEntryExpectation() {} |
There was a problem hiding this comment.
Actually, I would have the constructor
private AuditEntryExpectation(String changeId, AuditEntry.Status status)
| public static AuditEntryExpectation auditEntry() { | ||
| return new AuditEntryExpectation(); | ||
| } |
There was a problem hiding this comment.
Remove this, the minimum we require is state(given by the static constructors(APPLIED, FAILED, etc)) and the id
| public AuditEntryExpectation withTaskId(String taskId) { | ||
| this.expectedTaskId = taskId; | ||
| return this; | ||
| } |
There was a problem hiding this comment.
We can remove this because it should always be created with static constructors(APPLIED, FAILED, etc)
| if (changes != null) { | ||
| for (Class<?> c : changes) { | ||
| applied.add(c); | ||
| } | ||
| } |
There was a problem hiding this comment.
You can simply do applied.addAll(Arrays.asList(changes));
the same to the other methods
| 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(); | ||
| } |
There was a problem hiding this comment.
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
| ThenStage thenExpectAuditSequenceStrict(AuditEntryExpectation... expectations); | ||
| ThenStage thenExpectException(Class<? extends Throwable> exceptionClass, Consumer<Throwable> validator); | ||
| ThenStage thenInspectAuditEntries(Consumer<List<AuditEntry>> validator); | ||
| void verify(); |
There was a problem hiding this comment.
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
|
|
||
|
|
||
|
|
||
| include("core:flamingock-test-support") No newline at end of file |
| public interface GivenStage { | ||
| GivenStage andAppliedChanges(Class<?>... changes); | ||
| GivenStage andFailedChanges(Class<?>... changes); | ||
| GivenStage andRolledbackChanges(Class<?>... changes); | ||
| WhenStage whenRun(); | ||
| } |
feat: flamingock test support foundation