< prev index next >

test/jdk/tools/jpackage/helpers/jdk/jpackage/test/TestBuilder.java

Print this page

        

@@ -66,15 +66,15 @@
                                 TestBuilder::toMethodCalls)).flatMap(s -> s).collect(
                         Collectors.toList())),
 
                 CMDLINE_ARG_PREFIX + "exclude",
                 arg -> (excludedTests = Optional.ofNullable(
-                        excludedTests).orElse(new HashSet<String>())).add(arg),
+                        excludedTests).orElseGet(() -> new HashSet<String>())).add(arg),
 
                 CMDLINE_ARG_PREFIX + "include",
                 arg -> (includedTests = Optional.ofNullable(
-                        includedTests).orElse(new HashSet<String>())).add(arg),
+                        includedTests).orElseGet(() -> new HashSet<String>())).add(arg),
 
                 CMDLINE_ARG_PREFIX + "space-subst",
                 arg -> spaceSubstitute = arg,
 
                 CMDLINE_ARG_PREFIX + "group",

@@ -125,12 +125,11 @@
         }
 
         // Log all matches before returning from the function
         return tests.filter(test -> {
             String testDescription = test.createDescription().testFullName();
-            boolean match = filters.stream().anyMatch(
-                    v -> testDescription.contains(v));
+            boolean match = filters.stream().anyMatch(testDescription::contains);
             if (match) {
                 trace(String.format(logMsg + ": %s", testDescription));
             }
             return pred.apply(match);
         }).collect(Collectors.toList()).stream();

@@ -157,22 +156,22 @@
                 restoreSpaces.apply(excludedTests), x -> !x, "Exclude");
     }
 
     private void flushTestGroup() {
         if (testGroup != null) {
-            filterTestGroup().forEach(testBody -> createTestInstance(testBody));
+            filterTestGroup().forEach(this::createTestInstance);
             clear();
         }
     }
 
     private void createTestInstance(MethodCall testBody) {
         final List<ThrowingConsumer> curBeforeActions;
         final List<ThrowingConsumer> curAfterActions;
 
         Method testMethod = testBody.getMethod();
         if (Stream.of(BeforeEach.class, AfterEach.class).anyMatch(
-                type -> testMethod.isAnnotationPresent(type))) {
+                testMethod::isAnnotationPresent)) {
             curBeforeActions = beforeActions;
             curAfterActions = afterActions;
         } else {
             curBeforeActions = new ArrayList<>(beforeActions);
             curAfterActions = new ArrayList<>(afterActions);

@@ -284,11 +283,11 @@
         }
         // Get the list of all public methods as need to deal with overloads.
         List<Method> methods = Stream.of(methodClass.getMethods()).filter(
                 (m) -> filterMethod(methodName, m)).collect(Collectors.toList());
         if (methods.isEmpty()) {
-            new ParseException(String.format(
+            throw new ParseException(String.format(
                     "Method [%s] not found in [%s] class;",
                     methodName, className));
         }
 
         trace(String.format("%s -> %s", qualifiedMethodName, methods));
< prev index next >