Skip to content

Commit

Permalink
Update target platform to 4.29 Eclipse build.
Browse files Browse the repository at this point in the history
- React to changes in Mockito 5.5.0

Signed-off-by: Roland Grunberg <[email protected]>
  • Loading branch information
rgrunber committed Sep 13, 2023
1 parent 618d7e7 commit 072cb58
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 17 deletions.
2 changes: 1 addition & 1 deletion org.eclipse.jdt.ls.target/org.eclipse.jdt.ls.tp.target
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<unit id="org.eclipse.sdk.feature.group" version="0.0.0"/>
<unit id="org.mockito.mockito-core" version="0.0.0"/>
<unit id="org.apache.commons.commons-io" version="0.0.0"/>
<repository location="https://download.eclipse.org/eclipse/updates/4.29-I-builds/I20230806-1800/"/>
<repository location="https://download.eclipse.org/eclipse/updates/4.29/"/>
</location>
<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
<unit id="org.eclipse.xtext.xbase.lib" version="0.0.0"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ public void tearDown() throws Exception {
private Preferences mockPreferences() {
Preferences mockPreferences = Mockito.mock(Preferences.class);
Mockito.when(preferenceManager.getPreferences()).thenReturn(mockPreferences);
Mockito.when(preferenceManager.getPreferences(Mockito.any())).thenReturn(mockPreferences);
Mockito.lenient().when(preferenceManager.getPreferences(Mockito.any())).thenReturn(mockPreferences);
when(this.preferenceManager.getClientPreferences()).thenReturn(clientPreferences);
when(clientPreferences.isSupportedCodeActionKind(CodeActionKind.QuickFix)).thenReturn(true);
Mockito.lenient().when(clientPreferences.isSupportedCodeActionKind(CodeActionKind.QuickFix)).thenReturn(true);
return mockPreferences;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,14 @@ public void tearDown() throws Exception {

private Preferences mockPreferences() {
Preferences mockPreferences = Mockito.mock(Preferences.class);
Mockito.when(preferenceManager.getPreferences()).thenReturn(mockPreferences);
Mockito.when(preferenceManager.getPreferences(Mockito.any())).thenReturn(mockPreferences);
Mockito.lenient().when(preferenceManager.getPreferences()).thenReturn(mockPreferences);
Mockito.lenient().when(preferenceManager.getPreferences(Mockito.any())).thenReturn(mockPreferences);
when(this.preferenceManager.getClientPreferences()).thenReturn(clientPreferences);
when(clientPreferences.isSupportedCodeActionKind(CodeActionKind.QuickFix)).thenReturn(true);
return mockPreferences;
}

private List<Either<Command, CodeAction>> getCodeActions(ICompilationUnit cu, IProblem problem) throws JavaModelException {
private List<Either<Command, CodeAction>> getCodeActions(ICompilationUnit cu, IProblem problem) throws JavaModelException {
CodeActionParams parms = new CodeActionParams();
Range range = JDTUtils.toRange(cu, problem.getSourceStart(), 0);

Expand Down Expand Up @@ -139,7 +139,7 @@ public void testReportAllErrorsFixForNonProjectFile() throws Exception {
assertEquals(3, action.getCommand().getArguments().size());
assertEquals("thisFile", action.getCommand().getArguments().get(1));
assertEquals(false, action.getCommand().getArguments().get(2));

action = actions.get(1).getRight();
assertEquals(CodeActionKind.QuickFix, action.getKind());
assertEquals(ActionMessages.ReportAllErrorsForAnyNonProjectFile, action.getCommand().getTitle());
Expand Down Expand Up @@ -212,7 +212,7 @@ public void testReportSyntaxErrorsFixForNonProjectFile() throws Exception {
assertEquals(3, action.getCommand().getArguments().size());
assertEquals("thisFile", action.getCommand().getArguments().get(1));
assertEquals(true, action.getCommand().getArguments().get(2));

action = actions.get(1).getRight();
assertEquals(CodeActionKind.QuickFix, action.getKind());
assertEquals(ActionMessages.ReportSyntaxErrorsForAnyNonProjectFile, action.getCommand().getTitle());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;

@RunWith(MockitoJUnitRunner.class)
Expand Down Expand Up @@ -92,7 +93,7 @@ private String createCompletionRequest(ICompilationUnit unit, int line, int kar)
private void mockClient() {
// Mock the preference manager to use LSP v3 support.
when(preferenceManager.getClientPreferences().isCompletionSnippetsSupported()).thenReturn(true);
when(preferenceManager.getClientPreferences().isSignatureHelpSupported()).thenReturn(true);
Mockito.lenient().when(preferenceManager.getClientPreferences().isSignatureHelpSupported()).thenReturn(true);
when(preferenceManager.getClientPreferences().isCompletionInsertReplaceSupport()).thenReturn(true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;

@RunWith(MockitoJUnitRunner.class)
Expand All @@ -56,8 +57,8 @@ public void setup() throws Exception {
this.clientPreferences = preferenceManager.getClientPreferences();
when(clientPreferences.isResourceOperationSupported()).thenReturn(false);
Preferences p = mock(Preferences.class);
when(preferenceManager.getPreferences()).thenReturn(p);
when(p.isRenameEnabled()).thenReturn(true);
Mockito.lenient().when(preferenceManager.getPreferences()).thenReturn(p);
Mockito.lenient().when(p.isRenameEnabled()).thenReturn(true);
handler = new PrepareRenameHandler(preferenceManager);
}

Expand Down Expand Up @@ -160,7 +161,7 @@ public void testRenameMethod() throws JavaModelException, BadLocationException {

@Test
public void testRenameTypeWithResourceChanges() throws JavaModelException, BadLocationException {
when(clientPreferences.isResourceOperationSupported()).thenReturn(true);
Mockito.lenient().when(clientPreferences.isResourceOperationSupported()).thenReturn(true);

IPackageFragment pack1 = sourceFolder.createPackageFragment("test1", false, null);

Expand Down Expand Up @@ -276,7 +277,7 @@ public void testRenameJavadoc() throws JavaModelException, BadLocationException

@Test(expected = ResponseErrorException.class)
public void testRenamePackage() throws JavaModelException, BadLocationException {
when(clientPreferences.isResourceOperationSupported()).thenReturn(true);
Mockito.lenient().when(clientPreferences.isResourceOperationSupported()).thenReturn(true);

IPackageFragment pack1 = sourceFolder.createPackageFragment("test1", false, null);
IPackageFragment pack2 = sourceFolder.createPackageFragment("parent.test2", false, null);
Expand Down Expand Up @@ -312,7 +313,7 @@ public void testRenamePackage() throws JavaModelException, BadLocationException

@Test(expected = ResponseErrorException.class)
public void testRenameMiddleOfPackage() throws JavaModelException, BadLocationException {
when(clientPreferences.isResourceOperationSupported()).thenReturn(true);
Mockito.lenient().when(clientPreferences.isResourceOperationSupported()).thenReturn(true);

IPackageFragment pack1 = sourceFolder.createPackageFragment("ex.amples", false, null);

Expand Down Expand Up @@ -358,7 +359,7 @@ public void testRenameBinaryPackage() throws JavaModelException, BadLocationExce

@Test(expected = ResponseErrorException.class)
public void testRenameImportDeclaration() throws JavaModelException, BadLocationException {
when(clientPreferences.isResourceOperationSupported()).thenReturn(true);
Mockito.lenient().when(clientPreferences.isResourceOperationSupported()).thenReturn(true);

IPackageFragment pack1 = sourceFolder.createPackageFragment("ex.amples", false, null);

Expand All @@ -379,7 +380,7 @@ public void testRenameImportDeclaration() throws JavaModelException, BadLocation
}

private void testRenameClassFile(String type) throws JavaModelException, BadLocationException {
when(clientPreferences.isResourceOperationSupported()).thenReturn(true);
Mockito.lenient().when(clientPreferences.isResourceOperationSupported()).thenReturn(true);

IPackageFragment pack1 = sourceFolder.createPackageFragment("ex.amples", false, null);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public void testWhenRootPathChanged() throws Exception {
JavaLanguageClient client = mock(JavaLanguageClient.class);
ProjectsManager pm = JavaLanguageServerPlugin.getProjectsManager();
pm.setConnection(client);
doNothing().when(client).showMessage(any(MessageParams.class));
Mockito.lenient().doNothing().when(client).showMessage(any(MessageParams.class));
copyAndImportFolder("singlefile/simple", "src/App.java");

List<IPath> rootPaths = new ArrayList<>(preferenceManager.getPreferences().getRootPaths());
Expand Down

0 comments on commit 072cb58

Please sign in to comment.