use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class ProjectServiceTest method testResolveSources.
@Test
public void testResolveSources() throws Exception {
VirtualFile root = pm.getProjectsRoot().getVirtualFile();
root.createFolder("testEstimateProjectGood").createFolder("check");
root.createFolder("testEstimateProjectBad");
final ValueProviderFactory vpf1 = projectFolder -> new ReadonlyValueProvider() {
@Override
public List<String> getValues(String attributeName) throws ValueStorageException {
VirtualFileEntry file;
try {
file = projectFolder.getChild("check");
} catch (ServerException e) {
throw new ValueStorageException(e.getMessage());
}
if (file == null) {
throw new ValueStorageException("Check not found");
}
return (List<String>) singletonList("checked");
}
};
ProjectTypeDef pt = new ProjectTypeDef("testEstimateProjectPT", "my testEstimateProject type", true, false) {
{
addVariableDefinition("calculated_attribute", "attr description", true, vpf1);
addVariableDefinition("my_property_1", "attr description", true);
addVariableDefinition("my_property_2", "attr description", false);
}
};
ptRegistry.registerProjectType(pt);
ContainerResponse response = launcher.service(GET, format("http://localhost:8080/api/project/resolve/%s", "testEstimateProjectGood"), "http://localhost:8080/api", null, null, null);
assertEquals(response.getStatus(), 200, "Error: " + response.getEntity());
List<SourceEstimation> result = (List<SourceEstimation>) response.getEntity();
assertTrue(result.size() > 0);
boolean m = false;
for (SourceEstimation est : result) {
if (est.getType().equals("testEstimateProjectPT")) {
assertTrue(est.isMatched());
m = true;
}
}
assertTrue(m);
}
use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class LocalVirtualFileTest method copiesFolderAndReplaceExistedItem.
@Test
public void copiesFolderAndReplaceExistedItem() throws Exception {
VirtualFile folder = getRoot().createFolder(generateFolderName());
VirtualFile file = folder.createFile(generateFileName(), DEFAULT_CONTENT);
VirtualFile targetFolder = getRoot().createFolder(generateFolderName());
targetFolder.createFolder(folder.getName());
VirtualFile copiedFolder = folder.copyTo(targetFolder, null, true);
VirtualFile copiedFile = copiedFolder.getChild(Path.of(file.getName()));
assertionHelper.assertThatIoFileExists(copiedFolder.getPath());
assertionHelper.assertThatIoFilesHaveSameContent(file.getPath(), copiedFile.getPath());
}
use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class LocalVirtualFileTest method failsUnlockFileWhenLockTokenIsNull.
@Test
public void failsUnlockFileWhenLockTokenIsNull() throws Exception {
VirtualFile root = getRoot();
VirtualFile file = root.createFile(generateFileName(), DEFAULT_CONTENT);
file.lock(0);
try {
file.unlock(null);
thrown.expect(ForbiddenException.class);
} catch (ForbiddenException e) {
assertionHelper.assertThatLockIoFileExists(file.getPath());
assertTrue(file.isLocked());
}
}
use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class LocalVirtualFileTest method failsZipFile.
@Test
public void failsZipFile() throws Exception {
VirtualFile root = getRoot();
VirtualFile file = root.createFile(generateFileName(), DEFAULT_CONTENT);
thrown.expect(ForbiddenException.class);
file.zip();
}
use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class LocalVirtualFileTest method addFolderInSearcherAfterExtractTarArchive.
@Test
public void addFolderInSearcherAfterExtractTarArchive() throws Exception {
VirtualFile folder = getRoot().createFolder(generateFolderName());
Mockito.reset(searcher);
Archiver archiver = mock(Archiver.class);
when(archiverFactory.createArchiver(eq(folder), eq("tar"))).thenReturn(archiver);
folder.untar(new ByteArrayInputStream(new byte[0]), false, 0);
verify(searcher).add(folder);
}
Aggregations