Skip to content

Commit

Permalink
chore(test): Don't assume order of operation log entries in Test
Browse files Browse the repository at this point in the history
Related to CAM-10667
  • Loading branch information
mboskamp committed Nov 4, 2019
1 parent cbd4849 commit 0ba0faa
Showing 1 changed file with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@

import static org.assertj.core.api.Assertions.assertThat;

import java.util.List;

import org.camunda.bpm.engine.EntityTypes;
import org.camunda.bpm.engine.HistoryService;
import org.camunda.bpm.engine.IdentityService;
Expand Down Expand Up @@ -96,15 +94,14 @@ public void shouldUpdateOperationLogWhenUpdateLegacyLicense() {
// given legacy license
managementService.setProperty(LicenseCmd.LICENSE_KEY_PROPERTY_NAME, "oldLicense");
identityService.setAuthenticatedUserId(USER_ID);

// when
managementService.setLicenseKey(LICENSE_KEY);
List<UserOperationLogEntry> entries = historyService.createUserOperationLogQuery().orderByTimestamp().asc().list();

// then
assertThat(entries.size()).isEqualTo(2);
assertOperationLogEntry(entries.get(0), UserOperationLogEntry.OPERATION_TYPE_CREATE, LicenseCmd.LICENSE_KEY_BYTE_ARRAY_ID);
assertOperationLogEntry(entries.get(1), UserOperationLogEntry.OPERATION_TYPE_DELETE, LicenseCmd.LICENSE_KEY_PROPERTY_NAME);
assertThat(historyService.createUserOperationLogQuery().count()).isEqualTo(2L);
UserOperationLogEntry createEntry = historyService.createUserOperationLogQuery().operationType(UserOperationLogEntry.OPERATION_TYPE_CREATE).singleResult();
UserOperationLogEntry deleteEntry = historyService.createUserOperationLogQuery().operationType(UserOperationLogEntry.OPERATION_TYPE_DELETE).singleResult();
assertOperationLogEntry(createEntry, UserOperationLogEntry.OPERATION_TYPE_CREATE, LicenseCmd.LICENSE_KEY_BYTE_ARRAY_ID);
assertOperationLogEntry(deleteEntry, UserOperationLogEntry.OPERATION_TYPE_DELETE, LicenseCmd.LICENSE_KEY_PROPERTY_NAME);
}

@Test
Expand Down Expand Up @@ -148,12 +145,12 @@ public void shouldNotUpdateOperationLogWhenDeleteNonExistingLicense() {
assertThat(entry).isNull();
}

private void assertOperationLogEntry(UserOperationLogEntry entry, String operationType, String newValue) {
private void assertOperationLogEntry(UserOperationLogEntry entry, String expectedOperationType, String expectedNewValue) {
assertThat(entry.getEntityType()).isEqualTo(EntityTypes.PROPERTY);
assertThat(entry.getCategory()).isEqualTo(UserOperationLogEntry.CATEGORY_ADMIN);
assertThat(entry.getOperationType()).isEqualTo(operationType);
assertThat(entry.getOperationType()).isEqualTo(expectedOperationType);
assertThat(entry.getProperty()).isEqualTo("name");
assertThat(entry.getOrgValue()).isNull();
assertThat(entry.getNewValue()).isEqualTo(newValue);
assertThat(entry.getNewValue()).isEqualTo(expectedNewValue);
}
}

0 comments on commit 0ba0faa

Please sign in to comment.