### Question:
Validator { public static void checkNullOrNonNullNonEmptyEntries( @Nullable Collection<String> values, String propertyName) { if (values == null) { return; } for (String value : values) { Preconditions.checkNotNull( value, "Property '" + propertyName + "' cannot contain null entries"); Preconditions.checkArgument( !value.trim().isEmpty(), "Property '" + propertyName + "' cannot contain empty strings"); } }  static void checkNotNullAndNotEmpty(@Nullable String value, String propertyName); static void checkNullOrNotEmpty(@Nullable String value, String propertyName); static void checkNotNullAndNotEmpty(@Nullable Collection<?> value, String propertyName); static void checkNullOrNonNullNonEmptyEntries(
      @Nullable Collection<String> values, String propertyName); static void checkNullOrNonNullNonEmptyEntries(
      @Nullable Map<String, String> values, String propertyName); static void checkNullOrNonNullEntries(
      @Nullable Collection<?> values, String propertyName); static void checkEquals(
      @Nullable String value, String propertyName, String expectedValue);  }### Answer:
@Test public void testCheckNullOrNonNullNonEmptyEntries_nullMapPass() { Validator.checkNullOrNonNullNonEmptyEntries((Map<String, String>) null, "test"); }
@Test public void testCheckNullOrNonNullNonEmptyEntries_emptyMapPass() { Validator.checkNullOrNonNullNonEmptyEntries(ImmutableMap.of(), "test"); }
@Test public void testCheckNullOrNonNullNonEmptyEntries_mapWithValuesPass() { Validator.checkNullOrNonNullNonEmptyEntries( ImmutableMap.of("key1", "val1", "key2", "val2"), "test"); }
@Test public void testCheckNullOrNonNullNonEmptyEntries_mapNullKeyFail() { try { Validator.checkNullOrNonNullNonEmptyEntries(Collections.singletonMap(null, "val1"), "test"); Assert.fail(); } catch (NullPointerException npe) { Assert.assertEquals("Property 'test' cannot contain null keys", npe.getMessage()); } }
@Test public void testCheckNullOrNonNullNonEmptyEntries_mapEmptyKeyFail() { try { Validator.checkNullOrNonNullNonEmptyEntries(Collections.singletonMap(" ", "val1"), "test"); Assert.fail(); } catch (IllegalArgumentException iae) { Assert.assertEquals("Property 'test' cannot contain empty string keys", iae.getMessage()); } }
@Test public void testCheckNullOrNonNullNonEmptyEntries_mapNullValueFail() { try { Validator.checkNullOrNonNullNonEmptyEntries(Collections.singletonMap("key1", null), "test"); Assert.fail(); } catch (NullPointerException npe) { Assert.assertEquals("Property 'test' cannot contain null values", npe.getMessage()); } }
@Test public void testCheckNullOrNonNullNonEmptyEntries_mapEmptyValueFail() { try { Validator.checkNullOrNonNullNonEmptyEntries(Collections.singletonMap("key1", " "), "test"); Assert.fail(); } catch (IllegalArgumentException iae) { Assert.assertEquals("Property 'test' cannot contain empty string values", iae.getMessage()); } }
@Test public void testCheckNullOrNonNullNonEmptyEntries_nullPass() { Validator.checkNullOrNonNullNonEmptyEntries((List<String>) null, "test"); }
@Test public void testCheckNullOrNonNullNonEmptyEntries_emptyPass() { Validator.checkNullOrNonNullNonEmptyEntries(ImmutableList.of(), "test"); }
@Test public void testCheckNullNonNullNonEmptyEntries_valuesPass() { Validator.checkNullOrNonNullNonEmptyEntries(ImmutableList.of("first", "second"), "test"); }
@Test public void testCheckNullNonNullNonEmptyEntries_nullValueFail() { try { Validator.checkNullOrNonNullNonEmptyEntries(Arrays.asList("first", null), "test"); Assert.fail(); } catch (NullPointerException npe) { Assert.assertEquals("Property 'test' cannot contain null entries", npe.getMessage()); } }
@Test public void testCheckNullOrNonNullNonEmptyEntries_emptyValueFail() { try { Validator.checkNullOrNonNullNonEmptyEntries(ImmutableList.of("first", " "), "test"); Assert.fail(); } catch (IllegalArgumentException iae) { Assert.assertEquals("Property 'test' cannot contain empty strings", iae.getMessage()); } }