Search in sources :

Example 6 with Preparation

use of org.talend.dataprep.api.preparation.Preparation in project data-prep by Talend.

the class SearchAPITest method shouldReturnMatchingPreparationsWithSpaceWhenPerformingInventory.

@Test
public void shouldReturnMatchingPreparationsWithSpaceWhenPerformingInventory() throws IOException {
    // given
    final String preparationId = testClient.createPreparationFromFile("t-shirt_100.csv", "testInventory OfPreparations", folderRepository.getHome().getId());
    // when
    final Response response = // 
    given().queryParam("name", // 
    "Inventory ").expect().statusCode(200).log().ifError().get("/api/search");
    // then
    assertEquals(200, response.getStatusCode());
    JsonNode rootNode = mapper.readTree(response.asInputStream());
    JsonNode preparations = rootNode.get("preparations");
    List<Preparation> preparationList = mapper.readValue(preparations.toString(), new TypeReference<List<Preparation>>() {
    });
    assertThat(preparationList.size(), is(1));
    assertEquals("testInventory OfPreparations", preparationList.get(0).getName());
    assertEquals(preparationId, preparationList.get(0).id());
}
Also used : Response(com.jayway.restassured.response.Response) Preparation(org.talend.dataprep.api.preparation.Preparation) JsonNode(com.fasterxml.jackson.databind.JsonNode) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test)

Example 7 with Preparation

use of org.talend.dataprep.api.preparation.Preparation in project data-prep by Talend.

the class SearchAPITest method shouldReturnMatchingPreparationsWhenPerformingInventory.

@Test
public void shouldReturnMatchingPreparationsWhenPerformingInventory() throws IOException {
    // given
    final String preparationId = testClient.createPreparationFromFile("t-shirt_100.csv", "testInventoryOfPreparations", folderRepository.getHome().getId());
    // when
    final Response response = // 
    given().queryParam("name", // 
    "Inventory").expect().statusCode(200).log().ifError().get("/api/search");
    // then
    assertEquals(200, response.getStatusCode());
    JsonNode rootNode = mapper.readTree(response.asInputStream());
    JsonNode preparations = rootNode.get("preparations");
    List<Preparation> preparationList = mapper.readValue(preparations.toString(), new TypeReference<List<Preparation>>() {
    });
    assertThat(preparationList.size(), is(1));
    assertEquals("testInventoryOfPreparations", preparationList.get(0).getName());
    assertEquals(preparationId, preparationList.get(0).id());
}
Also used : Response(com.jayway.restassured.response.Response) Preparation(org.talend.dataprep.api.preparation.Preparation) JsonNode(com.fasterxml.jackson.databind.JsonNode) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test)

Example 8 with Preparation

use of org.talend.dataprep.api.preparation.Preparation in project data-prep by Talend.

the class TransformAPITest method testShouldEvictPreparationCacheOnDataSetUpdate.

@Test
public void testShouldEvictPreparationCacheOnDataSetUpdate() throws Exception {
    // given
    final String preparationId = testClient.createPreparationFromFile("dataset/dataset_TDP-2165.csv", "testDataset", home.getId());
    testClient.applyAction(preparationId, IOUtils.toString(this.getClass().getResourceAsStream("transformation/TDP-2165.json"), UTF_8));
    testClient.getPreparation(preparationId);
    final Preparation preparation = preparationRepository.get(preparationId, Preparation.class);
    final TransformationCacheKey transformationCacheKey = // 
    cacheKeyGenerator.generateContentKey(// 
    preparation.getDataSetId(), // 
    preparationId, // 
    preparation.getHeadId(), // 
    "JSON", // 
    HEAD, // no filter
    "");
    assertTrue(contentCache.has(transformationCacheKey));
    // when
    context.publishEvent(new DatasetUpdatedEvent(dataSetMetadataRepository.get(preparation.getDataSetId())));
    // then
    assertFalse(contentCache.has(transformationCacheKey));
}
Also used : TransformationCacheKey(org.talend.dataprep.cache.TransformationCacheKey) DatasetUpdatedEvent(org.talend.dataprep.dataset.event.DatasetUpdatedEvent) Preparation(org.talend.dataprep.api.preparation.Preparation) Test(org.junit.Test)

Example 9 with Preparation

use of org.talend.dataprep.api.preparation.Preparation in project data-prep by Talend.

the class PreparationRepositoryTest method findOneByDataset_should_return_null_when_no_preparation_use_dataset.

@Test
public void findOneByDataset_should_return_null_when_no_preparation_use_dataset() {
    // given
    final String dataSetId = "789b61f3128a9bc24a684";
    final Preparation prep1 = new Preparation();
    prep1.setDataSetId("other_dataset");
    final Preparation prep2 = new Preparation();
    prep2.setDataSetId("other_dataset");
    getRepository().add(prep1);
    getRepository().add(prep2);
    // when
    final boolean result = getRepository().exist(Preparation.class, eq("dataSetId", dataSetId));
    // then
    assertThat(result, is(false));
}
Also used : Preparation(org.talend.dataprep.api.preparation.Preparation) ServiceBaseTest(org.talend.ServiceBaseTest) Test(org.junit.Test)

Example 10 with Preparation

use of org.talend.dataprep.api.preparation.Preparation in project data-prep by Talend.

the class FileSystemPreparationRepositoryTest method shouldGetPreparationThatWasAdded.

@Test
public void shouldGetPreparationThatWasAdded() throws JsonProcessingException {
    // given
    Preparation expected = getPreparation("7561486");
    repository.add(expected);
    // when
    final Preparation actual = repository.get(expected.id(), Preparation.class);
    // then
    assertEquals(expected, actual);
}
Also used : Preparation(org.talend.dataprep.api.preparation.Preparation) PreparationTest(org.talend.dataprep.preparation.PreparationTest) PreparationRepositoryTest(org.talend.dataprep.preparation.store.PreparationRepositoryTest) Test(org.junit.Test)

Aggregations

Preparation (org.talend.dataprep.api.preparation.Preparation)65 Test (org.junit.Test)44 Step (org.talend.dataprep.api.preparation.Step)18 List (java.util.List)14 ServiceBaseTest (org.talend.ServiceBaseTest)11 ArrayList (java.util.ArrayList)10 Action (org.talend.dataprep.api.preparation.Action)10 PreparationActions (org.talend.dataprep.api.preparation.PreparationActions)10 Response (com.jayway.restassured.response.Response)9 Arrays (java.util.Arrays)8 DataSetMetadata (org.talend.dataprep.api.dataset.DataSetMetadata)8 ExportParameters (org.talend.dataprep.api.export.ExportParameters)8 UserPreparation (org.talend.dataprep.preparation.service.UserPreparation)8 TransformationCacheKey (org.talend.dataprep.cache.TransformationCacheKey)7 PreparationRepository (org.talend.dataprep.preparation.store.PreparationRepository)7 RowMetadata (org.talend.dataprep.api.dataset.RowMetadata)6 Folder (org.talend.dataprep.api.folder.Folder)6 TDPException (org.talend.dataprep.exception.TDPException)6 PersistentStep (org.talend.dataprep.preparation.store.PersistentStep)6 PreparationRepositoryTest (org.talend.dataprep.preparation.store.PreparationRepositoryTest)6