BlobName implements Function<Object, String> { public String apply(Object input) { checkArgument(checkNotNull(input, "input") instanceof Blob, "this function is only valid for Blobs!"); return checkNotNull(Blob.class.cast(input).getMetadata().getName(), "blobName"); }  String apply(Object input);  }
@Test public void testCorrect() throws SecurityException, NoSuchMethodException { Blob blob = BLOB_FACTORY.create(null); blob.getMetadata().setName("foo"); assertEquals(fn.apply(blob), "foo"); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testMustBeBlob() { fn.apply(new File("foo")); }
@Test(expectedExceptions = { NullPointerException.class, IllegalStateException.class }) public void testNullIsBad() { fn.apply(null); }