Links { public static Link getDefault() { return getLink(getDefaultConfigurer()); } private  Links(); static Link getDefault(); static Configurer getDefaultConfigurer(); static Link getLink(String uri); static Link getLink(URI uri); static Link getLink(Configurer configurer); @LapsedWith(module = JDK8, value = "Stream") static Configurer setChoiceValues(Configurer configurer); static boolean isConfigured(ConfigAttribute attribute);  }
@Test public void whenRequestingDefaultLinkReturnsFirstAvailableConnectionIfSerialNotAvailable() throws IOException { Link link = Links.getDefault(); assertThat(getConnection(link), instanceOf(DummyConnection.class)); close(link); }
@Test public void whenRequestingDefaultLinkSerialHasPriorityOverAllOthers() throws Exception { final LinkFactory<LinkConfig> serial = spy(factoryNamed(serial())); withRegistered(factoryNamed(serialDash("a")), factoryNamed("a"), serial, factoryNamed("z"), factoryNamed(serialDash("z"))).execute(new Statement() { @Override public void execute() throws Exception { assertLinkWasCreatedBy(Links.getDefault(), serial); } }); }
@Test public void whenRequestingDefaultLinkStartingWithSerialDashHasPriorityOverAllOthers() throws Exception { final LinkFactory<LinkConfig> serialDashAnything = spy(factoryNamed(serialDash("appendix-does-not-matter"))); withRegistered(factoryNamed("a"), serialDashAnything, factoryNamed("z")).execute(new Statement() { @Override public void execute() throws Exception { assertLinkWasCreatedBy(Links.getDefault(), serialDashAnything); } }); }
@Test public void isConfiguredForAllChoiceValues() throws IOException { Link link = Links.getDefault(); DummyLinkConfig config = getConnection(link).getConfig(); assertThat(config.getA(), is("aVal1")); close(link); }