Skip to content

Commit

Permalink
chore(project): jdk17 support
Browse files Browse the repository at this point in the history
- remove powermock
- update mockito to latest version & add mockito-inline for static tests
- fix ProcessEngineTestsTest & CmmnAwareTestsTest
- add jdk17 CI target

related to CAM-14399
  • Loading branch information
danielkelemen committed Mar 1, 2022
1 parent 1ad7ada commit 67295e6
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 145 deletions.
3 changes: 2 additions & 1 deletion .ci.cambpm
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ buildMavenAndDeployToMavenCentral([
'jdk-12-latest',
'jdk-13-latest',
'jdk-14-latest',
'jdk-15-latest'
'jdk-15-latest',
'jdk-17-latest'
]
])
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,9 @@
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.MockedStatic;
import org.mockito.Mockito;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import org.mockito.junit.MockitoJUnitRunner;

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.*;
Expand All @@ -48,21 +47,23 @@
/**
* @author Martin Schimak (martin.schimak@plexiti.com)
*/
@RunWith(PowerMockRunner.class)
@PrepareForTest(ProcessEngines.class)
@RunWith(MockitoJUnitRunner.class)
public class ProcessEngineTestsTest {

ProcessEngine processEngine;
MockedStatic<ProcessEngines> processEnginesMockedStatic;

@Before
public void setUp() {
processEngine = mock(ProcessEngine.class);
processEnginesMockedStatic = mockStatic(ProcessEngines.class, CALLS_REAL_METHODS);
init(processEngine);
}

@After
public void tearDown() {
reset();
processEnginesMockedStatic.close();
}

@Test
Expand All @@ -72,12 +73,11 @@ public void testProcessEngine() throws Exception {
// Then
assertThat(returnedEngine).isNotNull().isSameAs(processEngine);
}

@Test
public void testNoProcessEngine_Failure() throws Exception {
// Given
PowerMockito.spy(ProcessEngines.class);
Mockito.when(ProcessEngines.getProcessEngines()).thenReturn(new HashMap<String,ProcessEngine>());
processEnginesMockedStatic.when(ProcessEngines::getProcessEngines).thenReturn(new HashMap<String,ProcessEngine>());
reset();
try {
// When
Expand All @@ -88,15 +88,14 @@ public void testNoProcessEngine_Failure() throws Exception {
assertThat(e).hasMessage("No ProcessEngine found to be registered with ProcessEngines!");
}
}

@Test
public void testMultipleProcessEngine_Failure() throws Exception {
// Given
Map<String,ProcessEngine> multipleEnginesMap = new HashMap<>();
multipleEnginesMap.put("test1", mock(ProcessEngine.class));
multipleEnginesMap.put("test2", mock(ProcessEngine.class));
PowerMockito.spy(ProcessEngines.class);
Mockito.when(ProcessEngines.getProcessEngines()).thenReturn(multipleEnginesMap);
processEnginesMockedStatic.when(ProcessEngines::getProcessEngines).thenReturn(multipleEnginesMap);
reset();
try {
// When
Expand Down Expand Up @@ -173,7 +172,7 @@ public void testAssertThat_Job() throws Exception {
JobAssert jobAssert = assertThat(job);
assertThat(jobAssert.getActual()).isSameAs(job);
}

@Test
public void testAssertThat_CaseInstance() throws Exception {
//Given
Expand Down Expand Up @@ -367,7 +366,7 @@ public void testProcessDefinitionQuery() {
verify(repositoryService, times(1)).createProcessDefinitionQuery();
verifyNoMoreInteractions(repositoryService);
}

@Test
public void testExecutionQuery() {
// Given
Expand Down
Loading

0 comments on commit 67295e6

Please sign in to comment.