Refine search
@Test public void hasCycle_selfLoopEdge() { for (MutableGraph<Integer> graph : graphsToTest) { graph.putEdge(1, 1); } assertThat(hasCycle(directedGraph)).isTrue(); assertThat(hasCycle(undirectedGraph)).isTrue(); }
public void testCallableStartsAfterFirstFutureCompletes() { @SuppressWarnings({"unused", "nullness"}) Future<?> possiblyIgnoredError = serializer.submitAsync(firstCallable, directExecutor()); TestCallable secondCallable = new TestCallable(Futures.<Void>immediateFuture(null)); @SuppressWarnings({"unused", "nullness"}) Future<?> possiblyIgnoredError1 = serializer.submitAsync(secondCallable, directExecutor()); assertThat(firstCallable.called).isTrue(); assertThat(secondCallable.called).isFalse(); firstFuture.set(null); assertThat(secondCallable.called).isTrue(); }
@Test public void addEdge_orderMismatch() { EndpointPair<Integer> endpoints = EndpointPair.ordered(N1, N2); assertThat(addEdge(endpoints, E12)).isTrue(); } }
public void testFailed() throws Exception { Exception cause = new Exception(); assertThat(future.setException(cause)).isTrue(); assertFailed(future, cause); }
@Test public void isComplete_primaryNotFailed_primaryComplete_returnsTrue() { when(primary.isComplete()).thenReturn(true); assertThat(coordinator.isComplete()).isTrue(); }
public void testSetFutureThenInterrupt() throws Exception { assertThat(future.setFuture(delegate)).isTrue(); assertThat(future.cancel(true /* mayInterruptIfRunning */)).isTrue(); assertCancelled(future, true); assertCancelled(delegate, true); }
@Test public void isCancelled_primaryNotFailed_primaryCancelled_returnsTrue() { when(primary.isCleared()).thenReturn(true); assertThat(coordinator.isCleared()).isTrue(); }
public void testSetFutureThenCancel() throws Exception { assertThat(future.setFuture(delegate)).isTrue(); assertThat(future.cancel(false /* mayInterruptIfRunning */)).isTrue(); assertCancelled(future, false); assertCancelled(delegate, false); }
@Test public void canNotifyCleared_errorRequest_primaryFailed_nullParent_returnsTrue() { when(primary.isFailed()).thenReturn(true); assertThat(coordinator.canNotifyCleared(error)).isTrue(); }
public void testNewProxy_goodMethodWithEnoughTime() throws Exception { SampleImpl target = new SampleImpl(DELAY_MS); Sample proxy = service.newProxy(target, Sample.class, ENOUGH_MS, MILLISECONDS); Stopwatch stopwatch = Stopwatch.createStarted(); String result = proxy.sleepThenReturnInput("x"); assertThat(result).isEqualTo("x"); assertThat(stopwatch.elapsed(MILLISECONDS)).isIn(Range.closed(DELAY_MS, ENOUGH_MS)); assertThat(target.finished).isTrue(); }
@Test public void addNode_newNode() { assertThat(addNode(N1)).isTrue(); assertThat(graph.nodes()).contains(N1); }
public void testContains() { ImmutableLongArray iia = ImmutableLongArray.of(1, 1, 2, 3, 5, 8); assertThat(iia.contains(1)).isTrue(); assertThat(iia.contains(8)).isTrue(); assertThat(iia.contains(4)).isFalse(); assertThat(ImmutableLongArray.of(13).contains(13)).isTrue(); assertThat(ImmutableLongArray.of().contains(21)).isFalse(); assertThat(iia.subArray(1, 5).contains(1)).isTrue(); }
@Test public void createUndirected_multigraph() { MutableNetwork<Integer, String> undirectedMultigraph = NetworkBuilder.undirected().allowsParallelEdges(true).build(); assertThat(undirectedMultigraph.addEdge(N1, N2, E12)).isTrue(); assertThat(undirectedMultigraph.addEdge(N1, N2, E12_A)).isTrue(); assertThat(undirectedMultigraph.addEdge(N2, N1, E21)).isTrue(); assertThat(undirectedMultigraph.edgesConnecting(N1, N2)) .isEqualTo(ImmutableSet.of(E12, E12_A, E21)); }
public void testContains() { ImmutableDoubleArray iia = ImmutableDoubleArray.of(1, 1, 2, 3, 5, 8); assertThat(iia.contains(1)).isTrue(); assertThat(iia.contains(8)).isTrue(); assertThat(iia.contains(4)).isFalse(); assertThat(ImmutableDoubleArray.of(13).contains(13)).isTrue(); assertThat(ImmutableDoubleArray.of().contains(21)).isFalse(); assertThat(iia.subArray(1, 5).contains(1)).isTrue(); }
@Test public void putEdge_existingEdgeBetweenSameNodes() { assertThat(putEdge(N1, N2)).isTrue(); assertThat(putEdge(N1, N2)).isFalse(); }
public void testContains() { ImmutableIntArray iia = ImmutableIntArray.of(1, 1, 2, 3, 5, 8); assertThat(iia.contains(1)).isTrue(); assertThat(iia.contains(8)).isTrue(); assertThat(iia.contains(4)).isFalse(); assertThat(ImmutableIntArray.of(13).contains(13)).isTrue(); assertThat(ImmutableIntArray.of().contains(21)).isFalse(); assertThat(iia.subArray(1, 5).contains(1)).isTrue(); }
@Override @Test public void addEdge_selfLoop() { assertThat(putEdge(N1, N1)).isTrue(); assertThat(graph.adjacentNodes(N1)).containsExactly(N1); }
@GwtIncompatible // threads public void testSubmitAsync_asyncCallable_returnsInterruptedFuture() throws InterruptedException { assertThat(Thread.interrupted()).isFalse(); SettableFuture<Integer> cancelledFuture = SettableFuture.create(); cancelledFuture.cancel(true); assertThat(Thread.interrupted()).isFalse(); ListenableFuture<Integer> future = submitAsync(constantAsyncCallable(cancelledFuture), directExecutor()); assertThat(future.isDone()).isTrue(); assertThat(Thread.interrupted()).isFalse(); }
@Test public void hasEdgeConnecting_correct() { putEdge(N1, N2); assertThat(graph.hasEdgeConnecting(EndpointPair.unordered(N1, N2))).isTrue(); assertThat(graph.hasEdgeConnecting(EndpointPair.unordered(N2, N1))).isTrue(); }
public void testSetFutureDelegateLaterInterrupted() throws Exception { assertThat(future.setFuture(delegate)).isTrue(); delegate.cancel( true /** mayInterruptIfRunning */ ); assertCancelled(future, /* expectWasInterrupted= */ false); }