Skip to content

Commit

Permalink
Improve tests by using ExecutorService#submit to demonstrate inlini…
Browse files Browse the repository at this point in the history
…ng type arguments
  • Loading branch information
rickie authored and Stephan202 committed Dec 10, 2021
1 parent ca193c0 commit fa69dcf
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<Object> example() {
ExecutorService executorService = Executors.newSingleThreadExecutor();
return executorService.submit(() -> new Object());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.<String>isEmpty();
public Future<Object> example() {
ExecutorService executorService = Executors.newSingleThreadExecutor();
return executorService.<Object>submit(() -> new Object());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> {
@BeforeTemplate
boolean before(String string) {
return string.isEmpty();
Future<T> before(ExecutorService executorService, Callable<T> callable) {
return executorService.submit(callable);
}

@AfterTemplate
boolean after(String string) {
return string.<String>isEmpty();
Future<T> after(ExecutorService executorService, Callable<T> callable) {
return executorService.<T>submit(callable);
}
}

0 comments on commit fa69dcf

Please sign in to comment.