Use Truth8 to test Optionals in ActionResult/TerminationStatus tests.

RELNOTES: None.
PiperOrigin-RevId: 175153541
diff --git a/src/test/java/com/google/devtools/build/lib/BUILD b/src/test/java/com/google/devtools/build/lib/BUILD
index 2375e00..06bc832 100644
--- a/src/test/java/com/google/devtools/build/lib/BUILD
+++ b/src/test/java/com/google/devtools/build/lib/BUILD
@@ -337,6 +337,7 @@
         "//third_party:junit4",
         "//third_party:mockito",
         "//third_party:truth",
+        "//third_party:truth8",
     ],
 )
 
@@ -745,6 +746,7 @@
         "//third_party:junit4",
         "//third_party:mockito",
         "//third_party:truth",
+        "//third_party:truth8",
     ],
 )
 
@@ -1195,6 +1197,7 @@
         "//third_party:junit4",
         "//third_party:mockito",
         "//third_party:truth",
+        "//third_party:truth8",
     ],
 )
 
diff --git a/src/test/java/com/google/devtools/build/lib/actions/ActionResultTest.java b/src/test/java/com/google/devtools/build/lib/actions/ActionResultTest.java
index 8c683df..986e6e8 100644
--- a/src/test/java/com/google/devtools/build/lib/actions/ActionResultTest.java
+++ b/src/test/java/com/google/devtools/build/lib/actions/ActionResultTest.java
@@ -14,6 +14,7 @@
 package com.google.devtools.build.lib.actions;
 
 import static com.google.common.truth.Truth.assertThat;
+import static com.google.common.truth.Truth8.assertThat;
 
 import com.google.common.collect.ImmutableSet;
 import java.time.Duration;
@@ -30,9 +31,9 @@
   public void testCumulativeCommandExecutionTime_NoSpawnResults() {
     Set<SpawnResult> spawnResults = ImmutableSet.of();
     ActionResult actionResult = ActionResult.create(spawnResults);
-    assertThat(actionResult.cumulativeCommandExecutionWallTime().isPresent()).isFalse();
-    assertThat(actionResult.cumulativeCommandExecutionUserTime().isPresent()).isFalse();
-    assertThat(actionResult.cumulativeCommandExecutionSystemTime().isPresent()).isFalse();
+    assertThat(actionResult.cumulativeCommandExecutionWallTime()).isEmpty();
+    assertThat(actionResult.cumulativeCommandExecutionUserTime()).isEmpty();
+    assertThat(actionResult.cumulativeCommandExecutionSystemTime()).isEmpty();
   }
 
   @Test
@@ -46,15 +47,12 @@
             .build();
     Set<SpawnResult> spawnResults = ImmutableSet.of(spawnResult);
     ActionResult actionResult = ActionResult.create(spawnResults);
-    assertThat(actionResult.cumulativeCommandExecutionWallTime().isPresent()).isTrue();
-    assertThat(actionResult.cumulativeCommandExecutionUserTime().isPresent()).isTrue();
-    assertThat(actionResult.cumulativeCommandExecutionSystemTime().isPresent()).isTrue();
-    assertThat(actionResult.cumulativeCommandExecutionWallTime().get())
-        .isEqualTo(Duration.ofMillis(1984));
-    assertThat(actionResult.cumulativeCommandExecutionUserTime().get())
-        .isEqualTo(Duration.ofMillis(225));
-    assertThat(actionResult.cumulativeCommandExecutionSystemTime().get())
-        .isEqualTo(Duration.ofMillis(42));
+    assertThat(actionResult.cumulativeCommandExecutionWallTime()).isPresent();
+    assertThat(actionResult.cumulativeCommandExecutionWallTime()).hasValue(Duration.ofMillis(1984));
+    assertThat(actionResult.cumulativeCommandExecutionUserTime()).isPresent();
+    assertThat(actionResult.cumulativeCommandExecutionUserTime()).hasValue(Duration.ofMillis(225));
+    assertThat(actionResult.cumulativeCommandExecutionSystemTime()).isPresent();
+    assertThat(actionResult.cumulativeCommandExecutionSystemTime()).hasValue(Duration.ofMillis(42));
   }
 
   @Test
