use of org.junit.Assert.assertTrue in project flow by vaadin.
the class BootstrapHandlerTest method empty_body_size_adds_margin_but_no_size_for_body.
// 3749
@Test
public void empty_body_size_adds_margin_but_no_size_for_body() throws InvalidRouteConfigurationException {
initUI(testUI, createVaadinRequest(), Collections.singleton(EmptyBodySizeAnnotated.class));
Document page = pageBuilder.getBootstrapPage(new BootstrapContext(request, null, session, testUI, this::contextRootRelativePath));
Elements allElements = page.head().getAllElements();
Optional<Element> styleTag = allElements.stream().filter(element -> element.tagName().equals("style")).findFirst();
Assert.assertTrue("Expected a style element in head.", styleTag.isPresent());
Assert.assertTrue("The first style tag should start with body style containing only margin", styleTag.get().toString().startsWith("<style type=\"text/css\">body {margin:0;}"));
}
use of org.junit.Assert.assertTrue in project flow by vaadin.
the class BootstrapHandlerTest method body_size_adds_styles_for_body.
// 2344
@Test
public void body_size_adds_styles_for_body() throws InvalidRouteConfigurationException {
initUI(testUI, createVaadinRequest(), Collections.singleton(BodySizeAnnotated.class));
Document page = pageBuilder.getBootstrapPage(new BootstrapContext(request, null, session, testUI, this::contextRootRelativePath));
Elements allElements = page.head().getAllElements();
Optional<Element> styleTag = allElements.stream().filter(element -> element.tagName().equals("style")).findFirst();
Assert.assertTrue("Expected a style element in head.", styleTag.isPresent());
Assert.assertTrue("The first style tag should start with body style from @BodySize", styleTag.get().toString().startsWith("<style type=\"text/css\">body {height:10px;width:20px;margin:0;}"));
}
use of org.junit.Assert.assertTrue in project flow by vaadin.
the class BootstrapHandlerTest method index_appended_to_head_in_npm.
@Test
public void index_appended_to_head_in_npm() throws InvalidRouteConfigurationException {
initUI(testUI, createVaadinRequest(), Collections.singleton(AliasLayout.class));
Document page = pageBuilder.getBootstrapPage(new BootstrapContext(request, null, session, testUI, this::contextRootRelativePath));
Elements allElements = page.head().getAllElements();
Assert.assertTrue("index.js should be added to head for ES6 browsers. (type module with crossorigin)", allElements.stream().map(Object::toString).anyMatch(element -> element.equals("<script type=\"module\" src=\"./" + VAADIN_MAPPING + "build/vaadin-bundle-1111.cache.js\" data-app-id=\"" + testUI.getInternals().getAppId() + "\" crossorigin></script>")));
}
use of org.junit.Assert.assertTrue in project OpenGrok by OpenGrok.
the class ProjectMessageTest method testDelete.
/**
* This test needs to perform indexing so that it can be verified that
* the delete message handling performs removal of the index data.
* @throws Exception
*/
@Test
public void testDelete() throws Exception {
String[] projectsToDelete = { "git", "svn" };
assertTrue("No point in running indexer tests without valid ctags", RuntimeEnvironment.getInstance().validateExuberantCtags());
// Add a group matching the project to be added.
String groupName = "gitgroup";
Group group = new Group(groupName, "git.*");
env.getGroups().add(group);
Assert.assertTrue(env.hasGroups());
Assert.assertEquals(1, env.getGroups().stream().filter(g -> g.getName().equals(groupName)).collect(Collectors.toSet()).size());
Assert.assertEquals(0, group.getRepositories().size());
Assert.assertEquals(0, group.getProjects().size());
// Firstly add some projects.
Message m = new ProjectMessage();
m.setText("add");
m.addTag("mercurial");
m.addTag("git");
m.addTag("svn");
Assert.assertEquals(0, env.getProjects().size());
Assert.assertEquals(0, env.getRepositories().size());
Assert.assertEquals(0, env.getProjectRepositoriesMap().size());
m.apply(env);
Assert.assertEquals(3, env.getProjects().size());
Assert.assertEquals(3, env.getRepositories().size());
Assert.assertEquals(3, env.getProjectRepositoriesMap().size());
// Check the group was populated properly.
Assert.assertEquals(1, group.getRepositories().size());
Assert.assertEquals(0, group.getProjects().size());
Assert.assertEquals(1, group.getRepositories().stream().filter(p -> p.getName().equals("git")).collect(Collectors.toSet()).size());
// Run the indexer (ala 'indexpart') so that data directory is populated.
ArrayList<String> subFiles = new ArrayList<>();
subFiles.add("/git");
subFiles.add("/mercurial");
subFiles.add("/svn");
ArrayList<String> repos = new ArrayList<>();
repos.add("/git");
repos.add("/mercurial");
repos.add("/svn");
// This is necessary so that repositories in HistoryGuru get populated.
// When 'indexpart' is run, this is called from setConfiguration() because
// of the -R option is present.
HistoryGuru.getInstance().invalidateRepositories(env.getRepositories());
env.setHistoryEnabled(true);
Indexer.getInstance().prepareIndexer(env, // don't search for repositories
false, // don't scan and add projects
false, // no default project
null, // don't list files
false, // don't create dictionary
false, // subFiles - needed when refreshing history partially
subFiles, // repositories - needed when refreshing history partially
repos, // don't zap cache
new ArrayList<>(), // don't list repos
false);
Indexer.getInstance().doIndexerExecution(true, null, null);
// Then remove multiple projects.
m.setText("delete");
m.setTags(new TreeSet<String>());
for (String p : projectsToDelete) {
m.addTag(p);
}
m.apply(env);
Assert.assertEquals(1, env.getProjects().size());
Assert.assertEquals(1, env.getRepositories().size());
Assert.assertEquals(1, env.getProjectRepositoriesMap().size());
// Test data removal.
File dataRoot = env.getDataRootFile();
for (String projectName : projectsToDelete) {
for (String dirName : new String[] { "historycache", IndexDatabase.XREF_DIR, IndexDatabase.INDEX_DIR }) {
File dir = new File(env.getDataRootFile(), dirName + File.separator + projectName);
Assert.assertFalse(dir.exists());
}
}
// Check that HistoryGuru no longer maintains the removed projects.
for (String p : projectsToDelete) {
Assert.assertFalse(HistoryGuru.getInstance().getRepositories().stream().map(ri -> ri.getDirectoryName()).collect(Collectors.toSet()).contains(repository.getSourceRoot() + File.separator + p));
}
// Check the group no longer contains the removed project.
Assert.assertEquals(0, group.getRepositories().size());
Assert.assertEquals(0, group.getProjects().size());
}
use of org.junit.Assert.assertTrue in project flow by vaadin.
the class BootstrapHandlerTest method theme_contents_added_also_when_theme_in_super_class.
// 3384
@Test
public void theme_contents_added_also_when_theme_in_super_class() throws InvalidRouteConfigurationException {
initUI(testUI, createVaadinRequest(), Collections.singleton(ExtendingView.class));
Document page = BootstrapHandler.getBootstrapPage(new BootstrapContext(request, null, session, testUI));
Elements allElements = page.head().getAllElements();
Assert.assertTrue("Custom style should have been added to head.", allElements.stream().map(Object::toString).anyMatch(element -> element.equals("<link rel=\"import\" href=\"./frontend/bower_components/vaadin-lumo-styles/color.html\">")));
allElements = page.body().getAllElements();
// Note element 0 is the full head element.
assertStringEquals("Custom style should have been added to head.", "<custom-style><style include=\"lumo-typography\"></style></custom-style>", allElements.get(2).toString());
Assert.assertTrue("Style should have been wrapped in custom style", page.body().toString().contains("<custom-style><style include=\"lumo-typography\"></style></custom-style>"));
}
Aggregations