@Test public void returns_no_specimen_if_context_returns_non_url_object() { when(this.mockSpecimenContext.resolve(URL.class)).thenReturn("string"); Object specimen = this.uriBuilder.create(URI.class, this.mockSpecimenContext); assertEquals(new NoSpecimen(), specimen); }
@Override public Object create(Object request, SpecimenContext context) { if (!request.equals(URI.class)) { return new NoSpecimen(); } Object specimen = context.resolve(URL.class); if (!(specimen instanceof URL)) { return new NoSpecimen(); } URL url = (URL) specimen; try { return url.toURI(); } catch (URISyntaxException e) { return new NoSpecimen(); } }
UriBuilder implements SpecimenBuilder { @Override public Object create(Object request, SpecimenContext context) { if (!request.equals(URI.class)) { return new NoSpecimen(); } Object specimen = context.resolve(URL.class); if (!(specimen instanceof URL)) { return new NoSpecimen(); } URL url = (URL) specimen; try { return url.toURI(); } catch (URISyntaxException e) { return new NoSpecimen(); } } }
UriBuilder implements SpecimenBuilder { @Override public Object create(Object request, SpecimenContext context) { if (!request.equals(URI.class)) { return new NoSpecimen(); } Object specimen = context.resolve(URL.class); if (!(specimen instanceof URL)) { return new NoSpecimen(); } URL url = (URL) specimen; try { return url.toURI(); } catch (URISyntaxException e) { return new NoSpecimen(); } }  }
UriBuilder implements SpecimenBuilder { @Override public Object create(Object request, SpecimenContext context) { if (!request.equals(URI.class)) { return new NoSpecimen(); } Object specimen = context.resolve(URL.class); if (!(specimen instanceof URL)) { return new NoSpecimen(); } URL url = (URL) specimen; try { return url.toURI(); } catch (URISyntaxException e) { return new NoSpecimen(); } }  @Override Object create(Object request, SpecimenContext context); }
UriBuilder implements SpecimenBuilder { @Override public Object create(Object request, SpecimenContext context) { if (!request.equals(URI.class)) { return new NoSpecimen(); } Object specimen = context.resolve(URL.class); if (!(specimen instanceof URL)) { return new NoSpecimen(); } URL url = (URL) specimen; try { return url.toURI(); } catch (URISyntaxException e) { return new NoSpecimen(); } }  @Override Object create(Object request, SpecimenContext context);  }