use of com.vaadin.flow.server.frontend.scanner.FrontendDependencies in project flow by vaadin.
the class AbstractNodeUpdatePackagesTest method versionsMatch_noCleanUp.
@Test
public void versionsMatch_noCleanUp() throws IOException {
// TODO: Fixme
FrontendDependencies frontendDependencies = Mockito.mock(FrontendDependencies.class);
Map<String, String> packages = new HashMap<>();
packages.put("@polymer/iron-list", "3.0.2");
packages.put("@vaadin/vaadin-confirm-dialog", "1.1.4");
packages.put("@vaadin/vaadin-checkbox", "2.2.10");
packages.put("@polymer/iron-icon", "3.0.1");
packages.put("@vaadin/vaadin-time-picker", "2.0.2");
// packages.put(VAADIN_CORE, "1.1.1");
Mockito.when(frontendDependencies.getPackages()).thenReturn(packages);
packageUpdater = new TaskUpdatePackages(classFinder, frontendDependencies, baseDir, generatedDir, resourcesDir, false, false, TARGET, featureFlags);
// Generate package json in a proper format first
packageCreator.execute();
makeNodeModulesAndPackageLock();
Files.write(packageLock.toPath(), Collections.singletonList(stringify(makePackageLock("1.1.1"))));
packageUpdater.execute();
// nothing is removed
Assert.assertTrue(mainNodeModules.exists());
Assert.assertTrue(appNodeModules.exists());
Assert.assertTrue(packageLock.exists());
}
use of com.vaadin.flow.server.frontend.scanner.FrontendDependencies in project flow by vaadin.
the class AbstractNodeUpdatePackagesTest method generatePackageJson_sameDependencies_updaterIsNotModified.
@Test
public void generatePackageJson_sameDependencies_updaterIsNotModified() {
FrontendDependencies frontendDependencies = Mockito.mock(FrontendDependencies.class);
Map<String, String> packages = new HashMap<>();
packages.put("@polymer/iron-list", "3.0.2");
packages.put("@vaadin/vaadin-confirm-dialog", "1.1.4");
packages.put("@vaadin/vaadin-checkbox", "2.2.10");
packages.put("@polymer/iron-icon", "3.0.1");
packages.put("@vaadin/vaadin-time-picker", "2.0.2");
Mockito.when(frontendDependencies.getPackages()).thenReturn(packages);
packageUpdater = new TaskUpdatePackages(classFinder, frontendDependencies, baseDir, generatedDir, resourcesDir, false, false, TARGET, featureFlags);
packageCreator.execute();
packageUpdater.execute();
// generate it one more time, the content will be different since
// packageCreator has not added its content
packageUpdater.execute();
Assert.assertFalse("Modification flag should be false when no dependencies changed.", packageUpdater.modified);
}
use of com.vaadin.flow.server.frontend.scanner.FrontendDependencies in project flow by vaadin.
the class AbstractNodeUpdatePackagesTest method frameworkManagedPackages_versionsAreUpdated.
@Test
public void frameworkManagedPackages_versionsAreUpdated() throws IOException {
FrontendDependencies frontendDependencies = Mockito.mock(FrontendDependencies.class);
Map<String, String> packages = new HashMap<>();
packages.put("@polymer/iron-list", "3.0.2");
packages.put("@vaadin/vaadin-confirm-dialog", "1.1.4");
packages.put("@vaadin/vaadin-checkbox", "2.2.10");
packages.put("@polymer/iron-icon", "3.0.1");
packages.put("@vaadin/vaadin-time-picker", "2.0.2");
Mockito.when(frontendDependencies.getPackages()).thenReturn(packages);
packageUpdater = new TaskUpdatePackages(classFinder, frontendDependencies, baseDir, generatedDir, resourcesDir, false, false, TARGET, featureFlags);
packageCreator.execute();
packageUpdater.execute();
JsonObject dependencies = getPackageJson(packageJson).getObject(DEPENDENCIES);
for (Map.Entry<String, String> entry : packages.entrySet()) {
Assert.assertTrue(dependencies.hasKey(entry.getKey()));
Assert.assertEquals(entry.getValue(), dependencies.getString(entry.getKey()));
}
packages.clear();
packages.put("@polymer/iron-list", "3.1.0");
packages.put("@vaadin/vaadin-confirm-dialog", "2.0.0");
packages.put("@vaadin/vaadin-checkbox", "3.1.1");
packages.put("@polymer/iron-icon", "3.0.3");
packages.put("@vaadin/vaadin-time-picker", "2.0.3");
packageUpdater.execute();
dependencies = getPackageJson(packageJson).getObject(DEPENDENCIES);
for (Map.Entry<String, String> entry : packages.entrySet()) {
Assert.assertTrue(dependencies.hasKey(entry.getKey()));
Assert.assertEquals(entry.getValue(), dependencies.getString(entry.getKey()));
}
}
use of com.vaadin.flow.server.frontend.scanner.FrontendDependencies in project flow by vaadin.
the class AbstractNodeUpdatePackagesTest method generatePackageJson_noDependencies_updaterIsNotModified.
@Test
public void generatePackageJson_noDependencies_updaterIsNotModified() {
FrontendDependencies frontendDependencies = Mockito.mock(FrontendDependencies.class);
Map<String, String> packages = new HashMap<>();
Mockito.when(frontendDependencies.getPackages()).thenReturn(packages);
packageUpdater = new TaskUpdatePackages(classFinder, frontendDependencies, baseDir, generatedDir, resourcesDir, false, false, TARGET, featureFlags);
packageCreator.execute();
packageUpdater.execute();
Assert.assertTrue("Modification flag should be true as we have added default dependencies.", packageUpdater.modified);
// generate it one more time
packageUpdater.execute();
Assert.assertFalse("Modification flag should be false when there has never been dependencies.", packageUpdater.modified);
}
use of com.vaadin.flow.server.frontend.scanner.FrontendDependencies in project flow by vaadin.
the class AbstractNodeUpdatePackagesTest method generatePackageJson_removedDependencies_updaterIsModified.
@Test
public void generatePackageJson_removedDependencies_updaterIsModified() {
FrontendDependencies frontendDependencies = Mockito.mock(FrontendDependencies.class);
Map<String, String> packages = new HashMap<>();
packages.put("@polymer/iron-list", "3.0.2");
packages.put("@vaadin/vaadin-confirm-dialog", "1.1.4");
packages.put("@vaadin/vaadin-checkbox", "2.2.10");
packages.put("@polymer/iron-icon", "3.0.1");
packages.put("@vaadin/vaadin-time-picker", "2.0.2");
Mockito.when(frontendDependencies.getPackages()).thenReturn(packages);
packageUpdater = new TaskUpdatePackages(classFinder, frontendDependencies, baseDir, generatedDir, resourcesDir, false, false, TARGET, featureFlags);
packageCreator.execute();
packageUpdater.execute();
packages.remove("@vaadin/vaadin-checkbox");
// generate it one more time, the content will be different since
// packageCreator has not added its content
packageUpdater.execute();
Assert.assertTrue("Modification flag should be true when dependency removed.", packageUpdater.modified);
}
Aggregations