Skip to content

Commit

Permalink
Enhance ProjectSmartImportTest assertion
Browse files Browse the repository at this point in the history
  • Loading branch information
akurtakov authored and HannesWell committed Oct 20, 2024
1 parent cc83723 commit b29e97a
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018, 2023 Red Hat, Inc. and others.
* Copyright (c) 2018, 2024 Red Hat, Inc. and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -51,10 +51,10 @@ public class ProjectSmartImportTest {
@Parameters(name = "{0}")
public static Object[][] projects() {
return new Object[][] { //
{ "JavaEclipseProject", List.of("org.eclipse.jdt.core.javanature") }, //
{ "FeatureProject", List.of("org.eclipse.pde.FeatureNature") }, //
{ "PlainEclipseProject", List.of() }, //
{ "PlainJavaProject", List.of("org.eclipse.jdt.core.javanature") }, //
{ "JavaEclipseProject", List.of("org.eclipse.jdt.core.javanature") }, //
{ "FeatureProject", List.of("org.eclipse.pde.FeatureNature") }, //
{ "PlainEclipseProject", List.of() }, //
{ "PlainJavaProject", List.of("org.eclipse.jdt.core.javanature") }, //
};
}

Expand Down Expand Up @@ -86,15 +86,15 @@ private static Path getErrorLogFile() {
}

@Test
public void testImport() throws CoreException, InterruptedException {
public void testImport() throws CoreException, InterruptedException, IOException {
File projectPath = new File(workingDirectory.getRoot(), projectName);

var job = new org.eclipse.ui.internal.wizards.datatransfer.SmartImportJob(projectPath, null, true, false);
job.run(new NullProgressMonitor());
job.join();

// check imported project
assertThat(getErrorLogFile()).isEmptyFile();
assertThat(getErrorLogFile()).as("Content: %s", Files.readString(getErrorLogFile())).isEmptyFile();
IWorkspaceRoot workspace = ResourcesPlugin.getWorkspace().getRoot();
assertThat(workspace.getProjects()).hasSize(1).allMatch(p -> p.getName().equals(projectName));
IProject project = workspace.getProject(projectName);
Expand All @@ -116,7 +116,7 @@ private void checkProblemsView(IProject project) throws CoreException {
}).toList();
assertTrue(
"There should be no errors in imported project: " + System.lineSeparator() + errorMarkers.stream()
.map(String::valueOf).collect(Collectors.joining(System.lineSeparator())),
.map(String::valueOf).collect(Collectors.joining(System.lineSeparator())),
errorMarkers.isEmpty());

}
Expand Down

0 comments on commit b29e97a

Please sign in to comment.