@@ -82,15 +80,12 @@
             .build();
     Set<SpawnResult> spawnResults = ImmutableSet.of(spawnResult1, spawnResult2, spawnResult3);
     ActionResult actionResult = ActionResult.create(spawnResults);
-    assertThat(actionResult.cumulativeCommandExecutionWallTime().isPresent()).isTrue();
-    assertThat(actionResult.cumulativeCommandExecutionUserTime().isPresent()).isTrue();
-    assertThat(actionResult.cumulativeCommandExecutionSystemTime().isPresent()).isTrue();
-    assertThat(actionResult.cumulativeCommandExecutionWallTime().get())
-        .isEqualTo(Duration.ofMillis(1984));
-    assertThat(actionResult.cumulativeCommandExecutionUserTime().get())
-        .isEqualTo(Duration.ofMillis(4));
-    assertThat(actionResult.cumulativeCommandExecutionSystemTime().get())
-        .isEqualTo(Duration.ofMillis(42));
+    assertThat(actionResult.cumulativeCommandExecutionWallTime()).isPresent();
+    assertThat(actionResult.cumulativeCommandExecutionWallTime()).hasValue(Duration.ofMillis(1984));
+    assertThat(actionResult.cumulativeCommandExecutionUserTime()).isPresent();
+    assertThat(actionResult.cumulativeCommandExecutionUserTime()).hasValue(Duration.ofMillis(4));
+    assertThat(actionResult.cumulativeCommandExecutionSystemTime()).isPresent();
+    assertThat(actionResult.cumulativeCommandExecutionSystemTime()).hasValue(Duration.ofMillis(42));
   }
 
   @Test
@@ -103,8 +98,8 @@
         new SpawnResult.Builder().setStatus(SpawnResult.Status.SUCCESS).build();
     Set<SpawnResult> spawnResults = ImmutableSet.of(spawnResult1, spawnResult2, spawnResult3);
     ActionResult actionResult = ActionResult.create(spawnResults);
-    assertThat(actionResult.cumulativeCommandExecutionWallTime().isPresent()).isFalse();
-    assertThat(actionResult.cumulativeCommandExecutionUserTime().isPresent()).isFalse();
-    assertThat(actionResult.cumulativeCommandExecutionSystemTime().isPresent()).isFalse();
+    assertThat(actionResult.cumulativeCommandExecutionWallTime()).isEmpty();
+    assertThat(actionResult.cumulativeCommandExecutionUserTime()).isEmpty();
+    assertThat(actionResult.cumulativeCommandExecutionSystemTime()).isEmpty();
   }
 }
diff --git a/src/test/java/com/google/devtools/build/lib/exec/local/LocalSpawnRunnerTest.java b/src/test/java/com/google/devtools/build/lib/exec/local/LocalSpawnRunnerTest.java
index 69fa1f6..260debf 100644
--- a/src/test/java/com/google/devtools/build/lib/exec/local/LocalSpawnRunnerTest.java
+++ b/src/test/java/com/google/devtools/build/lib/exec/local/LocalSpawnRunnerTest.java
@@ -15,6 +15,7 @@
 package com.google.devtools.build.lib.exec.local;
 
 import static com.google.common.truth.Truth.assertThat;
+import static com.google.common.truth.Truth8.assertThat;
 import static org.junit.Assert.fail;
 import static org.mockito.Matchers.any;
 import static org.mockito.Matchers.eq;
@@ -380,9 +381,9 @@
     assertThat(result.status()).isEqualTo(SpawnResult.Status.EXECUTION_FAILED);
     assertThat(result.exitCode()).isEqualTo(-1);
     assertThat(result.setupSuccess()).isFalse();
-    assertThat(result.getWallTime().isPresent()).isFalse();
-    assertThat(result.getUserTime().isPresent()).isFalse();
-    assertThat(result.getSystemTime().isPresent()).isFalse();
+    assertThat(result.getWallTime()).isEmpty();
+    assertThat(result.getUserTime()).isEmpty();
+    assertThat(result.getSystemTime()).isEmpty();
     assertThat(result.getExecutorHostName()).isEqualTo(NetUtil.getCachedShortHostName());
 
     assertThat(FileSystemUtils.readContent(fs.getPath("/out/stderr"), StandardCharsets.UTF_8))
