Lines Matching defs:constrained
103 Map<String, Integer> constrained = MapConstraints.constrainedMap(
106 constrained.put("foo", 1);
108 constrained.putAll(ImmutableMap.of("baz", 3));
109 assertTrue(map.equals(constrained));
110 assertTrue(constrained.equals(map));
111 assertEquals(map.entrySet(), constrained.entrySet());
112 assertEquals(map.keySet(), constrained.keySet());
114 HashMultiset.create(constrained.values()));
116 assertEquals(map.toString(), constrained.toString());
117 assertEquals(map.hashCode(), constrained.hashCode());
127 Map<String, Integer> constrained = MapConstraints.constrainedMap(
130 constrained.put(TEST_KEY, TEST_VALUE);
134 constrained.put("baz", TEST_VALUE);
138 constrained.put(TEST_KEY, 3);
142 constrained.putAll(ImmutableMap.of("baz", 3, TEST_KEY, 4));
146 assertEquals(Collections.emptySet(), constrained.entrySet());
153 BiMap<String, Integer> constrained = MapConstraints.constrainedBiMap(
156 constrained.put("foo", 1);
158 constrained.putAll(ImmutableMap.of("baz", 3));
159 assertTrue(map.equals(constrained));
160 assertTrue(constrained.equals(map));
161 assertEquals(map.entrySet(), constrained.entrySet());
162 assertEquals(map.keySet(), constrained.keySet());
163 assertEquals(map.values(), constrained.values());
164 assertEquals(map.toString(), constrained.toString());
165 assertEquals(map.hashCode(), constrained.hashCode());
177 BiMap<String, Integer> constrained = MapConstraints.constrainedBiMap(
180 constrained.put(TEST_KEY, TEST_VALUE);
184 constrained.put("baz", TEST_VALUE);
188 constrained.put(TEST_KEY, 3);
192 constrained.putAll(ImmutableMap.of("baz", 3, TEST_KEY, 4));
196 constrained.forcePut(TEST_KEY, 3);
200 constrained.inverse().forcePut(TEST_VALUE, "baz");
204 constrained.inverse().forcePut(3, TEST_KEY);
208 assertEquals(Collections.emptySet(), constrained.entrySet());
213 Multimap<String, Integer> constrained = MapConstraints.constrainedMultimap(
216 constrained.put("foo", 1);
218 constrained.get("baz").add(3);
220 constrained.get("zig").addAll(Arrays.asList(5));
222 constrained.putAll("bee", Arrays.asList(7));
225 constrained.putAll(new ImmutableMultimap.Builder<String, Integer>()
229 constrained.putAll(new ImmutableMultimap.Builder<String, Integer>()
231 assertTrue(multimap.equals(constrained));
232 assertTrue(constrained.equals(multimap));
234 .is(ImmutableList.copyOf(constrained.entries()));
235 ASSERT.that(constrained.asMap().get("foo")).hasContentsInOrder(1);
236 assertNull(constrained.asMap().get("missing"));
237 assertEquals(multimap.asMap(), constrained.asMap());
238 assertEquals(multimap.values(), constrained.values());
239 assertEquals(multimap.keys(), constrained.keys());
240 assertEquals(multimap.keySet(), constrained.keySet());
241 assertEquals(multimap.toString(), constrained.toString());
242 assertEquals(multimap.hashCode(), constrained.hashCode());
256 assertFalse(constrained.asMap().values() instanceof Serializable);
258 constrained.asMap().values().iterator();
319 Multimap<String, Integer> constrained = MapConstraints.constrainedMultimap(
322 constrained.put(TEST_KEY, 1);
326 constrained.put("foo", TEST_VALUE);
330 constrained.put(TEST_KEY, TEST_VALUE);
334 constrained.get(TEST_KEY).add(1);
338 constrained.get("foo").add(TEST_VALUE);
342 constrained.get(TEST_KEY).add(TEST_VALUE);
346 constrained.get(TEST_KEY).addAll(Arrays.asList(1));
350 constrained.get("foo").addAll(Arrays.asList(1, TEST_VALUE));
354 constrained.get(TEST_KEY).addAll(Arrays.asList(1, TEST_VALUE));
358 constrained.putAll(TEST_KEY, Arrays.asList(1));
362 constrained.putAll("foo", Arrays.asList(1, TEST_VALUE));
366 constrained.putAll(TEST_KEY, Arrays.asList(1, TEST_VALUE));
370 constrained.putAll(new ImmutableMultimap.Builder<String, Integer>()
375 constrained.putAll(new ImmutableMultimap.Builder<String, Integer>()
380 constrained.putAll(new ImmutableMultimap.Builder<String, Integer>()
385 constrained.entries().add(Maps.immutableEntry(TEST_KEY, 1));
389 constrained.entries().addAll(Arrays.asList(
395 assertTrue(constrained.isEmpty());
396 constrained.put("foo", 1);
398 constrained.asMap().get("foo").add(TEST_VALUE);
402 constrained.asMap().values().iterator().next().add(TEST_VALUE);
406 ((Collection<Integer>) constrained.asMap().values().toArray()[0])
411 .is(ImmutableList.copyOf(constrained.entries()));
412 assertEquals(multimap.asMap(), constrained.asMap());
413 assertEquals(multimap.values(), constrained.values());
414 assertEquals(multimap.keys(), constrained.keys());
415 assertEquals(multimap.keySet(), constrained.keySet());
416 constrained.toString());
417 assertEquals(multimap.hashCode(), constrained.hashCode());
430 Multimap<String, Integer> constrained = MapConstraints.constrainedMultimap(
432 constrained.put("foo", 1);
433 assertTrue(constrained.get("foo").contains(1));
436 constrained.put(TEST_KEY, 1);
440 constrained.put("foo", TEST_VALUE);
444 constrained.get("foo").add(TEST_VALUE);
448 constrained.get(TEST_KEY).add(1);
451 assertEquals(1, constrained.size());
457 Map<String, Integer> constrained
462 = (Map.Entry) constrained.entrySet().toArray()[0];
472 Map<String, Integer> constrained
477 Set<Map.Entry<String, Integer>> entries = constrained.entrySet();
486 Multimap<String, Integer> constrained
492 constrained.asMap().entrySet().toArray()[0];
506 Multimap<String, Integer> constrained
511 = (Collection<Integer>) constrained.asMap().values().toArray()[0];
521 Multimap<String, Integer> constrained
526 Collection<Map.Entry<String, Integer>> entries = constrained.entries();
535 Multimap<String, Integer> constrained
540 Collection<Map.Entry<String, Integer>> entries = constrained.entries();
549 Multimap<String, Integer> constrained
555 = constrained.asMap().entrySet();
564 Multimap<String, Integer> constrained
570 = constrained.asMap().entrySet();
579 Map<String, Integer> constrained = MapConstraints.constrainedMap(
582 constrained.putAll(onceIterable);
583 assertEquals((Integer) 1, constrained.get("foo"));
588 Multimap<String, Integer> constrained = MapConstraints.constrainedMultimap(
592 constrained.putAll("foo", onceIterable);
593 assertEquals(ImmutableList.of(1), constrained.get("foo"));
598 Multimap<String, Integer> constrained = MapConstraints.constrainedMultimap(
602 constrained.putAll(onceIterable);
603 assertEquals(ImmutableList.of(1), constrained.get("foo"));
608 Multimap<String, Integer> constrained = MapConstraints.constrainedMultimap(
612 constrained.get("foo").addAll(onceIterable);
613 assertEquals(ImmutableList.of(1), constrained.get("foo"));
618 * iterator() methods. This verifies that the constrained map uses a
659 // TODO: Test serialization of constrained collections.