public void removeEdge_antiparallelEdges() { putEdge(N1, N2); putEdge(N2, N1); assertThat(graph.removeEdge(N1, N2)).isTrue(); assertThat(graph.successors(N1)).isEmpty(); assertThat(graph.predecessors(N1)).containsExactly(N2); assertThat(graph.edges()).hasSize(1); assertThat(graph.removeEdge(N2, N1)).isTrue(); assertThat(graph.successors(N1)).isEmpty(); assertThat(graph.predecessors(N1)).isEmpty(); assertThat(graph.edges()).isEmpty(); }
private static void containsExactlySanityCheck(Collection<?> collection, Object... varargs) { assertThat(collection).hasSize(varargs.length); for (Object obj : varargs) { assertThat(collection).contains(obj); } assertThat(collection).containsExactly(varargs); } }
@Test public void createDirected_multigraph() { MutableNetwork<Integer, String> directedMultigraph = NetworkBuilder.directed().allowsParallelEdges(true).build(); assertThat(directedMultigraph.addEdge(N1, N2, E12)).isTrue(); assertThat(directedMultigraph.addEdge(N1, N2, E12_A)).isTrue(); assertThat(directedMultigraph.edgesConnecting(N1, N2)).isEqualTo(ImmutableSet.of(E12, E12_A)); assertThat(directedMultigraph.edgesConnecting(N2, N1)).isEmpty(); }
public void testCharacterSimpleSplitWithNoDelimiter() { String simple = "a,b,c"; Iterable<String> letters = Splitter.on('.').split(simple); assertThat(letters).containsExactly("a,b,c").inOrder(); }
public void testMapSplitter_trimmedKeyValue() { Map<String, String> m = COMMA_SPLITTER .withKeyValueSeparator(Splitter.on(':').trimResults()) .split("boy : tom , girl: tina , cat : kitty , dog: tommy "); ImmutableMap<String, String> expected = ImmutableMap.of("boy", "tom", "girl", "tina", "cat", "kitty", "dog", "tommy"); assertThat(m).isEqualTo(expected); assertThat(m.entrySet()).containsExactlyElementsIn(expected.entrySet()).inOrder(); }
public void testLimitExtraSeparatorsTrim3() { String text = ",,a,, , b ,, c,d "; Iterable<String> items = COMMA_SPLITTER.limit(3).omitEmptyStrings().trimResults().split(text); assertThat(items).containsExactly("a", "b", "c,d").inOrder(); }
@GwtIncompatible // Splitter.onPattern public void testPatternSplitWithDoubleDelimiter() { String doubled = "a,,b,c"; Iterable<String> letters = Splitter.onPattern(",").split(doubled); assertThat(letters).containsExactly("a", "", "b", "c").inOrder(); }
public void testInverseInsertionOrderAfterInverseForcePut() { BiMap<String, Integer> map = HashBiMap.create(); map.put("foo", 1); map.put("bar", 2); map.put("quux", 3); map.inverse().forcePut(1, "quux"); assertThat(map.inverse().entrySet()) .containsExactly(Maps.immutableEntry(2, "bar"), Maps.immutableEntry(1, "quux")) .inOrder(); }
@Test public void edgeOrder_natural() { MutableNetwork<Integer, String> network = NetworkBuilder.directed().edgeOrder(ElementOrder.<String>natural()).build(); addEdges(network); assertThat(network.edgeOrder()).isEqualTo(ElementOrder.sorted(Ordering.<String>natural())); assertThat(network.edges()).containsExactly("e", "i", "p").inOrder(); assertThat(network.nodeOrder()).isEqualTo(insertion()); // default }
@Test public void testSelfLoop() { EndpointPair<String> unordered = EndpointPair.unordered("node", "node"); assertThat(unordered.isOrdered()).isFalse(); assertThat(unordered).containsExactly("node", "node"); assertThat(unordered.nodeU()).isEqualTo("node"); assertThat(unordered.nodeV()).isEqualTo("node"); assertThat(unordered.adjacentNode("node")).isEqualTo("node"); assertThat(unordered.toString()).isEqualTo("[node, node]"); }
@Test public void addEdge_existingEdgeBetweenSameNodes() { addEdge(N1, N2, E12); ImmutableSet<String> edges = ImmutableSet.copyOf(network.edges()); assertThat(addEdge(N1, N2, E12)).isFalse(); assertThat(network.edges()).containsExactlyElementsIn(edges); }
@Test public void testGetByIndex() { DrmInitData testInitData = new DrmInitData(DATA_1, DATA_2); assertThat(getAllSchemeData(testInitData)).containsAllOf(DATA_1, DATA_2); }
@Test public void testOrderedEndpointPair() { EndpointPair<String> ordered = EndpointPair.ordered("source", "target"); assertThat(ordered.isOrdered()).isTrue(); assertThat(ordered).containsExactly("source", "target").inOrder(); assertThat(ordered.source()).isEqualTo("source"); assertThat(ordered.target()).isEqualTo("target"); assertThat(ordered.nodeU()).isEqualTo("source"); assertThat(ordered.nodeV()).isEqualTo("target"); assertThat(ordered.adjacentNode("source")).isEqualTo("target"); assertThat(ordered.adjacentNode("target")).isEqualTo("source"); assertThat(ordered.toString()).isEqualTo("<source -> target>"); }
@Test public void createUndirected_expectedNodeCount() { MutableNetwork<Integer, String> undirectedGraph = NetworkBuilder.undirected().expectedNodeCount(NODE_COUNT).build(); assertThat(undirectedGraph.addEdge(N1, N2, E12)).isTrue(); assertThat(undirectedGraph.edgesConnecting(N1, N2)).isEqualTo(ImmutableSet.of(E12)); assertThat(undirectedGraph.edgesConnecting(N2, N1)).isEqualTo(ImmutableSet.of(E12)); }
/** * Asserts that the media source reported completed loads via {@link * MediaSourceEventListener#onLoadCompleted(int, MediaPeriodId, LoadEventInfo, MediaLoadData)} for * each specified window index and a null period id. Also asserts that no other loads with media * period id null are reported. */ public void assertCompletedManifestLoads(Integer... windowIndices) { List<Integer> expectedWindowIndices = new ArrayList<>(Arrays.asList(windowIndices)); for (Pair<Integer, MediaPeriodId> windowIndexAndMediaPeriodId : completedLoads) { if (windowIndexAndMediaPeriodId.second == null) { boolean loadExpected = expectedWindowIndices.remove(windowIndexAndMediaPeriodId.first); assertThat(loadExpected).isTrue(); } } assertWithMessage("Not all expected media source loads have been completed.") .that(expectedWindowIndices) .isEmpty(); }
@Test public void testKeySetIterator() { mapCache.put("A", "A_value"); mapCache.put("B", "B_value"); mapCache.put("C", "C_value"); assertThat(mapCache.unmodifiableKeySet()).hasSize(3); for (String key : mapCache.unmodifiableKeySet()) { assertThat(mapCache.get(key)).isEqualTo(key + "_value"); } }
@Test public void queryPermissionsByGroup_nullMatchesPermissionsNotAssociatedWithGroup_with_addPermissionInfo() throws Exception { PermissionInfo permissionInfo = new PermissionInfo(); permissionInfo.name = "some_name"; shadowPackageManager.addPermissionInfo(permissionInfo); List<PermissionInfo> permissions = packageManager.queryPermissionsByGroup(null, 0); assertThat(permissions).isNotEmpty(); assertThat(permissions.get(0).name).isEqualTo(permissionInfo.name); }
@Test public void bindInt64ArrayEmpty() { Struct row = execute( Statement.newBuilder("SELECT @v").bind("v").toInt64Array(Arrays.<Long>asList()), Type.array(Type.int64())); assertThat(row.isNull(0)).isFalse(); assertThat(row.getLongList(0)).containsExactly(); }
@Test public void bindTimestampArrayEmpty() { Struct row = execute( Statement.newBuilder("SELECT @v") .bind("v") .toTimestampArray(Arrays.<Timestamp>asList()), Type.array(Type.timestamp())); assertThat(row.isNull(0)).isFalse(); assertThat(row.getTimestampList(0)).containsExactly(); }
@Test public void shouldHandleParamTypes() throws Exception { InvocationProfile profile = new InvocationProfile("android/view/View/invalidate(I[ZLjava/lang/String;)Lwhatever/Foo;", false, getClass().getClassLoader()); assertThat(profile.clazz).isEqualTo(View.class); assertThat(profile.methodName).isEqualTo("invalidate"); assertThat(profile.isStatic).isEqualTo(false); assertThat(profile.paramTypes).asList().containsExactly("int", "boolean[]", "java.lang.String"); } }