use of com.vaadin.flow.shared.ui.Dependency in project flow by vaadin.
the class ComponentTest method usesChain.
@Test
public void usesChain() {
UIInternals internals = new UI().getInternals();
internals.addComponentDependencies(UsesUsesComponentWithDependencies.class);
Map<String, Dependency> pendingDependencies = getDependenciesMap(internals.getDependencyList().getPendingSendToClient());
Assert.assertEquals(5, pendingDependencies.size());
assertDependency(Dependency.Type.HTML_IMPORT, "usesuses.html", pendingDependencies);
assertDependency(Dependency.Type.HTML_IMPORT, "html.html", pendingDependencies);
assertDependency(Dependency.Type.JAVASCRIPT, "uses.js", pendingDependencies);
assertDependency(Dependency.Type.JAVASCRIPT, "js.js", pendingDependencies);
assertDependency(Dependency.Type.STYLESHEET, "css.css", pendingDependencies);
}
use of com.vaadin.flow.shared.ui.Dependency in project flow by vaadin.
the class ComponentTest method circularDependencies.
@Test
public void circularDependencies() {
UIInternals internals = new UI().getInternals();
DependencyList dependencyList = internals.getDependencyList();
internals.addComponentDependencies(CircularDependencies1.class);
Map<String, Dependency> pendingDependencies = getDependenciesMap(dependencyList.getPendingSendToClient());
Assert.assertEquals(2, pendingDependencies.size());
assertDependency(Dependency.Type.JAVASCRIPT, "dep1.js", pendingDependencies);
assertDependency(Dependency.Type.JAVASCRIPT, "dep2.js", pendingDependencies);
internals = new UI().getInternals();
dependencyList = internals.getDependencyList();
internals.addComponentDependencies(CircularDependencies2.class);
pendingDependencies = getDependenciesMap(dependencyList.getPendingSendToClient());
Assert.assertEquals(2, pendingDependencies.size());
assertDependency(Dependency.Type.JAVASCRIPT, "dep2.js", pendingDependencies);
assertDependency(Dependency.Type.JAVASCRIPT, "dep1.js", pendingDependencies);
}
use of com.vaadin.flow.shared.ui.Dependency in project flow by vaadin.
the class ComponentTest method assertDependency.
private void assertDependency(Dependency.Type type, String url, Map<String, Dependency> pendingDependencies) {
Dependency dependency = pendingDependencies.get("frontend://" + url);
Assert.assertNotNull("Could not locate a dependency object for url=" + url, dependency);
Assert.assertEquals(type, dependency.getType());
Assert.assertEquals("frontend://" + url, dependency.getUrl());
}
use of com.vaadin.flow.shared.ui.Dependency in project flow by vaadin.
the class DefaultTemplateParserTest method defaultParser_useDependencyFilters_noHtmlDependencies_throws.
@Test(expected = IllegalStateException.class)
public void defaultParser_useDependencyFilters_noHtmlDependencies_throws() {
DependencyFilter filter = (list, context) -> {
list.clear();
list.add(new Dependency(Type.STYLESHEET, "something.css", LoadMode.EAGER));
list.add(new Dependency(Type.JAVASCRIPT, "something.js", LoadMode.EAGER));
return list;
};
Mockito.when(service.getDependencyFilters()).thenReturn(Collections.singletonList(filter));
DefaultTemplateParser.getInstance().getTemplateContent(ImportsInspectTemplate.class, "foo");
}
use of com.vaadin.flow.shared.ui.Dependency in project flow by vaadin.
the class DependencyLoaderTest method loadMultiple.
@Test
public void loadMultiple() {
String TEST_JS_URL = "http://foo.bar/baz.js";
String TEST_JS_URL2 = "/my.js";
String TEST_CSS_URL = "https://x.yz/styles.css";
new DependencyLoader(registry).loadDependencies(createDependenciesMap(new Dependency(Dependency.Type.JAVASCRIPT, TEST_JS_URL, LoadMode.EAGER).toJson(), new Dependency(Dependency.Type.JAVASCRIPT, TEST_JS_URL2, LoadMode.EAGER).toJson(), new Dependency(Dependency.Type.STYLESHEET, TEST_CSS_URL, LoadMode.EAGER).toJson()));
assertEquals(Arrays.asList(TEST_JS_URL, TEST_JS_URL2), mockResourceLoader.loadingScripts);
assertEquals(Collections.singletonList(TEST_CSS_URL), mockResourceLoader.loadingStyles);
}
Aggregations