### Question:
GcpComputePlatform extends Platform implements SshBasedExperiment<GcpComputeInstanceContainer> { void performTaskAfterOperationCompletes (String operationSelfLink, Runnable task) { ScheduledExecutorService operationWatcher = Executors.newSingleThreadScheduledExecutor(); ExecutorService taskRunner = Executors.newSingleThreadExecutor(); final Object syncLock = new Object(); taskRunner.submit(() -> { synchronized (syncLock) { try { syncLock.wait(1000L * 60 * 5 ); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new ChaosException(GCP_COMPUTE_GENERIC_ERROR, e); } finally { operationWatcher.shutdown(); } task.run(); } }); operationWatcher.scheduleWithFixedDelay(() -> { synchronized (syncLock) { if (isOperationComplete(operationSelfLink)) { syncLock.notifyAll(); operationWatcher.shutdown(); } } }, 5, 1, TimeUnit.SECONDS); }  void setRoutableCIDRBlocks(Collection<String> routableCIDRBlocks); @Override ApiStatus getApiStatus(); @Override PlatformLevel getPlatformLevel(); @Override PlatformHealth getPlatformHealth(); Collection<Items> getIncludeFilter(); void setIncludeFilter(Map<String, String> includeFilter); Collection<Items> getExcludeFilter(); void setExcludeFilter(Map<String, String> excludeFilter); @Override boolean isContainerRecycled(Container container); String stopInstance(GcpComputeInstanceContainer container); ContainerHealth isContainerRunning(GcpComputeInstanceContainer gcpComputeInstanceContainer); String simulateMaintenance(GcpComputeInstanceContainer container); String setTags(GcpComputeInstanceContainer container, List<String> tags); String setTagsSafe(GcpComputeInstanceContainer container, List<String> newTags, String oldFingerprint); boolean isContainerGroupAtCapacity(GcpComputeInstanceContainer container); boolean checkTags(GcpComputeInstanceContainer container, List<String> expectedTags); void startInstance(GcpComputeInstanceContainer container); String restartContainer(GcpComputeInstanceContainer container); String getBestEndpoint(String privateIPAddress, String publicIPAddress); boolean isAddressRoutable(String privateIPAddress); String getLatestInstanceId(String instanceName, String zone); Fingerprint<List<String>> getFirewallTags(GcpComputeInstanceContainer container); void setProjectId(String projectId); @Override String getEndpoint(GcpComputeInstanceContainer container); @Override SSHCredentials getSshCredentials(GcpComputeInstanceContainer container); @Override String getRunningDirectory(); @Override void recycleContainer(GcpComputeInstanceContainer container); String recreateInstanceInInstanceGroup(GcpComputeInstanceContainer container); boolean isOperationComplete(String operationId);  }### Answer:
@Test public void performTaskAfterOperationCompletes () { String operationId = "my-operation-id"; final AtomicBoolean operationComplete = new AtomicBoolean(false); doReturn(false, true).when(gcpComputePlatform).isOperationComplete(operationId); gcpComputePlatform.performTaskAfterOperationCompletes(operationId, () -> operationComplete.set(true)); await().atLeast(5500, TimeUnit.MILLISECONDS).atMost(7, TimeUnit.SECONDS).until(operationComplete::get); }