Search in sources :

Example 1 with DependencyList

use of com.vaadin.flow.component.internal.DependencyList in project flow by vaadin.

the class DependencyListTest method testAddingDuplicateDependencies.

private void testAddingDuplicateDependencies(LoadMode first, LoadMode second, LoadMode expected) {
    String url = "foo/bar.js";
    Type type = Type.JAVASCRIPT;
    // need to clear so that there is no leftovers
    deps = new DependencyList();
    deps.add(new Dependency(type, url, first));
    deps.add(new Dependency(type, url, second));
    Collection<Dependency> pendingSendToClient = deps.getPendingSendToClient();
    assertEquals("Expected to have only one dependency", 1, pendingSendToClient.size());
    assertEquals("Wrong load mode resolved", pendingSendToClient.iterator().next().getLoadMode(), expected);
}
Also used : DependencyList(com.vaadin.flow.component.internal.DependencyList) Type(com.vaadin.flow.shared.ui.Dependency.Type) Dependency(com.vaadin.flow.shared.ui.Dependency)

Example 2 with DependencyList

use of com.vaadin.flow.component.internal.DependencyList 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);
}
Also used : DependencyList(com.vaadin.flow.component.internal.DependencyList) UIInternals(com.vaadin.flow.component.internal.UIInternals) Dependency(com.vaadin.flow.shared.ui.Dependency) Test(org.junit.Test)

Aggregations

DependencyList (com.vaadin.flow.component.internal.DependencyList)2 Dependency (com.vaadin.flow.shared.ui.Dependency)2 UIInternals (com.vaadin.flow.component.internal.UIInternals)1 Type (com.vaadin.flow.shared.ui.Dependency.Type)1 Test (org.junit.Test)1