Search in sources :

Example 1 with PreparationDetails

use of org.talend.dataprep.qa.dto.PreparationDetails in project data-prep by Talend.

the class ActionStep method getLastActionfromPreparation.

/**
 * Get the last {@link Action} from a preparation.
 *
 * @param preparationId the preparation id.
 * @return the last preparation {@link Action}.
 * @throws IOException
 */
private Action getLastActionfromPreparation(String preparationId) throws IOException {
    PreparationDetails prepDet = getPreparationDetails(preparationId);
    prepDet.updateActionIds();
    return prepDet.actions.get(prepDet.actions.size() - 1);
}
Also used : PreparationDetails(org.talend.dataprep.qa.dto.PreparationDetails)

Example 2 with PreparationDetails

use of org.talend.dataprep.qa.dto.PreparationDetails in project data-prep by Talend.

the class ActionStep method getFirstActionWithName.

private Action getFirstActionWithName(String preparationId, String actionName) throws IOException {
    PreparationDetails prepDet = getPreparationDetails(preparationId);
    prepDet.updateActionIds();
    return prepDet.actions.stream().filter(// 
    action -> action.action.equals(actionName)).findFirst().get();
}
Also used : PreparationDetails(org.talend.dataprep.qa.dto.PreparationDetails)

Example 3 with PreparationDetails

use of org.talend.dataprep.qa.dto.PreparationDetails 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());
    }
}
Also used : FolderContent(org.talend.dataprep.qa.dto.FolderContent) FolderContent(org.talend.dataprep.qa.dto.FolderContent) LoggerFactory(org.slf4j.LoggerFactory) HashMap(java.util.HashMap) DatasetContent(org.talend.dataprep.qa.dto.DatasetContent) StringUtils(org.apache.commons.lang3.StringUtils) Response(com.jayway.restassured.response.Response) Action(org.talend.dataprep.helper.api.Action) DataPrepStep(org.talend.dataprep.qa.config.DataPrepStep) Map(java.util.Map) PreparationDetails(org.talend.dataprep.qa.dto.PreparationDetails) Given(cucumber.api.java.en.Given) Assert.fail(org.junit.Assert.fail) Then(cucumber.api.java.en.Then) DataTable(cucumber.api.DataTable) And(cucumber.api.java.en.And) Logger(org.slf4j.Logger) FeatureContext.suffixName(org.talend.dataprep.qa.config.FeatureContext.suffixName) IOException(java.io.IOException) NotNull(javax.validation.constraints.NotNull) Collectors(java.util.stream.Collectors) HttpStatus(org.springframework.http.HttpStatus) List(java.util.List) Assert.assertNull(org.junit.Assert.assertNull) Folder(org.talend.dataprep.qa.dto.Folder) Matchers.is(org.hamcrest.Matchers.is) OK(org.springframework.http.HttpStatus.OK) Assert(org.junit.Assert) ContentMetadataColumn(org.talend.dataprep.qa.dto.ContentMetadataColumn) Assert.assertEquals(org.junit.Assert.assertEquals) When(cucumber.api.java.en.When) InputStream(java.io.InputStream) Folder(org.talend.dataprep.qa.dto.Folder) PreparationDetails(org.talend.dataprep.qa.dto.PreparationDetails) When(cucumber.api.java.en.When)

Example 4 with PreparationDetails

use of org.talend.dataprep.qa.dto.PreparationDetails in project data-prep by Talend.

the class PreparationStep method checkPreparation.

/**
 * Check if an existing preparation contains the same actions as the one given in parameters.
 * Be careful ! If your preparation contains lookup actions, you'll need to load your dataset by restoring a Mongo
 * dump, else the lookup_ds_id won't be the same in actions' parameter value.
 *
 * @param dataTable step parameters.
 * @throws IOException in case of exception.
 */
@Given("^A preparation with the following parameters exists :$")
public void checkPreparation(DataTable dataTable) throws IOException {
    Map<String, String> params = dataTable.asMap(String.class, String.class);
    String suffixedPrepName = getSuffixedPrepName(params.get(PREPARATION_NAME));
    String prepPath = util.extractPathFromFullName(params.get(PREPARATION_NAME));
    String prepId = context.getPreparationId(suffixedPrepName, prepPath);
    PreparationDetails prepDet = getPreparationDetails(prepId);
    Assert.assertNotNull(prepDet);
    assertEquals(prepDet.dataSetId, context.getDatasetId(suffixName(params.get(DATASET_NAME))));
    assertEquals(Integer.toString(prepDet.steps.size() - 1), params.get(NB_STEPS));
    if (params.get("actionsList") != null) {
        List<Action> actionsList = prepDet.actions;
        checkActionsListOfPrepa(actionsList, params.get("actionsList").toString());
    }
}
Also used : Action(org.talend.dataprep.helper.api.Action) PreparationDetails(org.talend.dataprep.qa.dto.PreparationDetails) Given(cucumber.api.java.en.Given)

Example 5 with PreparationDetails

use of org.talend.dataprep.qa.dto.PreparationDetails in project data-prep by Talend.

the class PreparationStep method checkPreparationsSteps.

@And("^I check that the preparations \"(.*)\" and \"(.*)\" have the same steps$")
public void checkPreparationsSteps(String prep1FullName, String prep2FullName) {
    String suffixedPrep1Name = getSuffixedPrepName(prep1FullName);
    String prep1Path = util.extractPathFromFullName(prep1FullName);
    String suffixedPrep2Name = getSuffixedPrepName(prep2FullName);
    String prep2Path = util.extractPathFromFullName(prep2FullName);
    String prepId1 = context.getPreparationId(suffixedPrep1Name, prep1Path);
    String prepId2 = context.getPreparationId(suffixedPrep2Name, prep2Path);
    PreparationDetails prepDet1 = getPreparationDetails(prepId1);
    PreparationDetails prepDet2 = getPreparationDetails(prepId2);
    assertEquals(prepDet1.actions, prepDet2.actions);
    assertEquals(prepDet1.steps.size(), prepDet2.steps.size());
    context.storeObject("copiedPrep", prepDet1);
}
Also used : PreparationDetails(org.talend.dataprep.qa.dto.PreparationDetails) And(cucumber.api.java.en.And)

Aggregations

PreparationDetails (org.talend.dataprep.qa.dto.PreparationDetails)6 And (cucumber.api.java.en.And)3 Given (cucumber.api.java.en.Given)3 Action (org.talend.dataprep.helper.api.Action)3 Response (com.jayway.restassured.response.Response)2 DataTable (cucumber.api.DataTable)2 Then (cucumber.api.java.en.Then)2 When (cucumber.api.java.en.When)2 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 Collectors (java.util.stream.Collectors)2 Logger (org.slf4j.Logger)2 LoggerFactory (org.slf4j.LoggerFactory)2 OK (org.springframework.http.HttpStatus.OK)2 DataPrepStep (org.talend.dataprep.qa.config.DataPrepStep)2 FeatureContext.suffixName (org.talend.dataprep.qa.config.FeatureContext.suffixName)2 InputStream (java.io.InputStream)1 NotNull (javax.validation.constraints.NotNull)1