Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kurtakov2018-04-19 15:25:59 +0000
committerAlexander Kurtakov2018-04-19 15:25:59 +0000
commitddc5c8e8c2c0f4dc2cae4b7974d65582995a9b15 (patch)
tree4c0586dc815aec6d4576963eb2c95efe0ddcc9c0
parent5255d2584af627c0d8e778bc77b7308e7203cb26 (diff)
downloadorg.eclipse.epp.mpc-ddc5c8e8c2c0f4dc2cae4b7974d65582995a9b15.tar.gz
org.eclipse.epp.mpc-ddc5c8e8c2c0f4dc2cae4b7974d65582995a9b15.tar.xz
org.eclipse.epp.mpc-ddc5c8e8c2c0f4dc2cae4b7974d65582995a9b15.zip
Lambda conversion in tests bundles.
Change-Id: If5c064f4567d692ab182e7999b364715dca2c590 Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
-rw-r--r--org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/UISuite.java8
-rw-r--r--org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/ui/wizard/AbstractMarketplaceWizardBotTest.java103
-rw-r--r--org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/ui/wizard/MarketplaceClientServiceTest.java62
-rw-r--r--org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/ui/wizard/SelectionModelStateSerializerTest.java20
-rw-r--r--org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/ui/wizard/widgets/SWTBotClickableStyledText.java15
-rw-r--r--org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/util/PropertyStub.java10
-rw-r--r--org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/util/TransportFactoryTest.java45
7 files changed, 95 insertions, 168 deletions
diff --git a/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/UISuite.java b/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/UISuite.java
index f8933a46..6a9fcb22 100644
--- a/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/UISuite.java
+++ b/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/UISuite.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 The Eclipse Foundation and others.
+ * Copyright (c) 2010, 2018 The Eclipse Foundation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -40,11 +40,7 @@ public class UISuite extends LoggingSuite {
super.run(notifier);//we are in an UI Thread already
} else {
final Display display = PlatformUI.getWorkbench().getDisplay();
- display.syncExec(new Runnable() {
- public void run() {
- doRun(notifier);
- }
- });
+ display.syncExec(() -> doRun(notifier));
}
}
diff --git a/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/ui/wizard/AbstractMarketplaceWizardBotTest.java b/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/ui/wizard/AbstractMarketplaceWizardBotTest.java
index 989a7185..0c756d57 100644
--- a/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/ui/wizard/AbstractMarketplaceWizardBotTest.java
+++ b/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/ui/wizard/AbstractMarketplaceWizardBotTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 The Eclipse Foundation and others.
+ * Copyright (c) 2010, 2018 The Eclipse Foundation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -13,8 +13,16 @@ package org.eclipse.epp.mpc.tests.ui.wizard;
import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.widgetOfType;
import static org.eclipse.swtbot.swt.finder.waits.Conditions.shellIsActive;
import static org.hamcrest.CoreMatchers.containsString;
-import static org.hamcrest.Matchers.*;
-import static org.junit.Assert.*;
+import static org.hamcrest.Matchers.allOf;
+import static org.hamcrest.Matchers.empty;
+import static org.hamcrest.Matchers.greaterThanOrEqualTo;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import java.io.File;
import java.lang.management.ManagementFactory;
@@ -63,7 +71,6 @@ import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
import org.eclipse.swtbot.swt.finder.junit.ScreenshotCaptureListener;
import org.eclipse.swtbot.swt.finder.results.ArrayResult;
import org.eclipse.swtbot.swt.finder.results.Result;
-import org.eclipse.swtbot.swt.finder.results.VoidResult;
import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferenceConstants;
import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
import org.eclipse.swtbot.swt.finder.utils.SWTUtils;
@@ -87,7 +94,6 @@ import org.junit.AssumptionViolatedException;
import org.junit.Before;
import org.junit.Rule;
import org.junit.rules.TestRule;
-import org.junit.runner.Description;
import org.junit.runner.notification.Failure;
import org.junit.runners.model.Statement;
@@ -134,31 +140,28 @@ public abstract class AbstractMarketplaceWizardBotTest {
}
@Rule
- public TestRule screenshotOnFailureRule = new TestRule() {
+ public TestRule screenshotOnFailureRule = (base, description) -> {
+ String targetDir = System.getProperty(SWTBotPreferenceConstants.KEY_SCREENSHOTS_DIR);
+ if (targetDir == null && new File("target").isDirectory()) {
+ SWTBotPreferences.SCREENSHOTS_DIR = "target/screenshots";
+ }
+ return new Statement() {
- public Statement apply(final Statement base, final Description description) {
- String targetDir = System.getProperty(SWTBotPreferenceConstants.KEY_SCREENSHOTS_DIR);
- if (targetDir == null && new File("target").isDirectory()) {
- SWTBotPreferences.SCREENSHOTS_DIR = "target/screenshots";
- }
- return new Statement() {
-
- private final ScreenshotCaptureListener capturer = new ScreenshotCaptureListener();
-
- @Override
- public void evaluate() throws Throwable {
- try {
- base.evaluate();
- } catch (Throwable t) {
- capturer.testFailure(new Failure(description, t));
- throw t;
- } finally {
- tearDownBot();
- }
+ private final ScreenshotCaptureListener capturer = new ScreenshotCaptureListener();
+
+ @Override
+ public void evaluate() throws Throwable {
+ try {
+ base.evaluate();
+ } catch (Throwable t) {
+ capturer.testFailure(new Failure(description, t));
+ throw t;
+ } finally {
+ tearDownBot();
}
+ }
- };
- }
+ };
};
@Before
@@ -182,15 +185,12 @@ public abstract class AbstractMarketplaceWizardBotTest {
wizardState.setProceedWithInstallation(false);
marketplaceWizardCommand.setWizardDialogState(wizardState);
- UIThreadRunnable.asyncExec(new VoidResult() {
-
- public void run() {
- try {
- marketplaceWizardCommand.execute(new ExecutionEvent());
- } catch (ExecutionException e) {
- fail("ExecutionException: " + e.getMessage());
- //otherwise ignore, we'll notice in the test thread when we don't get the wizard dialog in time
- }
+ UIThreadRunnable.asyncExec(() -> {
+ try {
+ marketplaceWizardCommand.execute(new ExecutionEvent());
+ } catch (ExecutionException e) {
+ fail("ExecutionException: " + e.getMessage());
+ //otherwise ignore, we'll notice in the test thread when we don't get the wizard dialog in time
}
});
}
@@ -287,12 +287,9 @@ public abstract class AbstractMarketplaceWizardBotTest {
final Shell shell = mpcShell.widget;
if (!shell.isDisposed()) {
Display display = shell.getDisplay();
- display.syncExec(new Runnable() {
- @Override
- public void run() {
- if (!shell.isDisposed()) {
- shell.dispose();
- }
+ display.syncExec(() -> {
+ if (!shell.isDisposed()) {
+ shell.dispose();
}
});
}
@@ -418,12 +415,7 @@ public abstract class AbstractMarketplaceWizardBotTest {
protected void checkSelectedTab(String tabLabel) {
SWTBotTabItem searchTab = bot.tabItem(tabLabel);
final TabItem tab = searchTab.widget;
- TabItem[] selection = UIThreadRunnable.syncExec(new ArrayResult<TabItem>() {
-
- public TabItem[] run() {
- return tab.getParent().getSelection();
- }
- });
+ TabItem[] selection = UIThreadRunnable.syncExec((ArrayResult<TabItem>) () -> tab.getParent().getSelection());
assertEquals(1, selection.length);
assertSame(tab, selection[0]);
}
@@ -480,12 +472,8 @@ public abstract class AbstractMarketplaceWizardBotTest {
}
private StyleRange[] findStyleRanges(final SWTBotStyledText styledText) {
- StyleRange[] ranges = UIThreadRunnable.syncExec(new ArrayResult<StyleRange>() {
-
- public StyleRange[] run() {
- return styledText.widget.getStyleRanges();
- }
- });
+ StyleRange[] ranges = UIThreadRunnable.syncExec((ArrayResult<StyleRange>) () -> styledText.widget
+ .getStyleRanges());
return ranges;
}
@@ -613,12 +601,7 @@ public abstract class AbstractMarketplaceWizardBotTest {
}
protected MarketplaceWizardDialog getWizardDialog() {
- return (MarketplaceWizardDialog) UIThreadRunnable.syncExec(new Result<Object>() {
-
- public Object run() {
- return wizardShell.widget.getData();
- }
- });
+ return (MarketplaceWizardDialog) UIThreadRunnable.syncExec((Result<Object>) () -> wizardShell.widget.getData());
}
protected MarketplaceWizard getWizard() {
diff --git a/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/ui/wizard/MarketplaceClientServiceTest.java b/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/ui/wizard/MarketplaceClientServiceTest.java
index 27598664..b68861fb 100644
--- a/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/ui/wizard/MarketplaceClientServiceTest.java
+++ b/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/ui/wizard/MarketplaceClientServiceTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 The Eclipse Foundation and others.
+ * Copyright (c) 2010, 2018 The Eclipse Foundation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -11,7 +11,9 @@
*******************************************************************************/
package org.eclipse.epp.mpc.tests.ui.wizard;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import java.util.Collections;
@@ -70,12 +72,7 @@ public class MarketplaceClientServiceTest extends AbstractMarketplaceWizardBotTe
@Test
public void testOpenDefault() throws Exception {
Display display = PlatformUI.getWorkbench().getDisplay();
- display.asyncExec(new Runnable() {
-
- public void run() {
- service.open(config);
- }
- });
+ display.asyncExec(() -> service.open(config));
initWizardBot();
checkSelectedTab("Search");
@@ -83,12 +80,7 @@ public class MarketplaceClientServiceTest extends AbstractMarketplaceWizardBotTe
@Test
public void testOpenInstalled() throws Exception {
- display.asyncExec(new Runnable() {
-
- public void run() {
- service.openInstalled(config);
- }
- });
+ display.asyncExec(() -> service.openInstalled(config));
initWizardBot();
checkSelectedTab("Installed");
@@ -97,12 +89,7 @@ public class MarketplaceClientServiceTest extends AbstractMarketplaceWizardBotTe
@Test
public void testOpenNodes() throws Exception {
- display.asyncExec(new Runnable() {
-
- public void run() {
- service.open(config, Collections.singleton(QueryHelper.nodeById(ITEM_ID)));
- }
- });
+ display.asyncExec(() -> service.open(config, Collections.singleton(QueryHelper.nodeById(ITEM_ID))));
initWizardBot();
checkSelectedTab("Search");
@@ -114,12 +101,7 @@ public class MarketplaceClientServiceTest extends AbstractMarketplaceWizardBotTe
final IMarket toolsMarket = QueryHelper.marketByName("Tools");
final ICategory mylynCategory = QueryHelper.categoryByName("Editor");
- display.asyncExec(new Runnable() {
-
- public void run() {
- service.openSearch(config, toolsMarket, mylynCategory, "snipmatch");
- }
- });
+ display.asyncExec(() -> service.openSearch(config, toolsMarket, mylynCategory, "snipmatch"));
initWizardBot();
checkSelectedTab("Search");
@@ -140,12 +122,7 @@ public class MarketplaceClientServiceTest extends AbstractMarketplaceWizardBotTe
public void testOpenWithSelection() throws Exception {
config.setInitialOperations(Collections.singletonMap(ITEM_ID, Operation.INSTALL));
- display.asyncExec(new Runnable() {
-
- public void run() {
- service.open(config);
- }
- });
+ display.asyncExec(() -> service.open(config));
initWizardBot();
checkSelectedTab("Search");
@@ -158,12 +135,7 @@ public class MarketplaceClientServiceTest extends AbstractMarketplaceWizardBotTe
public void testOpenSelected() throws Exception {
config.setInitialOperations(Collections.singletonMap(ITEM_ID, Operation.INSTALL));
- display.asyncExec(new Runnable() {
-
- public void run() {
- service.openSelected(config);
- }
- });
+ display.asyncExec(() -> service.openSelected(config));
initWizardBot();
checkSelectedTab("Search");
@@ -176,12 +148,7 @@ public class MarketplaceClientServiceTest extends AbstractMarketplaceWizardBotTe
public void testOpenProvisioning() throws Exception {
config.setInitialOperations(Collections.singletonMap(ITEM_ID, Operation.INSTALL));
- display.asyncExec(new Runnable() {
-
- public void run() {
- service.openProvisioning(config);
- }
- });
+ display.asyncExec(() -> service.openProvisioning(config));
initWizardBot();
@@ -199,12 +166,7 @@ public class MarketplaceClientServiceTest extends AbstractMarketplaceWizardBotTe
@Test
public void testOpenFavorites() throws Exception {
- display.asyncExec(new Runnable() {
-
- public void run() {
- service.openFavorites(config);
- }
- });
+ display.asyncExec(() -> service.openFavorites(config));
initWizardBot();
checkSelectedTab("Favorites");
diff --git a/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/ui/wizard/SelectionModelStateSerializerTest.java b/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/ui/wizard/SelectionModelStateSerializerTest.java
index 0da4c73b..8e5aa2b1 100644
--- a/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/ui/wizard/SelectionModelStateSerializerTest.java
+++ b/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/ui/wizard/SelectionModelStateSerializerTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 The Eclipse Foundation and others.
+ * Copyright (c) 2010, 2018 The Eclipse Foundation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -11,20 +11,24 @@
*******************************************************************************/
package org.eclipse.epp.mpc.tests.ui.wizard;
-import static org.hamcrest.Matchers.*;
-import static org.junit.Assert.*;
+import static org.hamcrest.Matchers.empty;
+import static org.hamcrest.Matchers.not;
+import static org.hamcrest.Matchers.startsWith;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
import java.net.URL;
import java.util.Collections;
import java.util.Map;
-import java.util.Set;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.epp.internal.mpc.core.ServiceLocator;
import org.eclipse.epp.internal.mpc.core.service.DefaultMarketplaceService;
import org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceCatalog;
import org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceDiscoveryStrategy;
-import org.eclipse.epp.internal.mpc.ui.wizards.InstallProfile;
import org.eclipse.epp.internal.mpc.ui.wizards.SelectionModel;
import org.eclipse.epp.internal.mpc.ui.wizards.SelectionModelStateSerializer;
import org.eclipse.epp.mpc.core.service.IMarketplaceService;
@@ -63,11 +67,7 @@ public class SelectionModelStateSerializerTest {
catalog = new MarketplaceCatalog();
catalog.getDiscoveryStrategies().add(discoveryStrategy);
- selectionModel = new SelectionModel(new InstallProfile() {
- public Set<String> getInstalledFeatures() {
- return Collections.emptySet();
- }
- });
+ selectionModel = new SelectionModel(() -> Collections.emptySet());
}
@After
diff --git a/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/ui/wizard/widgets/SWTBotClickableStyledText.java b/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/ui/wizard/widgets/SWTBotClickableStyledText.java
index 2a74f5f8..3dc77b5a 100644
--- a/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/ui/wizard/widgets/SWTBotClickableStyledText.java
+++ b/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/ui/wizard/widgets/SWTBotClickableStyledText.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 The Eclipse Foundation and others.
+ * Copyright (c) 2010, 2018 The Eclipse Foundation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -37,14 +37,11 @@ public class SWTBotClickableStyledText extends SWTBotStyledText {
}
public void click(final int offset) {
- Point location = UIThreadRunnable.syncExec(new Result<Point>() {
-
- public Point run() {
- Point location = widget.getLocationAtOffset(offset);
- int lineHeight = widget.getLineHeight(offset);
- location.y += lineHeight / 2;
- return location;
- }
+ Point location = UIThreadRunnable.syncExec((Result<Point>) () -> {
+ Point location1 = widget.getLocationAtOffset(offset);
+ int lineHeight = widget.getLineHeight(offset);
+ location1.y += lineHeight / 2;
+ return location1;
});
click(location.x, location.y, false);
}
diff --git a/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/util/PropertyStub.java b/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/util/PropertyStub.java
index 57bff98c..2dba1135 100644
--- a/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/util/PropertyStub.java
+++ b/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/util/PropertyStub.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 The Eclipse Foundation and others.
+ * Copyright (c) 2010, 2018 The Eclipse Foundation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -33,13 +33,7 @@ public class PropertyStub<T> {
}
};
- private final Answer<T> getterAnswer = new Answer<T>() {
-
- @Override
- public T answer(InvocationOnMock invocation) throws Throwable {
- return value;
- }
- };
+ private final Answer<T> getterAnswer = invocation -> value;
public T getValue() {
return value;
diff --git a/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/util/TransportFactoryTest.java b/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/util/TransportFactoryTest.java
index 101f1fc3..1778b984 100644
--- a/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/util/TransportFactoryTest.java
+++ b/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/util/TransportFactoryTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 The Eclipse Foundation and others.
+ * Copyright (c) 2010, 2018 The Eclipse Foundation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -11,8 +11,16 @@
*******************************************************************************/
package org.eclipse.epp.mpc.tests.util;
-import static org.hamcrest.Matchers.*;
-import static org.junit.Assert.*;
+import static org.hamcrest.Matchers.hasItem;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.not;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.fail;
import java.io.ByteArrayInputStream;
import java.io.IOException;
@@ -29,7 +37,6 @@ import java.util.Set;
import org.apache.http.ConnectionClosedException;
import org.apache.http.Header;
import org.apache.http.HttpEntity;
-import org.apache.http.HttpException;
import org.apache.http.HttpRequest;
import org.apache.http.HttpRequestInterceptor;
import org.apache.http.HttpResponse;
@@ -68,8 +75,6 @@ import org.junit.Before;
import org.junit.Test;
import org.mockito.Matchers;
import org.mockito.Mockito;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
import org.osgi.framework.BundleContext;
import org.osgi.framework.FrameworkUtil;
import org.osgi.framework.ServiceReference;
@@ -90,14 +95,10 @@ public class TransportFactoryTest {
@Override
public HttpClientBuilder customizeBuilder(HttpClientBuilder builder) {
- return builder.addInterceptorLast(new HttpRequestInterceptor() {
-
- @Override
- public void process(HttpRequest request, HttpContext context) throws HttpException, IOException {
- interceptedRequest = request;
- interceptedContext = context;
- throw new ConnectionClosedException("Aborting test request before execution");
- }
+ return builder.addInterceptorLast((HttpRequestInterceptor) (request, context) -> {
+ interceptedRequest = request;
+ interceptedContext = context;
+ throw new ConnectionClosedException("Aborting test request before execution");
}).disableAutomaticRetries();
}
@@ -276,17 +277,11 @@ public class TransportFactoryTest {
@Test
public void testHttpClientCustomizer() throws Exception {
final HttpClientCustomizer customizer = Mockito.mock(HttpClientCustomizer.class);
- Mockito.when(customizer.customizeBuilder(Matchers.any())).thenAnswer(new Answer<HttpClientBuilder>() {
- public HttpClientBuilder answer(InvocationOnMock invocation) {
- HttpClientBuilder builder = (HttpClientBuilder)invocation.getArguments()[0];
- return builder == null ? null : builder.addInterceptorFirst(new HttpRequestInterceptor() {
-
- @Override
- public void process(HttpRequest request, HttpContext context) throws HttpException, IOException {
- request.addHeader("X-Customizer-Test", "true");
- }
- });
- }
+ Mockito.when(customizer.customizeBuilder(Matchers.any())).thenAnswer(invocation -> {
+ HttpClientBuilder builder = (HttpClientBuilder) invocation.getArguments()[0];
+ return builder == null ? null
+ : builder.addInterceptorFirst((HttpRequestInterceptor) (request, context) -> request.addHeader(
+ "X-Customizer-Test", "true"));
});
Mockito.when(customizer.customizeCredentialsProvider(Matchers.any())).thenReturn(null);

Back to the top