From eacc96640d7bf5e51710f3b6c70dc77c511daf63 Mon Sep 17 00:00:00 2001 From: Romain Bioteau Date: Fri, 25 Oct 2024 11:00:23 +0200 Subject: [PATCH] fix(deps): update mockito (#3222) * fix(deps): update mockito * refactor(test): migrate ApplicationInstallerExtTest to JUnit5 * chore(web-server): include junit engines * test dep declaration --- .../data/ContractDataServiceImplTest.java | 4 +- .../form/impl/FormMappingServiceImplTest.java | 2 +- .../engine/home/BonitaHomeServerTest.java | 8 ++-- ...terBusinessArchiveArtifactManagerTest.java | 4 +- .../bdm/internal/EntityMergerTest.java | 4 +- .../process/DisableProcessTest.java | 4 +- .../ContractStructureValidatorTest.java | 2 +- .../data/BusinessDataRetrieverTest.java | 14 +++--- .../WaitingEventsInterrupterTest.java | 6 +-- .../TransitionConditionEvaluatorTest.java | 6 +-- ...essDataExpressionExecutorStrategyTest.java | 6 +-- ...ferenceExpressionExecutorStrategyTest.java | 4 +- ...ferenceExpressionExecutorStrategyTest.java | 2 +- .../engine/platform/PlatformManagerTest.java | 8 ++-- bpm/bonita-web-server/build.gradle | 8 +++- .../server/filter/SanitizerFilterTest.java | 43 +++++++++++-------- .../bdm/BusinessDataQueryResourceTest.java | 3 +- .../UserTaskExecutionResourceTest.java | 12 +++--- .../ProcessInstantiationResourceTest.java | 11 ++--- .../api/resource/CommonResourceTest.java | 2 +- .../engineclient/ProcessEngineClientTest.java | 3 +- gradle/libs.versions.toml | 4 +- .../impl/ApplicationServiceImplTest.java | 4 +- .../dao/client/resources/proxy/ProxyTest.java | 6 +-- .../data/impl/BusinessDataReloaderTest.java | 4 +- .../classloader/ClassLoaderUpdaterTest.java | 4 +- ...RefreshClassloaderSynchronizationTest.java | 4 +- .../impl/IdentityServiceImplForUserTest.java | 2 +- ...iExtensionPageServiceListenerImplTest.java | 8 ++-- .../engine/page/impl/PageServiceImplTest.java | 1 - .../impl/SPageMappingServiceImplTest.java | 4 +- .../TenantResourcesServiceImplTest.java | 4 +- .../scheduler/impl/JDBCJobListenerTest.java | 6 +-- .../JobServiceImplForJobDescriptorTest.java | 2 +- .../impl/JobServiceImplForJobLogTest.java | 2 +- .../work/RetryingWorkExecutorServiceTest.java | 2 +- 36 files changed, 113 insertions(+), 100 deletions(-) diff --git a/bpm/bonita-core/bonita-contract-data/src/test/java/org/bonitasoft/engine/core/contract/data/ContractDataServiceImplTest.java b/bpm/bonita-core/bonita-contract-data/src/test/java/org/bonitasoft/engine/core/contract/data/ContractDataServiceImplTest.java index 21522a3f62c..cf402fe33b2 100644 --- a/bpm/bonita-core/bonita-contract-data/src/test/java/org/bonitasoft/engine/core/contract/data/ContractDataServiceImplTest.java +++ b/bpm/bonita-core/bonita-contract-data/src/test/java/org/bonitasoft/engine/core/contract/data/ContractDataServiceImplTest.java @@ -202,7 +202,7 @@ public void archiveUserTaskData_should_not_create_archive_data_if_no_data_define contractDataService.archiveAndDeleteUserTaskData(usertTaskId, time); - verifyZeroInteractions(archiveService); + verifyNoInteractions(archiveService); } @Test(expected = SObjectModificationException.class) @@ -360,7 +360,7 @@ public void archiveProcessData_should_not_create_archive_data_if_no_data_defined contractDataService.archiveAndDeleteProcessData(usertProcessId, time); - verifyZeroInteractions(archiveService); + verifyNoInteractions(archiveService); } @Test(expected = SObjectModificationException.class) diff --git a/bpm/bonita-core/bonita-form-mapping/src/test/java/org/bonitasoft/engine/core/form/impl/FormMappingServiceImplTest.java b/bpm/bonita-core/bonita-form-mapping/src/test/java/org/bonitasoft/engine/core/form/impl/FormMappingServiceImplTest.java index 36a72020816..b776bce288e 100644 --- a/bpm/bonita-core/bonita-form-mapping/src/test/java/org/bonitasoft/engine/core/form/impl/FormMappingServiceImplTest.java +++ b/bpm/bonita-core/bonita-form-mapping/src/test/java/org/bonitasoft/engine/core/form/impl/FormMappingServiceImplTest.java @@ -103,7 +103,7 @@ public void createFormMappingWithUndefinedTargetShouldNotAddPageMapping() throws formMappingService.create(PROCESS_DEFINITION_ID, "someHumanTask", 84, SFormMapping.TARGET_UNDEFINED, null); - verifyZeroInteractions(pageMappingService); + verifyNoInteractions(pageMappingService); } @Test diff --git a/bpm/bonita-core/bonita-home-server/src/test/java/org/bonitasoft/engine/home/BonitaHomeServerTest.java b/bpm/bonita-core/bonita-home-server/src/test/java/org/bonitasoft/engine/home/BonitaHomeServerTest.java index 821489846d9..a33189678e9 100644 --- a/bpm/bonita-core/bonita-home-server/src/test/java/org/bonitasoft/engine/home/BonitaHomeServerTest.java +++ b/bpm/bonita-core/bonita-home-server/src/test/java/org/bonitasoft/engine/home/BonitaHomeServerTest.java @@ -15,6 +15,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.entry; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.verify; @@ -40,7 +41,6 @@ import org.junit.Test; import org.junit.rules.TemporaryFolder; import org.junit.runner.RunWith; -import org.mockito.ArgumentMatchers; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Spy; @@ -103,20 +103,20 @@ private BonitaConfiguration conf(String file1, byte[] bytes) { } @Test - public void should_context_have_properties_overriden_with_database_properties() throws Exception { + public void should_context_have_properties_overridden_with_database_properties() throws Exception { //given Properties databaseProperties = new Properties(); databaseProperties.setProperty("overriddenProperty", "databaseValue"); databaseProperties.setProperty("databaseProperty", "aValueInDb"); ByteArrayOutputStream out = new ByteArrayOutputStream(); databaseProperties.store(out, ""); - doReturn(Collections.singletonList(new BonitaConfiguration("myProp.properties", out.toByteArray()))) + doReturn(List.of(new BonitaConfiguration("myProp.properties", out.toByteArray()))) .when(configurationService).getPlatformEngineConf(); Properties classPathProperties = new Properties(); classPathProperties.setProperty("overriddenProperty", "classPathValue"); classPathProperties.setProperty("classPathProperty", "aValueInClassPath"); doReturn(classPathProperties).when(bonitaHomeServer) - .getPropertiesFromClassPath(ArgumentMatchers. any()); + .getPropertiesFromClassPath(any(String[].class)); //when Properties allProperties = bonitaHomeServer.getPlatformProperties(); //then diff --git a/bpm/bonita-core/bonita-process-engine/src/test/java/org/bonitasoft/engine/api/impl/resolver/ParameterBusinessArchiveArtifactManagerTest.java b/bpm/bonita-core/bonita-process-engine/src/test/java/org/bonitasoft/engine/api/impl/resolver/ParameterBusinessArchiveArtifactManagerTest.java index ee295956adf..954d12fb5ea 100644 --- a/bpm/bonita-core/bonita-process-engine/src/test/java/org/bonitasoft/engine/api/impl/resolver/ParameterBusinessArchiveArtifactManagerTest.java +++ b/bpm/bonita-core/bonita-process-engine/src/test/java/org/bonitasoft/engine/api/impl/resolver/ParameterBusinessArchiveArtifactManagerTest.java @@ -16,7 +16,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoInteractions; import java.util.Collections; import java.util.HashMap; @@ -95,7 +95,7 @@ public void should_resolve_process_if_no_defined_parameters_in_process() throws // then: assertThat(deployed).isTrue(); - verifyZeroInteractions(parameterService); + verifyNoInteractions(parameterService); } @Test diff --git a/bpm/bonita-core/bonita-process-engine/src/test/java/org/bonitasoft/engine/api/impl/transaction/expression/bdm/internal/EntityMergerTest.java b/bpm/bonita-core/bonita-process-engine/src/test/java/org/bonitasoft/engine/api/impl/transaction/expression/bdm/internal/EntityMergerTest.java index a0af63e1aad..aa7e598103e 100644 --- a/bpm/bonita-core/bonita-process-engine/src/test/java/org/bonitasoft/engine/api/impl/transaction/expression/bdm/internal/EntityMergerTest.java +++ b/bpm/bonita-core/bonita-process-engine/src/test/java/org/bonitasoft/engine/api/impl/transaction/expression/bdm/internal/EntityMergerTest.java @@ -68,7 +68,7 @@ public void merge_a_collection_of_entity_should_not_call_merge_on_bdrService_for public void merge_a_simple_serializable_should_not_call_merge_on_bdrService() { final String hello = "Hello"; assertThat(entityMerger.merge("Hello")).isEqualTo(hello); - verifyZeroInteractions(bdrService); + verifyNoInteractions(bdrService); } @Test @@ -78,7 +78,7 @@ public void merge_a_collection_of_simple_serializable_should_not_call_merge_on_b listOfEntities.add("Goodbye"); listOfEntities.add("Have a nice day"); entityMerger.merge((Serializable) listOfEntities); - verifyZeroInteractions(bdrService); + verifyNoInteractions(bdrService); } } diff --git a/bpm/bonita-core/bonita-process-engine/src/test/java/org/bonitasoft/engine/api/impl/transaction/process/DisableProcessTest.java b/bpm/bonita-core/bonita-process-engine/src/test/java/org/bonitasoft/engine/api/impl/transaction/process/DisableProcessTest.java index c7e5c0564f6..85a09efb79f 100644 --- a/bpm/bonita-core/bonita-process-engine/src/test/java/org/bonitasoft/engine/api/impl/transaction/process/DisableProcessTest.java +++ b/bpm/bonita-core/bonita-process-engine/src/test/java/org/bonitasoft/engine/api/impl/transaction/process/DisableProcessTest.java @@ -13,7 +13,7 @@ **/ package org.bonitasoft.engine.api.impl.transaction.process; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoInteractions; import static org.mockito.Mockito.when; import java.util.ArrayList; @@ -59,7 +59,7 @@ public void execute_should_not_clean_the_classLoader_due_to_its_use_for_running_ disableProcess.execute(); - verifyZeroInteractions(classLoaderService); + verifyNoInteractions(classLoaderService); } } diff --git a/bpm/bonita-core/bonita-process-engine/src/test/java/org/bonitasoft/engine/bpm/contract/validation/ContractStructureValidatorTest.java b/bpm/bonita-core/bonita-process-engine/src/test/java/org/bonitasoft/engine/bpm/contract/validation/ContractStructureValidatorTest.java index e20c5f8f365..58e37f21510 100644 --- a/bpm/bonita-core/bonita-process-engine/src/test/java/org/bonitasoft/engine/bpm/contract/validation/ContractStructureValidatorTest.java +++ b/bpm/bonita-core/bonita-process-engine/src/test/java/org/bonitasoft/engine/bpm/contract/validation/ContractStructureValidatorTest.java @@ -214,7 +214,7 @@ public void should_not_check_children_when_complex_input_is_null() throws Except public void should_not_check_type_validation_when_input_is_null() throws Exception { final SContractDefinition contract = aContract().withInput(aSimpleInput(TEXT).withName("someNullText")).build(); validator.validate(contract, Collections. singletonMap("someNullText", null)); - verifyZeroInteractions(typeValidator); + verifyNoInteractions(typeValidator); } @Test diff --git a/bpm/bonita-core/bonita-process-engine/src/test/java/org/bonitasoft/engine/business/data/BusinessDataRetrieverTest.java b/bpm/bonita-core/bonita-process-engine/src/test/java/org/bonitasoft/engine/business/data/BusinessDataRetrieverTest.java index f08b04f0a80..2977080c86a 100644 --- a/bpm/bonita-core/bonita-process-engine/src/test/java/org/bonitasoft/engine/business/data/BusinessDataRetrieverTest.java +++ b/bpm/bonita-core/bonita-process-engine/src/test/java/org/bonitasoft/engine/business/data/BusinessDataRetrieverTest.java @@ -18,7 +18,7 @@ import static org.bonitasoft.engine.business.data.DummyBusinessDataRefBuilder.buildSimpleRefBusinessData; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoInteractions; import java.util.ArrayList; import java.util.Arrays; @@ -79,8 +79,8 @@ public void getSimpleBusinessData_should_return_null_when_ref_business_data_does //then assertThat(retrievedEntity).isNull(); - verifyZeroInteractions(repository); - verifyZeroInteractions(proxyfier); + verifyNoInteractions(repository); + verifyNoInteractions(proxyfier); } @Test @@ -111,8 +111,8 @@ public void getMultiBusinessData_should_return_empty_list_when_multi_ref_data_do //then assertThat(retrievedEntities).isEmpty(); - verifyZeroInteractions(repository); - verifyZeroInteractions(proxyfier); + verifyNoInteractions(repository); + verifyNoInteractions(proxyfier); } @Test @@ -128,8 +128,8 @@ public void getMultiBusinessData_should_return_empty_Array_list_when_multi_ref_d retrievedEntities.add(new Employee()); // no exceptions - verifyZeroInteractions(repository); - verifyZeroInteractions(proxyfier); + verifyNoInteractions(repository); + verifyNoInteractions(proxyfier); } @Test diff --git a/bpm/bonita-core/bonita-process-engine/src/test/java/org/bonitasoft/engine/execution/WaitingEventsInterrupterTest.java b/bpm/bonita-core/bonita-process-engine/src/test/java/org/bonitasoft/engine/execution/WaitingEventsInterrupterTest.java index 0bd0290d500..55a707d0927 100644 --- a/bpm/bonita-core/bonita-process-engine/src/test/java/org/bonitasoft/engine/execution/WaitingEventsInterrupterTest.java +++ b/bpm/bonita-core/bonita-process-engine/src/test/java/org/bonitasoft/engine/execution/WaitingEventsInterrupterTest.java @@ -15,7 +15,7 @@ import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoInteractions; import java.util.Optional; @@ -86,8 +86,8 @@ public void should_not_delete_timer_and_event_trigger_when_catch_is_not_a_timer( waitingEventsInterrupter.interruptWaitingEvents(processDefinition, catchEventInstance, catchEventDefinition); - verifyZeroInteractions(eventInstanceService); - verifyZeroInteractions(schedulerService); + verifyNoInteractions(eventInstanceService); + verifyNoInteractions(schedulerService); } } diff --git a/bpm/bonita-core/bonita-process-engine/src/test/java/org/bonitasoft/engine/execution/transition/TransitionConditionEvaluatorTest.java b/bpm/bonita-core/bonita-process-engine/src/test/java/org/bonitasoft/engine/execution/transition/TransitionConditionEvaluatorTest.java index cde5529ad43..70a3d23b35e 100644 --- a/bpm/bonita-core/bonita-process-engine/src/test/java/org/bonitasoft/engine/execution/transition/TransitionConditionEvaluatorTest.java +++ b/bpm/bonita-core/bonita-process-engine/src/test/java/org/bonitasoft/engine/execution/transition/TransitionConditionEvaluatorTest.java @@ -17,7 +17,7 @@ import static org.assertj.core.api.Assertions.fail; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoInteractions; import java.util.Collections; @@ -71,7 +71,7 @@ public void evaluateCondition_should_return_null_when_there_is_no_condition() th //then assertThat(value).isNull(); - verifyZeroInteractions(expressionResolverService); + verifyNoInteractions(expressionResolverService); } @Test @@ -94,7 +94,7 @@ public void evaluateCondition_should_throw_SExpressionEvaluationException_when_e .isEqualTo("Condition expression must return a boolean, on transition: " + transition.getName()); assertThat(e.getExpressionName()).isEqualTo("isTrue"); - verifyZeroInteractions(expressionResolverService); + verifyNoInteractions(expressionResolverService); } } diff --git a/bpm/bonita-core/bonita-process-engine/src/test/java/org/bonitasoft/engine/expression/BusinessDataExpressionExecutorStrategyTest.java b/bpm/bonita-core/bonita-process-engine/src/test/java/org/bonitasoft/engine/expression/BusinessDataExpressionExecutorStrategyTest.java index 63d7d92aa8d..81d1f4a50e9 100644 --- a/bpm/bonita-core/bonita-process-engine/src/test/java/org/bonitasoft/engine/expression/BusinessDataExpressionExecutorStrategyTest.java +++ b/bpm/bonita-core/bonita-process-engine/src/test/java/org/bonitasoft/engine/expression/BusinessDataExpressionExecutorStrategyTest.java @@ -27,7 +27,7 @@ import static org.mockito.Mockito.nullable; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoInteractions; import static org.mockito.Mockito.when; import java.util.Arrays; @@ -233,8 +233,8 @@ public void evaluate_should_first_check_if_expression_already_evaluated_and_avai context, null, ContainerState.ACTIVE); assertThat(fetchedBizData).isEqualTo(expectedBizData); - verifyZeroInteractions(businessDataRetriever); - verifyZeroInteractions(refBusinessDataRetriever); + verifyNoInteractions(businessDataRetriever); + verifyNoInteractions(refBusinessDataRetriever); } @Test diff --git a/bpm/bonita-core/bonita-process-engine/src/test/java/org/bonitasoft/engine/expression/DocumentListReferenceExpressionExecutorStrategyTest.java b/bpm/bonita-core/bonita-process-engine/src/test/java/org/bonitasoft/engine/expression/DocumentListReferenceExpressionExecutorStrategyTest.java index d83ed7d65f5..a458e627ae1 100644 --- a/bpm/bonita-core/bonita-process-engine/src/test/java/org/bonitasoft/engine/expression/DocumentListReferenceExpressionExecutorStrategyTest.java +++ b/bpm/bonita-core/bonita-process-engine/src/test/java/org/bonitasoft/engine/expression/DocumentListReferenceExpressionExecutorStrategyTest.java @@ -80,7 +80,7 @@ public void evaluate_result_should_retrieve_documents_list_when_it_is_not_alread //then: assertThat(result).hasSize(1).containsOnly(expectedDocumentList); - verifyZeroInteractions(activityInstanceService); + verifyNoInteractions(activityInstanceService); } @Test @@ -100,7 +100,7 @@ public void evaluate_should_directly_return_the_documents_list_when_it_is_alread //then: assertThat(result).isSameAs(documentListInContext); - verifyZeroInteractions(documentService); + verifyNoInteractions(documentService); } // ================================================================================================================= diff --git a/bpm/bonita-core/bonita-process-engine/src/test/java/org/bonitasoft/engine/expression/DocumentReferenceExpressionExecutorStrategyTest.java b/bpm/bonita-core/bonita-process-engine/src/test/java/org/bonitasoft/engine/expression/DocumentReferenceExpressionExecutorStrategyTest.java index d971ac05fd4..aa926db5cc7 100644 --- a/bpm/bonita-core/bonita-process-engine/src/test/java/org/bonitasoft/engine/expression/DocumentReferenceExpressionExecutorStrategyTest.java +++ b/bpm/bonita-core/bonita-process-engine/src/test/java/org/bonitasoft/engine/expression/DocumentReferenceExpressionExecutorStrategyTest.java @@ -174,7 +174,7 @@ public void evaluate_should_directly_return_the_document_when_it_is_already_in_t //then: assertThat(result).isSameAs(docInContext); - verifyZeroInteractions(documentService); + verifyNoInteractions(documentService); } @Test diff --git a/bpm/bonita-core/bonita-process-engine/src/test/java/org/bonitasoft/engine/platform/PlatformManagerTest.java b/bpm/bonita-core/bonita-process-engine/src/test/java/org/bonitasoft/engine/platform/PlatformManagerTest.java index ac56b589423..de29311f807 100644 --- a/bpm/bonita-core/bonita-process-engine/src/test/java/org/bonitasoft/engine/platform/PlatformManagerTest.java +++ b/bpm/bonita-core/bonita-process-engine/src/test/java/org/bonitasoft/engine/platform/PlatformManagerTest.java @@ -123,8 +123,8 @@ public void should_start_platform_only_once() throws Exception { boolean started = platformManager.start(); - verifyZeroInteractions(platformLifecycleService1); - verifyZeroInteractions(platformLifecycleService2); + verifyNoInteractions(platformLifecycleService1); + verifyNoInteractions(platformLifecycleService2); verify(platformStateProvider, never()).setStarted(); assertThat(started).isFalse(); } @@ -147,8 +147,8 @@ public void should_stop_platform_only_once() throws Exception { boolean stopped = platformManager.stop(); - verifyZeroInteractions(platformLifecycleService1); - verifyZeroInteractions(platformLifecycleService2); + verifyNoInteractions(platformLifecycleService1); + verifyNoInteractions(platformLifecycleService2); verify(platformStateProvider, never()).setStopped(); assertThat(stopped).isFalse(); } diff --git a/bpm/bonita-web-server/build.gradle b/bpm/bonita-web-server/build.gradle index 1921aa8b5a8..1de54f512ca 100644 --- a/bpm/bonita-web-server/build.gradle +++ b/bpm/bonita-web-server/build.gradle @@ -48,9 +48,12 @@ dependencies { testImplementation libs.logback testImplementation libs.springTest testImplementation libs.systemRules - testImplementation libs.mockitoCore + testImplementation libs.mockitoJunitJupiter testImplementation libs.hamcrest testImplementation libs.junit4 + testImplementation libs.junit5api + testRuntimeOnly libs.junitJupiterEngine + testRuntimeOnly libs.junitVintageEngine } configurations { @@ -90,6 +93,9 @@ tasks.named("build") { tasks.named("test") { dependsOn tasks.named("testsJar") + useJUnitPlatform { + includeEngines 'junit-jupiter', 'junit-vintage' + } } tasks.register('testsJar', Jar) { diff --git a/bpm/bonita-web-server/src/test/java/org/bonitasoft/console/common/server/filter/SanitizerFilterTest.java b/bpm/bonita-web-server/src/test/java/org/bonitasoft/console/common/server/filter/SanitizerFilterTest.java index fc13eeb8fdf..98e9bbaf38e 100644 --- a/bpm/bonita-web-server/src/test/java/org/bonitasoft/console/common/server/filter/SanitizerFilterTest.java +++ b/bpm/bonita-web-server/src/test/java/org/bonitasoft/console/common/server/filter/SanitizerFilterTest.java @@ -14,16 +14,21 @@ package org.bonitasoft.console.common.server.filter; import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Matchers.any; import static org.mockito.Mockito.*; -import static org.mockito.MockitoAnnotations.initMocks; +import static org.mockito.quality.Strictness.LENIENT; import java.io.ByteArrayInputStream; import java.io.IOException; import java.util.Collections; import java.util.List; -import javax.servlet.*; +import javax.servlet.FilterChain; +import javax.servlet.FilterConfig; +import javax.servlet.ReadListener; +import javax.servlet.ServletContext; +import javax.servlet.ServletInputStream; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; @@ -33,18 +38,23 @@ import org.apache.commons.io.IOUtils; import org.bonitasoft.console.common.server.login.HttpServletRequestAccessor; import org.bonitasoft.web.toolkit.client.common.json.JSonUtil; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.ArgumentCaptor; import org.mockito.Mock; import org.mockito.Spy; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; /** * Test class SanitizerFilter * * @author Vincent Hemery */ -public class SanitizerFilterTest { +@ExtendWith(MockitoExtension.class) +@MockitoSettings(strictness = LENIENT) +class SanitizerFilterTest { @Mock private FilterChain chain; @@ -70,9 +80,8 @@ public class SanitizerFilterTest { @Spy SanitizerFilter sanitizerFilter; - @Before - public void setUp() throws Exception { - initMocks(this); + @BeforeEach + void setUp() { doReturn(httpSession).when(request).getHttpSession(); when(request.asHttpServletRequest()).thenReturn(httpRequest); when(httpRequest.getMethod()).thenReturn("POST"); @@ -84,7 +93,7 @@ public void setUp() throws Exception { } @Test - public void shouldNotSanitizeWhenDisabled() throws Exception { + void shouldNotSanitizeWhenDisabled() throws Exception { when(httpRequest.getContentType()).thenReturn("application/json"); when(sanitizerFilter.isSanitizerEnabled()).thenReturn(false); @@ -96,7 +105,7 @@ public void shouldNotSanitizeWhenDisabled() throws Exception { } @Test - public void shouldNotAffectAttributeValue() throws Exception { + void shouldNotAffectAttributeValue() throws Exception { when(httpRequest.getContentType()).thenReturn("application/json"); when(sanitizerFilter.isSanitizerEnabled()).thenReturn(true); final String attributeName = "key"; @@ -115,7 +124,7 @@ public void shouldNotAffectAttributeValue() throws Exception { } @Test - public void shouldNotAffectParameterValues() throws Exception { + void shouldNotAffectParameterValues() throws Exception { when(httpRequest.getContentType()).thenReturn("application/json"); when(sanitizerFilter.isSanitizerEnabled()).thenReturn(true); final String parameterName = "key"; @@ -134,7 +143,7 @@ public void shouldNotAffectParameterValues() throws Exception { } @Test - public void shouldNotAffectFileUpload() throws Exception { + void shouldNotAffectFileUpload() throws Exception { when(httpRequest.getContentType()).thenReturn("text/xml"); when(sanitizerFilter.isSanitizerEnabled()).thenReturn(true); final String body = String.format("%n" + @@ -159,7 +168,7 @@ public void shouldNotAffectFileUpload() throws Exception { } @Test - public void shouldNotAffectNonHtml() throws Exception { + void shouldNotAffectNonHtml() throws Exception { when(httpRequest.getContentType()).thenReturn("application/json"); when(sanitizerFilter.isSanitizerEnabled()).thenReturn(true); when(sanitizerFilter.getAttributesExcluded()).thenReturn(Collections.emptyList()); @@ -180,7 +189,7 @@ public void shouldNotAffectNonHtml() throws Exception { } @Test - public void shouldNotAffectPre() throws Exception { + void shouldNotAffectPre() throws Exception { when(httpRequest.getContentType()).thenReturn("application/json"); when(sanitizerFilter.isSanitizerEnabled()).thenReturn(true); when(sanitizerFilter.getAttributesExcluded()).thenReturn(Collections.emptyList()); @@ -201,7 +210,7 @@ public void shouldNotAffectPre() throws Exception { } @Test - public void shouldNotAffectLinks() throws Exception { + void shouldNotAffectLinks() throws Exception { when(httpRequest.getContentType()).thenReturn("application/json"); when(sanitizerFilter.isSanitizerEnabled()).thenReturn(true); when(sanitizerFilter.getAttributesExcluded()).thenReturn(Collections.emptyList()); @@ -223,7 +232,7 @@ public void shouldNotAffectLinks() throws Exception { } @Test - public void shouldSanitizeAttackFromBody() throws Exception { + void shouldSanitizeAttackFromBody() throws Exception { when(httpRequest.getContentType()).thenReturn("application/JSON"); when(sanitizerFilter.isSanitizerEnabled()).thenReturn(true); when(sanitizerFilter.getAttributesExcluded()).thenReturn(List.of("email", "password")); diff --git a/bpm/bonita-web-server/src/test/java/org/bonitasoft/web/rest/server/api/bdm/BusinessDataQueryResourceTest.java b/bpm/bonita-web-server/src/test/java/org/bonitasoft/web/rest/server/api/bdm/BusinessDataQueryResourceTest.java index fd6f13f108a..2404c2c17dc 100644 --- a/bpm/bonita-web-server/src/test/java/org/bonitasoft/web/rest/server/api/bdm/BusinessDataQueryResourceTest.java +++ b/bpm/bonita-web-server/src/test/java/org/bonitasoft/web/rest/server/api/bdm/BusinessDataQueryResourceTest.java @@ -15,7 +15,6 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.anyMap; -import static org.mockito.ArgumentMatchers.anyMapOf; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.when; @@ -83,7 +82,7 @@ public Serializable answer(final InvocationOnMock invocation) throws Throwable { return new BusinessDataQueryResultImpl(JSON_RESPONSE, new BusinessDataQueryMetadataImpl(1, 2, 4L)); } }; - when(commandAPI.execute(anyString(), anyMapOf(String.class, Serializable.class))).then(answer); + when(commandAPI.execute(anyString(), anyMap())).then(answer); //then Conditions modifiedSinceConditions = new Conditions(); diff --git a/bpm/bonita-web-server/src/test/java/org/bonitasoft/web/rest/server/api/bpm/flownode/UserTaskExecutionResourceTest.java b/bpm/bonita-web-server/src/test/java/org/bonitasoft/web/rest/server/api/bpm/flownode/UserTaskExecutionResourceTest.java index e52803d8b24..22fa2a40fd9 100644 --- a/bpm/bonita-web-server/src/test/java/org/bonitasoft/web/rest/server/api/bpm/flownode/UserTaskExecutionResourceTest.java +++ b/bpm/bonita-web-server/src/test/java/org/bonitasoft/web/rest/server/api/bpm/flownode/UserTaskExecutionResourceTest.java @@ -17,9 +17,9 @@ import static java.util.Collections.emptyList; import static org.assertj.core.api.Assertions.assertThat; import static org.bonitasoft.web.rest.server.utils.ResponseAssert.assertThat; -import static org.mockito.ArgumentMatchers.*; +import static org.mockito.ArgumentMatchers.anyLong; +import static org.mockito.ArgumentMatchers.anyMap; import static org.mockito.Mockito.*; -import static org.mockito.Mockito.verify; import java.io.FileNotFoundException; import java.io.Serializable; @@ -139,7 +139,7 @@ public void should_respond_400_Bad_request_when_contract_is_not_validated_when_e doThrow(new ContractViolationException("aMessage", "aMessage", asList("first explanation", "second explanation"), null)) .when(processAPI) - .executeUserTask(anyLong(), anyLong(), anyMapOf(String.class, Serializable.class)); + .executeUserTask(anyLong(), anyLong(), anyMap()); final Response response = request("/bpm/userTask/2/execution").post(VALID_POST_BODY); @@ -153,7 +153,7 @@ public void should_respond_400_Bad_request_when_contract_is_not_validated_when_e @Test public void should_respond_500_Internal_server_error_when_error_occurs_on_task_execution() throws Exception { doThrow(new FlowNodeExecutionException("aMessage")) - .when(processAPI).executeUserTask(anyLong(), anyLong(), anyMapOf(String.class, Serializable.class)); + .when(processAPI).executeUserTask(anyLong(), anyLong(), anyMap()); final Response response = request("/bpm/userTask/2/execution").post(VALID_POST_BODY); @@ -175,7 +175,7 @@ public void should_respond_400_Bad_request_when_trying_to_execute_with_not_json_ public void should_respond_404_Not_found_when_task_is_not_found_when_trying_to_execute_it() throws Exception { when(processAPI.getUserTaskContract(2)).thenReturn(contractDefinition); doThrow(new UserTaskNotFoundException("task not found")).when(processAPI) - .executeUserTask(anyLong(), anyLong(), anyMapOf(String.class, Serializable.class)); + .executeUserTask(anyLong(), anyLong(), anyMap()); final Response response = request("/bpm/userTask/2/execution").post(VALID_POST_BODY); @@ -189,7 +189,7 @@ public void should_contract_violation_exception_log_explanations_when_logger_is_ final String message = "contract violation !!!!"; final List explanations = Arrays.asList("explanation1", "explanation2"); doThrow(new ContractViolationException(message, message, explanations, null)).when(processAPI) - .executeUserTask(anyLong(), anyLong(), anyMapOf(String.class, Serializable.class)); + .executeUserTask(anyLong(), anyLong(), anyMap()); when(processAPI.getUserTaskContract(1L)).thenReturn(contractDefinition); doReturn(1L).when(userTaskExecutionResource).getTaskIdParameter(); doReturn(response).when(userTaskExecutionResource).getResponse(); diff --git a/bpm/bonita-web-server/src/test/java/org/bonitasoft/web/rest/server/api/bpm/process/ProcessInstantiationResourceTest.java b/bpm/bonita-web-server/src/test/java/org/bonitasoft/web/rest/server/api/bpm/process/ProcessInstantiationResourceTest.java index 5ca9966d28a..0e50f34c079 100644 --- a/bpm/bonita-web-server/src/test/java/org/bonitasoft/web/rest/server/api/bpm/process/ProcessInstantiationResourceTest.java +++ b/bpm/bonita-web-server/src/test/java/org/bonitasoft/web/rest/server/api/bpm/process/ProcessInstantiationResourceTest.java @@ -16,7 +16,8 @@ import static java.util.Arrays.asList; import static org.assertj.core.api.Assertions.assertThat; import static org.bonitasoft.web.rest.server.utils.ResponseAssert.assertThat; -import static org.mockito.ArgumentMatchers.*; +import static org.mockito.ArgumentMatchers.anyLong; +import static org.mockito.ArgumentMatchers.anyMap; import static org.mockito.Mockito.*; import java.io.FileNotFoundException; @@ -159,7 +160,7 @@ public void should_respond_400_Bad_request_when_contract_is_not_validated_when_i throws Exception { doThrow(new ContractViolationException("aMessage", "aMessage", asList("first explanation", "second explanation"), null)) - .when(processAPI).startProcessWithInputs(anyLong(), anyMapOf(String.class, Serializable.class)); + .when(processAPI).startProcessWithInputs(anyLong(), anyMap()); when(processAPI.getProcessContract(PROCESS_DEFINITION_ID)).thenReturn(contractDefinition); final Response response = request(URL_API_PROCESS_INSTANTIATION_TEST).post(VALID_POST_BODY); @@ -174,7 +175,7 @@ public void should_respond_400_Bad_request_when_contract_is_not_validated_when_i @Test public void should_respond_500_Internal_server_error_when_error_occurs_on_process_instanciation() throws Exception { doThrow(new ProcessExecutionException("aMessage")) - .when(processAPI).startProcessWithInputs(anyLong(), anyMapOf(String.class, Serializable.class)); + .when(processAPI).startProcessWithInputs(anyLong(), anyMap()); final Response response = request(URL_API_PROCESS_INSTANTIATION_TEST).post(VALID_POST_BODY); @@ -195,7 +196,7 @@ public void should_respond_400_Bad_request_when_trying_to_execute_with_not_json_ @Test public void should_respond_404_Not_found_when_task_is_not_found_when_trying_to_execute_it() throws Exception { doThrow(new ProcessDefinitionNotFoundException("process not found")).when(processAPI) - .startProcessWithInputs(anyLong(), anyMapOf(String.class, Serializable.class)); + .startProcessWithInputs(anyLong(), anyMap()); when(processAPI.getProcessContract(PROCESS_DEFINITION_ID)).thenReturn(contractDefinition); final Response response = request(URL_API_PROCESS_INSTANTIATION_TEST).post(VALID_POST_BODY); @@ -209,7 +210,7 @@ public void should_contract_violation_exception_log_explanations_when_logger_is_ final String message = "contract violation !!!!"; final List explanations = Arrays.asList("explanation1", "explanation2"); doThrow(new ContractViolationException(message, message, explanations, null)).when(processAPI) - .startProcessWithInputs(anyLong(), anyMapOf(String.class, Serializable.class)); + .startProcessWithInputs(anyLong(), anyMap()); doReturn(Long.toString(PROCESS_DEFINITION_ID)).when(processInstantiationResource) .getAttribute(ProcessInstantiationResource.PROCESS_DEFINITION_ID); doReturn(contractDefinition).when(processAPI).getProcessContract(PROCESS_DEFINITION_ID); diff --git a/bpm/bonita-web-server/src/test/java/org/bonitasoft/web/rest/server/api/resource/CommonResourceTest.java b/bpm/bonita-web-server/src/test/java/org/bonitasoft/web/rest/server/api/resource/CommonResourceTest.java index 509d681a591..438cd3a887e 100644 --- a/bpm/bonita-web-server/src/test/java/org/bonitasoft/web/rest/server/api/resource/CommonResourceTest.java +++ b/bpm/bonita-web-server/src/test/java/org/bonitasoft/web/rest/server/api/resource/CommonResourceTest.java @@ -78,7 +78,7 @@ public void getParameterShouldVerifyNotNullIfMandatory() { // given: final CommonResource spy = spy(new CommonResource()); doReturn(null).when(spy).getRequestParameter(anyString()); - doNothing().when(spy).verifyNotNullParameter(anyObject(), anyString()); + doNothing().when(spy).verifyNotNullParameter(any(), anyString()); final String parameterName = "any string parameter name"; // when: diff --git a/bpm/bonita-web-server/src/test/java/org/bonitasoft/web/rest/server/engineclient/ProcessEngineClientTest.java b/bpm/bonita-web-server/src/test/java/org/bonitasoft/web/rest/server/engineclient/ProcessEngineClientTest.java index ed99509aac2..2c0e3898880 100644 --- a/bpm/bonita-web-server/src/test/java/org/bonitasoft/web/rest/server/engineclient/ProcessEngineClientTest.java +++ b/bpm/bonita-web-server/src/test/java/org/bonitasoft/web/rest/server/engineclient/ProcessEngineClientTest.java @@ -15,7 +15,6 @@ import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyLong; -import static org.mockito.ArgumentMatchers.anyObject; import static org.mockito.Mockito.*; import static org.mockito.MockitoAnnotations.initMocks; @@ -104,7 +103,7 @@ public void deploying_a_process_with_v6_forms_fails_with_the_right_message() BusinessArchive businessArchive = new BusinessArchive(); businessArchive.setProcessDefinition(designProcessDefinition); - when(processAPI.deploy((BusinessArchive) anyObject())) + when(processAPI.deploy((BusinessArchive) any())) .thenThrow(new V6FormDeployException(new Exception("a cause"))); expectedException.expect(APIException.class); diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 24403bcb47b..457b190b4b8 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -74,11 +74,11 @@ owaspHtmlSanitizerVersion = "20220608.1" # Test dependency versions junit4Version = "4.13.2" -junit5Version = "5.10.2" +junit5Version = "5.11.3" awaitilityVersion = "4.0.3" assertjVersion = "3.17.2" xmlunitVersion = "1.6" -mockitoVersion = "3.5.10" +mockitoVersion = "5.14.2" jsonUnitVersion = "2.19.0" systemRulesVersion = "1.19.0" systemLambdaVersion = "1.2.0" diff --git a/services/bonita-business-application/src/test/java/org/bonitasoft/engine/business/application/impl/ApplicationServiceImplTest.java b/services/bonita-business-application/src/test/java/org/bonitasoft/engine/business/application/impl/ApplicationServiceImplTest.java index 207a329147c..278875fa941 100755 --- a/services/bonita-business-application/src/test/java/org/bonitasoft/engine/business/application/impl/ApplicationServiceImplTest.java +++ b/services/bonita-business-application/src/test/java/org/bonitasoft/engine/business/application/impl/ApplicationServiceImplTest.java @@ -881,7 +881,7 @@ public void updateApplicationMenu_should_not_organize_indexes_when_field_index_i applicationServiceImpl.updateApplicationMenu(applicationMenuId, updateDescriptor); //then - verifyZeroInteractions(indexManager); + verifyNoInteractions(indexManager); } @Test(expected = SObjectNotFoundException.class) @@ -1103,7 +1103,7 @@ public void getNextIndex_should_return_getLastUsedIndex_more_one() throws Except given(applicationService.getLastUsedIndex(4L)).willReturn(7); //when - final int next = applicationServiceImpl.getNextAvailableIndex(4L); + final int next = applicationService.getNextAvailableIndex(4L); //then assertThat(next).isEqualTo(8); diff --git a/services/bonita-business-data/bonita-business-data-client-resources/src/test/java/org/bonitasoft/engine/bdm/dao/client/resources/proxy/ProxyTest.java b/services/bonita-business-data/bonita-business-data-client-resources/src/test/java/org/bonitasoft/engine/bdm/dao/client/resources/proxy/ProxyTest.java index 097d08e89b0..43154270dfc 100644 --- a/services/bonita-business-data/bonita-business-data-client-resources/src/test/java/org/bonitasoft/engine/bdm/dao/client/resources/proxy/ProxyTest.java +++ b/services/bonita-business-data/bonita-business-data-client-resources/src/test/java/org/bonitasoft/engine/bdm/dao/client/resources/proxy/ProxyTest.java @@ -71,7 +71,7 @@ public void should_return_value_when_it_has_been_already_loaded_before_proxyfica final String proxyName = entity.getName(); - verifyZeroInteractions(lazyLoader); + verifyNoInteractions(lazyLoader); assertThat(proxyName).isEqualTo(name); } @@ -93,7 +93,7 @@ public void should_not_load_object_for_a_non_lazy_loading_method() { entity.getEagerEntity(); - verifyZeroInteractions(lazyLoader); + verifyNoInteractions(lazyLoader); } @Test @@ -104,7 +104,7 @@ public void should_not_load_object_that_has_been_set_by_a_setter() { entity.setLazyEntity(expectedEntity); final TestEntity lazyEntity = entity.getLazyEntity(); - verifyZeroInteractions(lazyLoader); + verifyNoInteractions(lazyLoader); assertThat(lazyEntity).isEqualTo(expectedEntity); } diff --git a/services/bonita-business-data/bonita-business-data-impl/src/test/java/org/bonitasoft/engine/business/data/impl/BusinessDataReloaderTest.java b/services/bonita-business-data/bonita-business-data-impl/src/test/java/org/bonitasoft/engine/business/data/impl/BusinessDataReloaderTest.java index 85e1fd449ae..e4d51e58d65 100644 --- a/services/bonita-business-data/bonita-business-data-impl/src/test/java/org/bonitasoft/engine/business/data/impl/BusinessDataReloaderTest.java +++ b/services/bonita-business-data/bonita-business-data-impl/src/test/java/org/bonitasoft/engine/business/data/impl/BusinessDataReloaderTest.java @@ -15,7 +15,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoInteractions; import org.bonitasoft.engine.bdm.Entity; import org.bonitasoft.engine.business.data.BusinessDataRepository; @@ -88,7 +88,7 @@ public void reloadEntitySoftly_should_return_entity_itself_when_id_is_not_set() //then assertThat(reloadedEntity).isEqualTo(entity); - verifyZeroInteractions(repository); + verifyNoInteractions(repository); } @Test diff --git a/services/bonita-classloader/src/test/java/org/bonitasoft/engine/classloader/ClassLoaderUpdaterTest.java b/services/bonita-classloader/src/test/java/org/bonitasoft/engine/classloader/ClassLoaderUpdaterTest.java index b375cab656d..54b93bfff66 100644 --- a/services/bonita-classloader/src/test/java/org/bonitasoft/engine/classloader/ClassLoaderUpdaterTest.java +++ b/services/bonita-classloader/src/test/java/org/bonitasoft/engine/classloader/ClassLoaderUpdaterTest.java @@ -19,7 +19,7 @@ import static org.bonitasoft.engine.dependency.model.ScopeType.PROCESS; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoInteractions; import java.util.HashSet; import java.util.concurrent.Callable; @@ -83,7 +83,7 @@ public void should_not_create_a_session_when_there_is_no_tenant_id() throws Exce callableGivenToTheTaskExecutor.getValue().call(); - verifyZeroInteractions(sessionAccessor); + verifyNoInteractions(sessionAccessor); } @Test diff --git a/services/bonita-classloader/src/test/java/org/bonitasoft/engine/classloader/RefreshClassloaderSynchronizationTest.java b/services/bonita-classloader/src/test/java/org/bonitasoft/engine/classloader/RefreshClassloaderSynchronizationTest.java index bfd9c3dda90..3070657563b 100644 --- a/services/bonita-classloader/src/test/java/org/bonitasoft/engine/classloader/RefreshClassloaderSynchronizationTest.java +++ b/services/bonita-classloader/src/test/java/org/bonitasoft/engine/classloader/RefreshClassloaderSynchronizationTest.java @@ -82,7 +82,7 @@ public void should_refresh_classloader_on_other_nodes_after_commit() throws Exce public void should_not_refresh_classloader_when_transaction_is_not_committed() { refreshClassloaderSynchronization.afterCompletion(STATUS_MARKED_ROLLBACK); - verifyZeroInteractions(broadcastService); - verifyZeroInteractions(classLoaderUpdater); + verifyNoInteractions(broadcastService); + verifyNoInteractions(classLoaderUpdater); } } diff --git a/services/bonita-identity/src/test/java/org/bonitasoft/engine/identity/impl/IdentityServiceImplForUserTest.java b/services/bonita-identity/src/test/java/org/bonitasoft/engine/identity/impl/IdentityServiceImplForUserTest.java index 8cb52cc699d..54f9c60e79f 100644 --- a/services/bonita-identity/src/test/java/org/bonitasoft/engine/identity/impl/IdentityServiceImplForUserTest.java +++ b/services/bonita-identity/src/test/java/org/bonitasoft/engine/identity/impl/IdentityServiceImplForUserTest.java @@ -102,7 +102,7 @@ public void getNumberOfUsers() throws Exception { when(persistenceService.selectOne(ArgumentMatchers.> any())).thenReturn(1L); Assert.assertEquals(1L, identityServiceImpl.getNumberOfUsers()); - verifyZeroInteractions(recorder); + verifyNoInteractions(recorder); } @Test(expected = SIdentityException.class) diff --git a/services/bonita-page/src/test/java/org/bonitasoft/engine/page/impl/ApiExtensionPageServiceListenerImplTest.java b/services/bonita-page/src/test/java/org/bonitasoft/engine/page/impl/ApiExtensionPageServiceListenerImplTest.java index ac0763a8234..d81052623a3 100644 --- a/services/bonita-page/src/test/java/org/bonitasoft/engine/page/impl/ApiExtensionPageServiceListenerImplTest.java +++ b/services/bonita-page/src/test/java/org/bonitasoft/engine/page/impl/ApiExtensionPageServiceListenerImplTest.java @@ -18,8 +18,8 @@ import static org.mockito.Mockito.never; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions; -import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.when; import java.io.IOException; @@ -76,7 +76,7 @@ public void pageInserted_should_only_care_of_api_extension() throws Exception { listener.pageInserted(page, content); - verifyZeroInteractions(pageMappingService, helper); + verifyNoInteractions(pageMappingService, helper); } @Test @@ -312,7 +312,7 @@ public void pageDeleted_should_only_care_of_api_extension() throws Exception { listener.pageDeleted(page); - verifyZeroInteractions(pageMappingService, helper); + verifyNoInteractions(pageMappingService, helper); } @Test @@ -435,7 +435,7 @@ public void pageUpdated_should_only_care_of_api_extension() throws Exception { listener.pageUpdated(page, content); - verifyZeroInteractions(pageMappingService, helper); + verifyNoInteractions(pageMappingService, helper); } } diff --git a/services/bonita-page/src/test/java/org/bonitasoft/engine/page/impl/PageServiceImplTest.java b/services/bonita-page/src/test/java/org/bonitasoft/engine/page/impl/PageServiceImplTest.java index f7624e231a5..48fa5f60445 100644 --- a/services/bonita-page/src/test/java/org/bonitasoft/engine/page/impl/PageServiceImplTest.java +++ b/services/bonita-page/src/test/java/org/bonitasoft/engine/page/impl/PageServiceImplTest.java @@ -224,7 +224,6 @@ public void should_create_page_with_process_scope_when_name_exists() throws Exce final byte[] validContent = validPageContent(PAGE_NAME); when(pageServiceImpl.getPageByName(PAGE_NAME)).thenReturn(null); pageServiceImpl.addPage(newPage, validContent); - when(pageServiceImpl.getPageByName(PAGE_NAME)).thenReturn(newPage); // when final SPage newProcessPage = new SPage(PAGE_NAME, 123456, 45, false, CONTENT_NAME); diff --git a/services/bonita-page/src/test/java/org/bonitasoft/engine/page/impl/SPageMappingServiceImplTest.java b/services/bonita-page/src/test/java/org/bonitasoft/engine/page/impl/SPageMappingServiceImplTest.java index 9c8e71a66fe..edf9da25d32 100644 --- a/services/bonita-page/src/test/java/org/bonitasoft/engine/page/impl/SPageMappingServiceImplTest.java +++ b/services/bonita-page/src/test/java/org/bonitasoft/engine/page/impl/SPageMappingServiceImplTest.java @@ -25,7 +25,7 @@ import static org.mockito.Mockito.nullable; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoInteractions; import java.io.Serializable; import java.util.ArrayList; @@ -407,7 +407,7 @@ public void resolvePageURL_shouldAllowAsSoonAsOneRuleIsValid() throws Exception verify(neverValidRule).isAllowed(nullable(String.class), anyMap()); verify(validRule).isAllowed(nullable(String.class), anyMap()); - verifyZeroInteractions(neverValidRule2); + verifyNoInteractions(neverValidRule2); } @Test diff --git a/services/bonita-resources/src/test/java/org/bonitasoft/engine/resources/TenantResourcesServiceImplTest.java b/services/bonita-resources/src/test/java/org/bonitasoft/engine/resources/TenantResourcesServiceImplTest.java index 62b98257360..16a0349b130 100644 --- a/services/bonita-resources/src/test/java/org/bonitasoft/engine/resources/TenantResourcesServiceImplTest.java +++ b/services/bonita-resources/src/test/java/org/bonitasoft/engine/resources/TenantResourcesServiceImplTest.java @@ -56,7 +56,7 @@ public void add_should_log_message_and_ignore_null_file_content() throws Excepti tenantResourcesService.add("resourceName", TenantResourceType.BDM, null, -1); // then - verifyZeroInteractions(recorder); + verifyNoInteractions(recorder); } @Test @@ -65,7 +65,7 @@ public void add_should_log_message_and_ignore_empty_file_content() throws Except tenantResourcesService.add("resourceName", TenantResourceType.BDM, new byte[] {}, -1); // then - verifyZeroInteractions(recorder); + verifyNoInteractions(recorder); } @Test diff --git a/services/bonita-scheduler/src/test/java/org/bonitasoft/engine/scheduler/impl/JDBCJobListenerTest.java b/services/bonita-scheduler/src/test/java/org/bonitasoft/engine/scheduler/impl/JDBCJobListenerTest.java index d6ab02f7e10..2981b1f76d9 100755 --- a/services/bonita-scheduler/src/test/java/org/bonitasoft/engine/scheduler/impl/JDBCJobListenerTest.java +++ b/services/bonita-scheduler/src/test/java/org/bonitasoft/engine/scheduler/impl/JDBCJobListenerTest.java @@ -17,7 +17,7 @@ import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoInteractions; import java.io.Serializable; import java.util.Date; @@ -120,7 +120,7 @@ public void jobToBeExecuted_should_do_nothing_when_no_job_descriptor_id() throws jdbcJobListener.jobToBeExecuted(context); // Then - verifyZeroInteractions(jobService); + verifyNoInteractions(jobService); } @Test @@ -132,7 +132,7 @@ public void jobToBeExecuted_should_do_nothing_when_job_descriptor_id_equals_0() jdbcJobListener.jobToBeExecuted(context); // Then - verifyZeroInteractions(jobService); + verifyNoInteractions(jobService); } } diff --git a/services/bonita-scheduler/src/test/java/org/bonitasoft/engine/scheduler/impl/JobServiceImplForJobDescriptorTest.java b/services/bonita-scheduler/src/test/java/org/bonitasoft/engine/scheduler/impl/JobServiceImplForJobDescriptorTest.java index fcb8830e7f3..5a11bd2c7c2 100644 --- a/services/bonita-scheduler/src/test/java/org/bonitasoft/engine/scheduler/impl/JobServiceImplForJobDescriptorTest.java +++ b/services/bonita-scheduler/src/test/java/org/bonitasoft/engine/scheduler/impl/JobServiceImplForJobDescriptorTest.java @@ -306,7 +306,7 @@ public void getNumberOfJobDescriptors() throws SBonitaReadException, SBonitaRead // Then Assert.assertEquals(1L, numberOfJobDescriptors); - verifyZeroInteractions(recorder); + verifyNoInteractions(recorder); } @Test(expected = SBonitaReadException.class) diff --git a/services/bonita-scheduler/src/test/java/org/bonitasoft/engine/scheduler/impl/JobServiceImplForJobLogTest.java b/services/bonita-scheduler/src/test/java/org/bonitasoft/engine/scheduler/impl/JobServiceImplForJobLogTest.java index 42fa7a05622..0293ae05be6 100644 --- a/services/bonita-scheduler/src/test/java/org/bonitasoft/engine/scheduler/impl/JobServiceImplForJobLogTest.java +++ b/services/bonita-scheduler/src/test/java/org/bonitasoft/engine/scheduler/impl/JobServiceImplForJobLogTest.java @@ -284,7 +284,7 @@ public void getNumberOfJobLogs() throws SBonitaReadException, SBonitaReadExcepti // Then Assert.assertEquals(1L, numberOfJobLogs); - verifyZeroInteractions(recorder); + verifyNoInteractions(recorder); } @Test(expected = SBonitaReadException.class) diff --git a/services/bonita-work/src/test/java/org/bonitasoft/engine/work/RetryingWorkExecutorServiceTest.java b/services/bonita-work/src/test/java/org/bonitasoft/engine/work/RetryingWorkExecutorServiceTest.java index 10d35fc31e3..57180957f66 100644 --- a/services/bonita-work/src/test/java/org/bonitasoft/engine/work/RetryingWorkExecutorServiceTest.java +++ b/services/bonita-work/src/test/java/org/bonitasoft/engine/work/RetryingWorkExecutorServiceTest.java @@ -505,7 +505,7 @@ public void should_abandon_execution_when_failure_is_a_precondition_issue() thro workExecutorService.onFailure(workDescriptor, bonitaWork, context, rootCause); - verifyZeroInteractions(bonitaExecutorService); + verifyNoInteractions(bonitaExecutorService); verify(bonitaWork, never()).handleFailure(rootCause, emptyMap()); assertThat(workDescriptor.getRetryCount()).isEqualTo(0); }