### Question:
StatusFactory { public Map<String, Boolean> from(final Object data) { if (!(data instanceof Map<?, ?>)) { throw new IllegalArgumentException( String.format("Unexpected data format :: %s", data.toString())); } @SuppressWarnings("unchecked") final Map<Object, Object> entries = (Map<Object, Object>) data; return entries .entrySet() .stream() .map(entry -> { if (!(entry.getKey() instanceof String)) { throw new IllegalArgumentException( String.format("Unexpected data format :: %s", entry.getKey())); } if (!(entry.getValue() instanceof Boolean)) { throw new IllegalArgumentException( String.format("Unexpected data format :: %s", entry.getValue())); } final Boolean status = (Boolean) entry.getValue(); return Pair.of((String) entry.getKey(), status); }) .collect(Collectors.toMap(Pair::getKey, Pair::getValue)); }  Map<String, Boolean> from(final Object data);  }### Answer:
@Test public void fromTest() { final Map<String, Boolean> expected = ImmutableMap.of( "foo", true, "bar", false ); final Map<String, Boolean> actual = statusFactory.from(expected); assertEquals(expected, actual); }
@Test(expected = IllegalArgumentException.class) public void fromNonMapTest() { statusFactory.from(Collections.<Integer>emptyList()); }
@Test(expected = IllegalArgumentException.class) public void fromInvalidKeyTest() { statusFactory.from(ImmutableMap.of(1, true)); }
@Test(expected = IllegalArgumentException.class) public void fromInvalidValueTest() { statusFactory.from(ImmutableMap.of("foo", 1)); }