@@ -405,9 +406,9 @@
     assertThat(reply.status()).isEqualTo(SpawnResult.Status.LOCAL_ACTION_NOT_ALLOWED);
     assertThat(reply.exitCode()).isEqualTo(-1);
     assertThat(reply.setupSuccess()).isFalse();
-    assertThat(reply.getWallTime().isPresent()).isFalse();
-    assertThat(reply.getUserTime().isPresent()).isFalse();
-    assertThat(reply.getSystemTime().isPresent()).isFalse();
+    assertThat(reply.getWallTime()).isEmpty();
+    assertThat(reply.getUserTime()).isEmpty();
+    assertThat(reply.getSystemTime()).isEmpty();
     assertThat(reply.getExecutorHostName()).isEqualTo(NetUtil.getCachedShortHostName());
 
     // TODO(ulfjack): Maybe we should only lock after checking?
diff --git a/src/test/java/com/google/devtools/build/lib/shell/TerminationStatusTest.java b/src/test/java/com/google/devtools/build/lib/shell/TerminationStatusTest.java
index 1d2b041..e4d8c61 100644
--- a/src/test/java/com/google/devtools/build/lib/shell/TerminationStatusTest.java
+++ b/src/test/java/com/google/devtools/build/lib/shell/TerminationStatusTest.java
@@ -15,6 +15,7 @@
 package com.google.devtools.build.lib.shell;
 
 import static com.google.common.truth.Truth.assertThat;
+import static com.google.common.truth.Truth8.assertThat;
 import static com.google.devtools.build.lib.testutil.MoreAsserts.assertThrows;
 
 import java.time.Duration;
@@ -42,9 +43,9 @@
   public void testBuilder_WithNoExecutionTime() {
     TerminationStatus terminationStatus =
         TerminationStatus.builder().setWaitResponse(0).setTimedOut(false).build();
-    assertThat(terminationStatus.getWallExecutionTime().isPresent()).isFalse();
-    assertThat(terminationStatus.getUserExecutionTime().isPresent()).isFalse();
-    assertThat(terminationStatus.getSystemExecutionTime().isPresent()).isFalse();
+    assertThat(terminationStatus.getWallExecutionTime()).isEmpty();
+    assertThat(terminationStatus.getUserExecutionTime()).isEmpty();
+    assertThat(terminationStatus.getSystemExecutionTime()).isEmpty();
   }
 
   @Test
@@ -57,11 +58,11 @@
             .setUserExecutionTime(Duration.ofMillis(1492))
             .setSystemExecutionTime(Duration.ofMillis(1787))
             .build();
-    assertThat(terminationStatus.getWallExecutionTime().isPresent()).isTrue();
-    assertThat(terminationStatus.getUserExecutionTime().isPresent()).isTrue();
-    assertThat(terminationStatus.getSystemExecutionTime().isPresent()).isTrue();
-    assertThat(terminationStatus.getWallExecutionTime().get()).isEqualTo(Duration.ofMillis(1929));
-    assertThat(terminationStatus.getUserExecutionTime().get()).isEqualTo(Duration.ofMillis(1492));
-    assertThat(terminationStatus.getSystemExecutionTime().get()).isEqualTo(Duration.ofMillis(1787));
+    assertThat(terminationStatus.getWallExecutionTime()).isPresent();
+    assertThat(terminationStatus.getWallExecutionTime()).hasValue(Duration.ofMillis(1929));
+    assertThat(terminationStatus.getUserExecutionTime()).isPresent();
+    assertThat(terminationStatus.getUserExecutionTime()).hasValue(Duration.ofMillis(1492));
+    assertThat(terminationStatus.getSystemExecutionTime()).isPresent();
+    assertThat(terminationStatus.getSystemExecutionTime()).hasValue(Duration.ofMillis(1787));
   }
 }