use of org.eclipse.che.api.project.server.importer.ProjectImportOutputWSLineConsumer in project che by eclipse.
the class ProjectManagerWriteTest method testImportProject.
@Test
public void testImportProject() throws Exception {
ByteArrayOutputStream bout = new ByteArrayOutputStream();
String fileContent = "to be or not to be";
ZipOutputStream zipOut = new ZipOutputStream(bout);
zipOut.putNextEntry(new ZipEntry("folder1/"));
zipOut.putNextEntry(new ZipEntry("folder1/file1.txt"));
zipOut.putNextEntry(new ZipEntry("file1"));
zipOut.write(fileContent.getBytes());
zipOut.close();
final InputStream zip = new ByteArrayInputStream(bout.toByteArray());
final String importType = "_123_";
registerImporter(importType, zip);
SourceStorage sourceConfig = DtoFactory.newDto(SourceStorageDto.class).withType(importType);
pm.importProject("/testImportProject", sourceConfig, false, () -> new ProjectImportOutputWSLineConsumer("BATCH", "ws", 300));
RegisteredProject project = projectRegistry.getProject("/testImportProject");
assertNotNull(project);
// BASE
//System.out.println(">>> "+project.getProjectType());
assertNotNull(project.getBaseFolder().getChild("file1"));
assertEquals(fileContent, project.getBaseFolder().getChild("file1").getVirtualFile().getContentAsString());
}
use of org.eclipse.che.api.project.server.importer.ProjectImportOutputWSLineConsumer in project che by eclipse.
the class ProjectManagerWriteTest method testRemoveFolderForSourcesWhenImportingProjectIsFailed.
@Test
public void testRemoveFolderForSourcesWhenImportingProjectIsFailed() throws Exception {
final String projectPath = "/testImportProject";
final String importType = "_123_";
registerImporter(importType, null);
SourceStorage sourceConfig = DtoFactory.newDto(SourceStorageDto.class).withType(importType);
try {
pm.importProject(projectPath, sourceConfig, false, () -> new ProjectImportOutputWSLineConsumer("testImportProject", "ws", 300));
} catch (Exception e) {
}
boolean projectFolderExist = vfsProvider.getVirtualFileSystem().getRoot().hasChild(Path.of(projectPath));
assertFalse(projectFolderExist);
}
use of org.eclipse.che.api.project.server.importer.ProjectImportOutputWSLineConsumer in project che by eclipse.
the class ProjectManagerWriteTest method testImportProjectWithoutImporterFailed.
@Test
public void testImportProjectWithoutImporterFailed() throws Exception {
SourceStorage sourceConfig = DtoFactory.newDto(SourceStorageDto.class).withType("nothing");
try {
pm.importProject("/testImportProject", sourceConfig, false, () -> new ProjectImportOutputWSLineConsumer("testImportProject", "ws", 300));
fail("NotFoundException: Unable import sources project from 'null'. Sources type 'nothing' is not supported.");
} catch (NotFoundException e) {
}
}
Aggregations