Search in sources :

Example 11 with CSVFormatFamily

use of org.talend.dataprep.schema.csv.CSVFormatFamily in project data-prep by Talend.

the class DataSetServiceTest method testFavorite.

@Test
public void testFavorite() {
    // given
    final String datasetId = UUID.randomUUID().toString();
    final DataSetMetadata dataSetMetadata = metadataBuilder.metadata().id(datasetId).formatFamilyId(new CSVFormatFamily().getBeanId()).build();
    dataSetMetadata.getContent().addParameter(CSVFormatFamily.SEPARATOR_PARAMETER, ";");
    dataSetMetadataRepository.save(dataSetMetadata);
    contentStore.storeAsRaw(dataSetMetadata, new ByteArrayInputStream(new byte[0]));
    final UserData userData = new UserData(security.getUserId(), versionService.version().getVersionId());
    userDataRepository.save(userData);
    final Set<String> favorites = new HashSet<>();
    favorites.add(datasetId);
    boolean isFavorite = from(when().get("/datasets/{id}/content", datasetId).asString()).get("metadata.favorite");
    assertFalse(isFavorite);
    // when
    userData.setFavoritesDatasets(favorites);
    userDataRepository.save(userData);
    // then
    isFavorite = from(when().get("/datasets/{id}/content", datasetId).asString()).get("metadata.favorite");
    assertTrue(isFavorite);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) UserData(org.talend.dataprep.api.user.UserData) Matchers.containsString(org.hamcrest.Matchers.containsString) Matchers.isEmptyString(org.hamcrest.Matchers.isEmptyString) DataSetMetadata(org.talend.dataprep.api.dataset.DataSetMetadata) CSVFormatFamily(org.talend.dataprep.schema.csv.CSVFormatFamily) HashSet(java.util.HashSet) DataSetBaseTest(org.talend.dataprep.dataset.DataSetBaseTest) Test(org.junit.Test)

Aggregations

DataSetMetadata (org.talend.dataprep.api.dataset.DataSetMetadata)11 CSVFormatFamily (org.talend.dataprep.schema.csv.CSVFormatFamily)11 Test (org.junit.Test)10 Matchers.containsString (org.hamcrest.Matchers.containsString)9 Matchers.isEmptyString (org.hamcrest.Matchers.isEmptyString)9 DataSetBaseTest (org.talend.dataprep.dataset.DataSetBaseTest)8 JsonNode (com.fasterxml.jackson.databind.JsonNode)4 ByteArrayInputStream (java.io.ByteArrayInputStream)4 HashSet (java.util.HashSet)3 UserData (org.talend.dataprep.api.user.UserData)3 InputStream (java.io.InputStream)2 ServiceBaseTest (org.talend.ServiceBaseTest)2 DataSet (org.talend.dataprep.api.dataset.DataSet)2 ColumnMetadata (org.talend.dataprep.api.dataset.ColumnMetadata)1 DataSetContent (org.talend.dataprep.api.dataset.DataSetContent)1 LocalStoreLocation (org.talend.dataprep.api.dataset.location.LocalStoreLocation)1 DataSetMetadataBuilder (org.talend.dataprep.dataset.DataSetMetadataBuilder)1