LinkManager { public abstract Configurer getConfigurer(URI uri);  static LinkManager getInstance(); static String extractNameFromURI(URI uri); static URI replaceName(URI uri, String name); abstract Configurer getConfigurer(URI uri); abstract List<URI> listURIs();  }
@Test public void onceQueriedChoiceValuesStayValid() throws Exception { Configurer configurer = sut.getConfigurer(newURI("ardulink: choiceValuesOfDNowAre("x", "y"); assertThat(configurer.getAttribute("d").getChoiceValues(), is(new Object[] { "x", "y" })); choiceValuesOfDNowAre("1", "2"); configurer.getAttribute("d").setValue("y"); assertThat(configurer.getAttribute("d").getChoiceValues(), is(new Object[] { "1", "2" })); }
@Test public void canLoadViaMetaInfServicesArdulinkLinkfactoryWithoutConfig() { Link link = sut.getConfigurer(newURI("ardulink: assertThat(link, is(instanceOf(AlLinkWithoutArealLinkFactoryWithoutConfig.class))); }
@Test public void canLoadViaMetaInfServicesArdulinkLinkfactoryWithConfig() { Link link = sut.getConfigurer(newURI("ardulink: assertThat(link, is(instanceOf(AlLinkWithoutArealLinkFactoryWithConfig.class))); }
@Test public void nonExistingNameWitllThrowRTE() throws IOException { exception.expect(RuntimeException.class); exception.expectMessage(allOf(containsString("registered"), containsString("factory"))); sut.getConfigurer(newURI("ardulink: }
@Test public void canLoadDummyLinkViaAlias() throws Exception { withRegistered(new AliasUsingLinkFactory()).execute(new Statement() { @Override public void execute() { sut.getConfigurer(aliasUri()); } }); }
@Test public void nameHasPriorityOverAlias() throws Exception { AliasUsingLinkFactory factory = new AliasUsingLinkFactory(); final String dummyLinkFactoryName = new DummyLinkFactory().getName(); assert aliasNames(factory).contains(dummyLinkFactoryName); final AliasUsingLinkFactory spy = spy(factory); withRegistered(spy).execute(new Statement() { @Override public void execute() throws IOException { Link link = sut.getConfigurer(newURI("ardulink: verify(spy, never()).newLink(any(LinkConfig.class)); link.close(); } }); }