PrefixToResourceMetadata implements Function<String, StorageMetadata> { public StorageMetadata apply(String from) { checkNotNull(from, "prefix"); MutableStorageMetadata returnVal = new MutableStorageMetadataImpl(); returnVal.setType(StorageType.RELATIVE_PATH); returnVal.setName(from); return returnVal; }  StorageMetadata apply(String from);  }
@Test public void testCorrect() throws SecurityException, NoSuchMethodException { MutableStorageMetadata expected = new MutableStorageMetadataImpl(); expected.setType(StorageType.RELATIVE_PATH); expected.setName("foo"); assertEquals(fn.apply("foo"), expected); }
@Test(expectedExceptions = { NullPointerException.class, IllegalStateException.class }) public void testNullIsBad() { fn.apply(null); }