From fa69dcf65f3d298034545249caa277fb0ef25efe Mon Sep 17 00:00:00 2001 From: Rick Ossendrijver Date: Thu, 25 Nov 2021 15:37:33 +0100 Subject: [PATCH] Improve tests by using `ExecutorService#submit` to demonstrate inlining type arguments --- ...ypeArgumentsMethodInvocationTemplateExample.java | 10 +++++++--- ...ypeArgumentsMethodInvocationTemplateExample.java | 10 +++++++--- .../TypeArgumentsMethodInvocationTemplate.java | 13 ++++++++----- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/core/src/test/java/com/google/errorprone/refaster/testdata/input/TypeArgumentsMethodInvocationTemplateExample.java b/core/src/test/java/com/google/errorprone/refaster/testdata/input/TypeArgumentsMethodInvocationTemplateExample.java index 9f43ca040f16..4a2c119556f3 100644 --- a/core/src/test/java/com/google/errorprone/refaster/testdata/input/TypeArgumentsMethodInvocationTemplateExample.java +++ b/core/src/test/java/com/google/errorprone/refaster/testdata/input/TypeArgumentsMethodInvocationTemplateExample.java @@ -14,10 +14,14 @@ package com.google.errorprone.refaster.testdata; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; + /** Test data for {@code TypeArgumentsMethodInvocationTemplate}. */ public class TypeArgumentsMethodInvocationTemplateExample { - public boolean example() { - String s = ""; - return s.isEmpty(); + public Future example() { + ExecutorService executorService = Executors.newSingleThreadExecutor(); + return executorService.submit(() -> new Object()); } } diff --git a/core/src/test/java/com/google/errorprone/refaster/testdata/output/TypeArgumentsMethodInvocationTemplateExample.java b/core/src/test/java/com/google/errorprone/refaster/testdata/output/TypeArgumentsMethodInvocationTemplateExample.java index 28630cc6b53e..629f40086fd9 100644 --- a/core/src/test/java/com/google/errorprone/refaster/testdata/output/TypeArgumentsMethodInvocationTemplateExample.java +++ b/core/src/test/java/com/google/errorprone/refaster/testdata/output/TypeArgumentsMethodInvocationTemplateExample.java @@ -14,10 +14,14 @@ package com.google.errorprone.refaster.testdata; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; + /** Test data for {@code TypeArgumentsMethodInvocationTemplate}. */ public class TypeArgumentsMethodInvocationTemplateExample { - public boolean example() { - String s = ""; - return s.isEmpty(); + public Future example() { + ExecutorService executorService = Executors.newSingleThreadExecutor(); + return executorService.submit(() -> new Object()); } } diff --git a/core/src/test/java/com/google/errorprone/refaster/testdata/template/TypeArgumentsMethodInvocationTemplate.java b/core/src/test/java/com/google/errorprone/refaster/testdata/template/TypeArgumentsMethodInvocationTemplate.java index 33d2f1868257..4243f7d8d946 100644 --- a/core/src/test/java/com/google/errorprone/refaster/testdata/template/TypeArgumentsMethodInvocationTemplate.java +++ b/core/src/test/java/com/google/errorprone/refaster/testdata/template/TypeArgumentsMethodInvocationTemplate.java @@ -18,16 +18,19 @@ import com.google.errorprone.refaster.annotation.AfterTemplate; import com.google.errorprone.refaster.annotation.BeforeTemplate; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Future; /** Sample template for introducing type arguments on a method invocation in an @AfterTemplate. */ -public class TypeArgumentsMethodInvocationTemplate { +public class TypeArgumentsMethodInvocationTemplate { @BeforeTemplate - boolean before(String string) { - return string.isEmpty(); + Future before(ExecutorService executorService, Callable callable) { + return executorService.submit(callable); } @AfterTemplate - boolean after(String string) { - return string.isEmpty(); + Future after(ExecutorService executorService, Callable callable) { + return executorService.submit(callable); } }