Refine search
private static void assertEqualCharNodes(Iterable<Character> result, String expectedCharacters) { assertThat(ImmutableList.copyOf(result)) .containsExactlyElementsIn(Chars.asList(expectedCharacters.toCharArray())) .inOrder(); }
private static void assertEqualWildcardType(WildcardType expected, WildcardType actual) { assertEquals(expected.toString(), actual.toString()); assertEquals(actual.toString(), expected.hashCode(), actual.hashCode()); assertThat(actual.getLowerBounds()) .asList() .containsExactlyElementsIn(asList(expected.getLowerBounds())) .inOrder(); assertThat(actual.getUpperBounds()) .asList() .containsExactlyElementsIn(asList(expected.getUpperBounds())) .inOrder(); }
public void testMapSplitter_trimmedBoth() { Map<String, String> m = COMMA_SPLITTER .trimResults() .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(); }
private static void assertEqualTypeVariable(TypeVariable<?> expected, TypeVariable<?> actual) { assertEquals(expected.toString(), actual.toString()); assertEquals(expected.getName(), actual.getName()); assertEquals(expected.getGenericDeclaration(), actual.getGenericDeclaration()); if (!Types.NativeTypeVariableEquals.NATIVE_TYPE_VARIABLE_ONLY) { assertEquals(actual.toString(), expected.hashCode(), actual.hashCode()); } assertThat(actual.getBounds()) .asList() .containsExactlyElementsIn(asList(expected.getBounds())) .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 testMapSplitter_CharacterSeparator() { // try different delimiters. Map<String, String> m = Splitter.on(",").withKeyValueSeparator(':').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 testMapSplitter_trimmedEntries() { Map<String, String> m = COMMA_SPLITTER .trimResults() .withKeyValueSeparator(":") .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 testMapSplitter_multiCharacterSeparator() { // try different delimiters. Map<String, String> m = Splitter.on(",") .withKeyValueSeparator(":^&") .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 testMapSplitter_notTrimmed() { Map<String, String> m = COMMA_SPLITTER .withKeyValueSeparator(":") .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 testReadsThroughAdd() { for (List<Integer> contents : SAMPLE_INPUTS) { C unfiltered = createUnfiltered(contents); C filterThenAdd = filter(unfiltered, EVEN); unfiltered.add(4); List<Integer> target = Lists.newArrayList(contents); target.add(4); C addThenFilter = filter(createUnfiltered(target), EVEN); assertThat(filterThenAdd).containsExactlyElementsIn(addThenFilter); } }
public void testCreateFromMultimap() { Multimap<String, Integer> multimap = LinkedListMultimap.create(); multimap.put("foo", 1); multimap.put("bar", 3); multimap.put("foo", 2); LinkedListMultimap<String, Integer> copy = LinkedListMultimap.create(multimap); assertEquals(multimap, copy); assertThat(copy.entries()).containsExactlyElementsIn(multimap.entries()).inOrder(); }
public void testClearFilterFiltered() { for (List<Integer> contents : SAMPLE_INPUTS) { C unfiltered = createUnfiltered(contents); C filtered1 = filter(unfiltered, EVEN); C filtered2 = filter(filtered1, PRIME_DIGIT); C inverseFiltered = filter(createUnfiltered(contents), Predicates.not(Predicates.and(EVEN, PRIME_DIGIT))); filtered2.clear(); assertThat(unfiltered).containsExactlyElementsIn(inverseFiltered); } } }
private static <R, C, V> void validateViewOrdering(Table<R, C, V> original, Table<R, C, V> copy) { assertThat(copy.cellSet()).containsExactlyElementsIn(original.cellSet()).inOrder(); assertThat(copy.rowKeySet()).containsExactlyElementsIn(original.rowKeySet()).inOrder(); assertThat(copy.values()).containsExactlyElementsIn(original.values()).inOrder(); }
private static <R, C, V> void validateReserialization(Table<R, C, V> original) { Table<R, C, V> copy = SerializableTester.reserializeAndAssert(original); assertThat(copy.cellSet()).containsExactlyElementsIn(original.cellSet()).inOrder(); assertThat(copy.rowKeySet()).containsExactlyElementsIn(original.rowKeySet()).inOrder(); assertThat(copy.columnKeySet()).containsExactlyElementsIn(original.columnKeySet()).inOrder(); }
@Test public void addEdge_existingEdgeBetweenSameNodes() { assertThat(addEdge(N1, N2, E12)).isTrue(); ImmutableSet<String> edges = ImmutableSet.copyOf(network.edges()); assertThat(addEdge(N1, N2, E12)).isFalse(); assertThat(network.edges()).containsExactlyElementsIn(edges); assertThat(addEdge(N2, N1, E12)).isFalse(); assertThat(network.edges()).containsExactlyElementsIn(edges); }
@Override @Test public void nodes_checkReturnedSetMutability() { Set<Integer> nodes = graph.nodes(); try { nodes.add(N2); fail(ERROR_MODIFIABLE_SET); } catch (UnsupportedOperationException e) { addNode(N1); assertThat(graph.nodes()).containsExactlyElementsIn(nodes); } }
@Test public void removeNode_nodeNotPresent() { addNode(N1); ImmutableSet<Integer> nodes = ImmutableSet.copyOf(graph.nodes()); assertThat(graph.removeNode(NODE_NOT_IN_GRAPH)).isFalse(); assertThat(graph.nodes()).containsExactlyElementsIn(nodes); }
@Override public void adjacentEdges_checkReturnedSetMutability() { addEdge(N1, N2, E12); Set<String> adjacentEdges = network.adjacentEdges(E12); try { adjacentEdges.add(E23); fail(ERROR_MODIFIABLE_COLLECTION); } catch (UnsupportedOperationException e) { addEdge(N2, N3, E23); assertThat(network.adjacentEdges(E12)).containsExactlyElementsIn(adjacentEdges); } }
@Test public void addEdge_existingSelfLoopEdgeBetweenSameNodes() { addEdge(N1, N1, E11); ImmutableSet<String> edges = ImmutableSet.copyOf(network.edges()); assertThat(addEdge(N1, N1, E11)).isFalse(); assertThat(network.edges()).containsExactlyElementsIn(edges); }
@Override @Test public void nodes_checkReturnedSetMutability() { Set<Integer> nodes = graph.nodes(); try { nodes.add(N2); fail(ERROR_MODIFIABLE_SET); } catch (UnsupportedOperationException e) { addNode(N1); assertThat(graph.nodes()).containsExactlyElementsIn(nodes); } }