From 7243fa0be676960a9a20c2e1a5b990fefffb17c9 Mon Sep 17 00:00:00 2001 From: Emmanuel Duchastenier Date: Wed, 21 Sep 2022 09:53:35 +0200 Subject: [PATCH] fix(test): do not print warning at end of tests (#2317) if there are no unclean message to display --- .../engine/test/internal/EngineCommander.java | 45 ++++++++++--------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/bonita-test-api/src/main/java/org/bonitasoft/engine/test/internal/EngineCommander.java b/bonita-test-api/src/main/java/org/bonitasoft/engine/test/internal/EngineCommander.java index b55a8304dc5..87dbcc41d01 100644 --- a/bonita-test-api/src/main/java/org/bonitasoft/engine/test/internal/EngineCommander.java +++ b/bonita-test-api/src/main/java/org/bonitasoft/engine/test/internal/EngineCommander.java @@ -220,8 +220,8 @@ public void clearData() throws Exception { messages.addAll(checkNoComments()); messages.addAll(checkNoArchivedComments()); messages.addAll(checkNoWaitingEvent()); - messages.addAll(checkNoProcessIntances()); - messages.addAll(checkNoArchivedProcessIntances()); + messages.addAll(checkNoProcessInstances()); + messages.addAll(checkNoArchivedProcessInstances()); messages.addAll(checkNoProcessDefinitions()); messages.addAll(checkNoCategories()); messages.addAll(checkNoUsers()); @@ -229,9 +229,11 @@ public void clearData() throws Exception { messages.addAll(checkNoRoles()); messages.addAll(checkNoSupervisors()); logoutOnTenant(); - LOGGER.warn("Engine was not clean after test:"); - for (String message : messages) { - LOGGER.warn(message); + if (!messages.isEmpty()) { + LOGGER.warn("Engine was not clean after test. We cleaned for you the following elements:"); + for (String message : messages) { + LOGGER.warn(message); + } } } @@ -240,7 +242,7 @@ public List checkNoCategories() throws DeletionException { final long numberOfCategories = getProcessAPI().getNumberOfCategories(); if (numberOfCategories > 0) { final List categories = getProcessAPI().getCategories(0, 5000, CategoryCriterion.NAME_ASC); - final StringBuilder categoryBuilder = new StringBuilder("Categories are still present: "); + final StringBuilder categoryBuilder = new StringBuilder("Categories were still present: "); for (final Category category : categories) { categoryBuilder.append(category.getName()).append(", "); getProcessAPI().deleteCategory(category.getId()); @@ -256,7 +258,7 @@ public List checkNoFlowNodes() throws SearchException { final SearchResult searchResult = getProcessAPI().searchFlowNodeInstances(build.done()); final List flowNodeInstances = searchResult.getResult(); if (searchResult.getCount() > 0) { - final StringBuilder messageBuilder = new StringBuilder("FlowNodes are still present: "); + final StringBuilder messageBuilder = new StringBuilder("FlowNodes were still present: "); for (final FlowNodeInstance flowNodeInstance : flowNodeInstances) { messageBuilder.append("{").append(flowNodeInstance.getName()).append(" - ") .append(flowNodeInstance.getType()).append("}").append(", "); @@ -273,7 +275,7 @@ public List checkNoArchivedFlowNodes() throws SearchException { .searchArchivedFlowNodeInstances(build.done()); final List archivedFlowNodeInstances = searchResult.getResult(); if (searchResult.getCount() > 0) { - final StringBuilder messageBuilder = new StringBuilder("Archived flowNodes are still present: "); + final StringBuilder messageBuilder = new StringBuilder("Archived flowNodes were still present: "); for (final ArchivedFlowNodeInstance archivedFlowNodeInstance : archivedFlowNodeInstances) { messageBuilder.append(archivedFlowNodeInstance.getName()).append(", "); } @@ -288,7 +290,7 @@ public List checkNoComments() throws SearchException { final SearchResult searchResult = getProcessAPI().searchComments(build.done()); final List comments = searchResult.getResult(); if (searchResult.getCount() > 0) { - final StringBuilder messageBuilder = new StringBuilder("Comments are still present: "); + final StringBuilder messageBuilder = new StringBuilder("Comments were still present: "); for (final Comment comment : comments) { messageBuilder.append(comment.getContent()).append(", "); } @@ -303,7 +305,7 @@ public List checkNoArchivedComments() throws SearchException { final SearchResult searchResult = getProcessAPI().searchArchivedComments(build.done()); final List archivedComments = searchResult.getResult(); if (searchResult.getCount() > 0) { - final StringBuilder messageBuilder = new StringBuilder("Archived comments are still present: "); + final StringBuilder messageBuilder = new StringBuilder("Archived comments were still present: "); for (final ArchivedComment archivedComment : archivedComments) { messageBuilder.append(archivedComment.getName()).append(", "); } @@ -317,7 +319,7 @@ public List checkNoProcessDefinitions() throws BonitaException { final List processes = getProcessAPI().getProcessDeploymentInfos(0, 200, ProcessDeploymentInfoCriterion.DEFAULT); if (processes.size() > 0) { - final StringBuilder processBuilder = new StringBuilder("Process Definitions are still active: "); + final StringBuilder processBuilder = new StringBuilder("Process Definitions were still active: "); for (final ProcessDeploymentInfo processDeploymentInfo : processes) { processBuilder.append(processDeploymentInfo.getId()).append(", "); if (ActivationState.ENABLED.equals(processDeploymentInfo.getActivationState())) { @@ -339,7 +341,8 @@ public List checkNoWaitingEvent() throws BonitaException { final List waitingEvents = ((SearchResult) getCommandAPI() .execute("searchWaitingEventsCommand", parameters)).getResult(); if (waitingEvents.size() > 0) { - final StringBuilder messageBuilder = new StringBuilder("Waiting Event are still present: "); + final StringBuilder messageBuilder = new StringBuilder( + "Waiting Events are still present (not deleted automatically): "); for (final WaitingEvent waitingEvent : waitingEvents) { messageBuilder.append("[process instance:").append(waitingEvent.getProcessName()) .append(", flow node instance:") @@ -359,7 +362,7 @@ public List checkNoSupervisors() throws SearchException, DeletionExcepti .getResult(); if (supervisors.size() > 0) { - final StringBuilder processBuilder = new StringBuilder("Process Supervisors are still active: "); + final StringBuilder processBuilder = new StringBuilder("Process Supervisors were still active: "); for (final ProcessSupervisor supervisor : supervisors) { processBuilder.append(supervisor.getSupervisorId()).append(", "); getProcessAPI().deleteSupervisor(supervisor.getSupervisorId()); @@ -369,12 +372,12 @@ public List checkNoSupervisors() throws SearchException, DeletionExcepti return messages; } - public List checkNoProcessIntances() throws DeletionException { + public List checkNoProcessInstances() throws DeletionException { final List messages = new ArrayList<>(); final List processInstances = getProcessAPI().getProcessInstances(0, 1000, ProcessInstanceCriterion.DEFAULT); if (!processInstances.isEmpty()) { - final StringBuilder stb = new StringBuilder("Process instances are still present: "); + final StringBuilder stb = new StringBuilder("Process instances were still present: "); for (final ProcessInstance processInstance : processInstances) { stb.append(processInstance).append(", "); getProcessAPI().deleteProcessInstance(processInstance.getId()); @@ -384,12 +387,12 @@ public List checkNoProcessIntances() throws DeletionException { return messages; } - public List checkNoArchivedProcessIntances() throws DeletionException { + public List checkNoArchivedProcessInstances() throws DeletionException { final List messages = new ArrayList<>(); final List archivedProcessInstances = getProcessAPI().getArchivedProcessInstances(0, 1000, ProcessInstanceCriterion.DEFAULT); if (!archivedProcessInstances.isEmpty()) { - final StringBuilder stb = new StringBuilder("Archived process instances are still present: "); + final StringBuilder stb = new StringBuilder("Archived process instances were still present: "); for (final ArchivedProcessInstance archivedProcessInstance : archivedProcessInstances) { stb.append(archivedProcessInstance).append(", "); getProcessAPI().deleteArchivedProcessInstancesInAllStates(archivedProcessInstance.getSourceObjectId()); @@ -405,7 +408,7 @@ public List checkNoGroups() throws DeletionException { if (numberOfGroups > 0) { final List groups = getIdentityAPI().getGroups(0, Long.valueOf(numberOfGroups).intValue(), GroupCriterion.NAME_ASC); - final StringBuilder groupBuilder = new StringBuilder("Groups are still present: "); + final StringBuilder groupBuilder = new StringBuilder("Groups were still present: "); for (final Group group : groups) { groupBuilder.append(group.getId()).append(", "); getIdentityAPI().deleteGroup(group.getId()); @@ -421,7 +424,7 @@ public List checkNoRoles() throws DeletionException { if (numberOfRoles > 0) { final List roles = getIdentityAPI().getRoles(0, Long.valueOf(numberOfRoles).intValue(), RoleCriterion.NAME_ASC); - final StringBuilder roleBuilder = new StringBuilder("Roles are still present: "); + final StringBuilder roleBuilder = new StringBuilder("Roles were still present: "); for (final Role role : roles) { roleBuilder.append(role.getId()).append(", "); getIdentityAPI().deleteRole(role.getId()); @@ -437,7 +440,7 @@ public List checkNoUsers() throws DeletionException { if (numberOfUsers > 0) { final List users = getIdentityAPI().getUsers(0, Long.valueOf(numberOfUsers).intValue(), UserCriterion.USER_NAME_ASC); - final StringBuilder userBuilder = new StringBuilder("Users are still present: "); + final StringBuilder userBuilder = new StringBuilder("Users were still present: "); for (final User user : users) { userBuilder.append(user.getId()).append(", "); getIdentityAPI().deleteUser(user.getId()); @@ -457,7 +460,7 @@ public List checkNoCommands() throws SearchException, CommandNotFoundExc .searchCommands(searchOptionsBuilder.done()); final List commands = searchCommands.getResult(); if (searchCommands.getCount() > 0) { - final StringBuilder commandBuilder = new StringBuilder("Commands are still present: "); + final StringBuilder commandBuilder = new StringBuilder("Commands were still present: "); for (final CommandDescriptor command : commands) { commandBuilder.append(command.getName()).append(", "); getCommandAPI().unregister(command.getName());