Locator { public static List<ProgressCheck> loadFromCheckSpecs(final List<CheckSpec> checkSpecs) throws Exception { return loadFromCheckSpecs(checkSpecs, Util.getDefaultClassLoader()); } private  Locator(); static ProgressCheck loadProgressCheck(final String impl); static ProgressCheck loadProgressCheck(final String impl, final JsonObject config); static ProgressCheck loadProgressCheck(final String impl, final JsonObject config,
                                                  final ClassLoader classLoader); static ProgressCheck wrapWithAlias(final ProgressCheck progressCheck, final String alias); static List<ProgressCheck> loadFromCheckSpecs(final List<CheckSpec> checkSpecs); static List<ProgressCheck> loadFromCheckSpecs(final List<CheckSpec> checkSpecs,
                                                         final ClassLoader checkLoader);  }
@Test public void testLoadFromCheckSpecs_empty() throws Exception { assertEquals("empty list to empty list", new ArrayList<ProgressCheck>(), Locator .loadFromCheckSpecs(Collections.emptyList())); }
@Test public void testLoadFromCheckSpecs_singleImpl() throws Exception { assertEquals("single impl check", new ArrayList<ProgressCheck>(Collections.singletonList(new ACheck())), Locator.loadFromCheckSpecs(Collections.singletonList( CheckSpec.fromJson(key("impl", ACheck.class.getName()).get())))); }
@Test public void testLoadFromCheckSpecs_singleInline() throws Exception { assertEquals("single inline check is loaded", 1, Locator.loadFromCheckSpecs(Collections.singletonList( CheckSpec.fromJson(key("inlineScript", "function getCheckName() { return \"simple inline\"; }").get()))).size()); assertEquals("simple inline check name is same", "simple inline", Locator.loadFromCheckSpecs(Collections.singletonList( CheckSpec.fromJson(key("inlineScript", "function getCheckName() { return \"simple inline\"; }").get()))).get(0).getCheckName()); assertEquals("simple inline check name is alias", "alias for simple inline", Locator.loadFromCheckSpecs(Collections.singletonList( CheckSpec.fromJson(key("name", "alias for simple inline").key("inlineScript", "function getCheckName() { return \"simple inline\"; }").get()))).get(0).getCheckName()); }
@Test(expected = Exception.class) public void testLoadFromCheckSpecs_abstract() throws Exception { Locator.loadFromCheckSpecs(Collections.singletonList(CheckSpec.fromJson(key("name", "i am abstract").get()))); }
@Test(expected = Exception.class) public void testLoadFromCheckSpecs_unloadable() throws Exception { Locator.loadFromCheckSpecs(Collections.singletonList(CheckSpec.fromJson(key("impl", NotACheck.class.getName()).get()))); }