### Question:
ShortNameRenderer { public String shorten( String uri, boolean memoise ) { String shortName = lookupURI( uri ); if (shortName == null) { shortName = shortForm( uri ); if (!shortName.equals( uri ) && memoise) { addShortName( shortForm( uri ), uri ); } } return shortName; } ShortNameRenderer( ShortnameService sns, Iterable<Binding<Resource>> bindings ); ShortnameService shortNameService(); ShortnameService shortNameService( boolean required ); boolean isDatatype( String type ); Resource asResource( RDFNode r ); Resource asResource( String s ); String expand( String shortName ); String shorten( String uri, boolean memoise ); String shorten( String uri ); boolean hasShortNameService(); boolean isKnownShortnamePath( String path );  }### Answer:
@Test public void testShorten1() { ShortnameService sns = stubShortNameService(); ShortNameRenderer snr = new ShortNameRenderer( sns, null ); assertEquals( "name_p", snr.shorten( "http: assertEquals( "_foo", snr.shorten( "http: }
@Test public void testShorten2() { List<Binding<Resource>> bindings = new ArrayList<Binding<Resource>>(); bindings.add( new Binding<Resource>( "foo1", ResourceFactory.createResource( "http: final ShortNameRenderer snr = new ShortNameRenderer( null, bindings ); assertEquals( "foo1", snr.shorten( "http: }