use of org.talend.dataprep.qa.dto.Folder in project data-prep by Talend.
the class FolderStep method createFolder.
@Then("^I create a folder with the following parameters :$")
public void createFolder(@NotNull Map<String, String> params) throws IOException {
String parentFolderName = params.get(ORIGIN);
String folder = suffixFolderName(params.get(FOLDER_NAME));
Folder parentFolder = folderUtil.searchFolder(parentFolderName);
Assert.assertNotNull(parentFolder);
Response response = api.createFolder(parentFolder.id, folder);
response.then().statusCode(200);
final String content = IOUtils.toString(response.getBody().asInputStream(), StandardCharsets.UTF_8);
Folder createdFolder = objectMapper.readValue(content, Folder.class);
Assert.assertEquals(createdFolder.path, "/" + folder);
List<Folder> folders = folderUtil.listFolders();
Set<Folder> splittedFolders = folderUtil.splitFolder(createdFolder, folders);
context.storeFolder(splittedFolders);
}
use of org.talend.dataprep.qa.dto.Folder in project data-prep by Talend.
the class PreparationStep method registerExistingPreparation.
@When("^I load the existing preparation called \"(.*)\"$")
public void registerExistingPreparation(String preparationFullname) throws IOException {
String preparationName = util.extractNameFromFullName(preparationFullname);
String prepPath = util.extractPathFromFullName(preparationFullname);
Folder prepFolder = folderUtil.searchFolder(prepPath);
FolderContent folderContent = folderUtil.listPreparation(prepPath);
if (folderContent != null) {
List<PreparationDetails> preparations = //
folderContent.preparations.stream().filter(p -> p.name.equals(preparationName)).collect(Collectors.toList());
assertEquals("More than one preparation with \"" + preparationFullname + "\" name founded.", 1, preparations.size());
PreparationDetails preparation = preparations.get(0);
context.storeExistingPreparationRef(preparation.id, preparation.name, prepFolder.getPath());
}
}
use of org.talend.dataprep.qa.dto.Folder in project data-prep by Talend.
the class PreparationStep method doesPrepExistsInFolder.
/**
* Check if a preparation of a given name exist in a specified folder.
*
* @param prepFullName the seeked preparation.
* @return <code>true</code> if the preparation is founded, <code>false</code> else.
* @throws IOException if the folder preparation listing fails.
*/
private boolean doesPrepExistsInFolder(String prepFullName) throws IOException {
boolean isPrepPresent = false;
String suffixedPrepName = getSuffixedPrepName(prepFullName);
String prepPath = util.extractPathFromFullName(prepFullName);
String prepId = context.getPreparationId(suffixedPrepName, prepPath);
FolderContent folderContent = folderUtil.listPreparation(prepPath);
if (folderContent != null) {
isPrepPresent = folderContent.preparations.stream().filter(p -> //
p.id.equals(prepId) && //
p.name.equals(suffixedPrepName)).count() == 1;
}
return isPrepPresent;
}
use of org.talend.dataprep.qa.dto.Folder in project data-prep by Talend.
the class GlobalStep method cleanAfter.
/**
* Clean the created objects in the test environment.
* This method must be called on the last scenario of each feature in order to keep the tests reentrant.
* It also can be called on demand to clean the context for the next scenario.
* First @After to be executed in OS context
* Second @After to be executed in EE context
*/
@After(value = "@CleanAfter", order = 300)
public void cleanAfter() {
LOGGER.debug("Cleaning IT context.");
Boolean cleanAfterOSStepIsOK = true;
// cleaning stored actions
context.clearAction();
// cleaning temporary files
context.clearTempFile();
// cleaning application's preparations
List<String> listPreparationDeletionPb = context.getPreparationIdsToDelete().stream().filter(preparationDeletionIsNotOK()).collect(Collectors.toList());
cleanAfterOSStepIsOK = listPreparationDeletionPb.size() == 0;
// cleaning preparations's related context
context.clearPreparationLists();
// cleaning application's datasets
List<String> listDatasetDeletionPb = context.getDatasetIdsToDelete().stream().filter(datasetDeletionIsNotOK()).collect(Collectors.toList());
cleanAfterOSStepIsOK &= listDatasetDeletionPb.size() == 0;
// cleaning dataset's related context
context.clearDatasetLists();
// cleaning application's folders
List<Folder> listFolderDeletionPb = context.getFolders().stream().filter(folderDeletionIsNotOK()).collect(Collectors.toList());
cleanAfterOSStepIsOK &= listFolderDeletionPb.size() == 0;
// cleaning folder's related context
context.clearFolders();
// cleaning all features context object
context.clearObject();
if (cleanAfterOSStepIsOK) {
LOGGER.info("The Clean After Step is Ok. All deletion were done.");
} else {
for (String prepId : listPreparationDeletionPb) {
LOGGER.warn("Pb in the deletion of preparation {}.", prepId);
}
for (String datasetId : listDatasetDeletionPb) {
LOGGER.warn("Pb in the deletion of dataset {}.", datasetId);
}
for (Folder folder : listFolderDeletionPb) {
LOGGER.warn("Pb in the deletion of folder {}.", folder.getPath());
}
LOGGER.warn("The Clean After Step has failed (OS side). All deletion were not done.");
throw new CleanAfterException("Fail to delete some elements : go to see the logs to obtain more details. Good luck luke. May the Force (may)be with you");
}
}
use of org.talend.dataprep.qa.dto.Folder in project data-prep by Talend.
the class FolderStep method createFolder.
@Then("^I create a folder with the following parameters :$")
public void createFolder(@NotNull DataTable dataTable) throws IOException {
Map<String, String> params = dataTable.asMap(String.class, String.class);
String parentFolderName = params.get(ORIGIN);
String folder = params.get(FOLDER_NAME);
Folder parentFolder = folderUtil.searchFolder(parentFolderName);
Assert.assertNotNull(parentFolder);
Response response = api.createFolder(parentFolder.id, folder);
response.then().statusCode(200);
final String content = IOUtils.toString(response.getBody().asInputStream(), StandardCharsets.UTF_8);
Folder createdFolder = objectMapper.readValue(content, Folder.class);
Assert.assertEquals(createdFolder.path, "/" + folder);
List<Folder> folders = folderUtil.listFolders();
Set<Folder> splittedFolders = folderUtil.splitFolder(createdFolder, folders);
context.storeFolder(splittedFolders);
}
Aggregations