CAM-10025: improve assertion error for "hasPassed" - misleading hint for historyLevel
jangalinski opened this issue · 2 comments
I have been hunting ghosts for the past 30 minutes because a processinstance assertion "
assertThat(processInstance)
.isEnded()
.hasPassed("event");"
failed with:
java.lang.AssertionError: Expecting actual ProcessInstance {id='4', processDefinitionId='process_skipTaskAndEvent:1:3', businessKey='null'}
to be ended, but it is not!. (Please make sure you have set the history service
of the engine to at least 'activity' or a higher level before making use of this assertion!)
which let to me analysing the in memory engine configuration to verify I have a sufficient history level defined. Turns out: I have. So the side note was not only irrelevant, but misleading.
I think it would be a good idea to determine the history Level of the registered engine and then let assertions fail when they the level is not sufficient.
Code example (java 7):
try (Statement st = processEngineRule.getProcessEngine().getProcessEngineConfiguration().getDataSource().getConnection().createStatement()) {
ResultSet rs = st.executeQuery("SELECT VALUE_ FROM ACT_GE_PROPERTY where NAME_ = 'historyLevel'");
while (rs.next()) {
System.out.println(rs.getString(1));
}
}
Good observation. I agree. I propose to add that check not just for hasPassed, but as an internally accessible method, e.g. in AbstractProcessAssert. Do you want to contribute that?
Hey Jan,
it has been a while already, but thanks for spotting and proposing this.
A check for the history level set in the engine before making this suggestion sounds like a useful addition.
We will look into this as soon as possible and track the further progress in https://app.camunda.com/jira/browse/CAM-10025.
You are of course welcome to submit a pull request to speed up the integration of the feature.
I am closing this as transferred to JIRA.
Best,
Tobias