Search in sources :

Example 81 with DataSetMetadata

use of org.talend.dataprep.api.dataset.DataSetMetadata in project data-prep by Talend.

the class FileSystemDataSetMetadataRepositoryTest method shouldIgnoreHiddenFiles.

@Test
public void shouldIgnoreHiddenFiles() throws Exception {
    // given
    assertFalse(repository.list().findFirst().isPresent());
    // when
    File hidden = new File("target/test/store/metadata/.hidden_file");
    FileOutputStream fos = new FileOutputStream(hidden);
    fos.write("hello".getBytes());
    fos.close();
    // then
    final DataSetMetadata dataSetMetadata = repository.get(".hidden");
    hidden.delete();
    assertNull(dataSetMetadata);
}
Also used : FileOutputStream(java.io.FileOutputStream) File(java.io.File) DataSetMetadata(org.talend.dataprep.api.dataset.DataSetMetadata) Test(org.junit.Test) DataSetBaseTest(org.talend.dataprep.dataset.DataSetBaseTest)

Example 82 with DataSetMetadata

use of org.talend.dataprep.api.dataset.DataSetMetadata in project data-prep by Talend.

the class FileSystemDataSetMetadataRepositoryTest method getShouldReturnSameMetadataThatWasAdded.

@Test
public void getShouldReturnSameMetadataThatWasAdded() throws IOException {
    // given
    final DataSetMetadata expected = getMetadata("456789");
    // when
    repository.save(expected);
    final DataSetMetadata actual = repository.get(expected.getId());
    // then
    assertEquals(expected, actual);
}
Also used : DataSetMetadata(org.talend.dataprep.api.dataset.DataSetMetadata) Test(org.junit.Test) DataSetBaseTest(org.talend.dataprep.dataset.DataSetBaseTest)

Example 83 with DataSetMetadata

use of org.talend.dataprep.api.dataset.DataSetMetadata in project data-prep by Talend.

the class FileSystemDataSetMetadataRepositoryTest method shouldUpdateExistingEntry.

@Test
public void shouldUpdateExistingEntry() throws IOException {
    String id = "75396";
    // given
    final DataSetMetadata metadata = getMetadata(id);
    repository.save(metadata);
    // when
    DataSetMetadata update = mapper.readerFor(DataSetMetadata.class).readValue(this.getClass().getResourceAsStream("dataset_2.json"));
    update = metadataBuilder.metadata().copy(update).id(id).build();
    repository.save(update);
    // then
    final DataSetMetadata actual = repository.get(id);
    assertEquals(update, actual);
}
Also used : DataSetMetadata(org.talend.dataprep.api.dataset.DataSetMetadata) Test(org.junit.Test) DataSetBaseTest(org.talend.dataprep.dataset.DataSetBaseTest)

Example 84 with DataSetMetadata

use of org.talend.dataprep.api.dataset.DataSetMetadata in project data-prep by Talend.

the class FileSystemDataSetMetadataRepositoryTest method shouldList.

@Test
public void shouldList() throws IOException {
    // list nothing
    final Iterator<DataSetMetadata> emptyList = repository.list().iterator();
    assertFalse(emptyList.hasNext());
    // given
    int expected = 26;
    for (int i = 1; i <= expected; i++) {
        repository.save(getMetadata(String.valueOf(i)));
    }
    // when
    final Iterator<DataSetMetadata> actual = repository.list().iterator();
    // then
    // need of a final object that can be incremented in the
    final AtomicInteger count = new AtomicInteger(0);
    // following lambda expression
    actual.forEachRemaining(dataSetMetadata -> {
        assertTrue(Integer.valueOf(dataSetMetadata.getId()) <= expected);
        count.addAndGet(1);
    /*assertFalse(dataSetMetadata.isSharedDataSet());
            assertNotNull(dataSetMetadata.getOwner());
            assertEquals(dataSetMetadata.getAuthor(), dataSetMetadata.getOwner().getFirstName());*/
    });
    assertEquals(expected, count.intValue());
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) DataSetMetadata(org.talend.dataprep.api.dataset.DataSetMetadata) Test(org.junit.Test) DataSetBaseTest(org.talend.dataprep.dataset.DataSetBaseTest)

Example 85 with DataSetMetadata

use of org.talend.dataprep.api.dataset.DataSetMetadata in project data-prep by Talend.

the class InMemoryDataSetMetadataRepositoryTest method addMetadataToRepository.

private void addMetadataToRepository(String id, long dataSetSize) {
    DataSetMetadata metadata = new DataSetMetadata();
    metadata.setId(id);
    metadata.setDataSetSize(dataSetSize);
    inMemoryDataSetMetadataRepository.save(metadata);
}
Also used : DataSetMetadata(org.talend.dataprep.api.dataset.DataSetMetadata)

Aggregations

DataSetMetadata (org.talend.dataprep.api.dataset.DataSetMetadata)192 Test (org.junit.Test)126 DataSetBaseTest (org.talend.dataprep.dataset.DataSetBaseTest)63 ColumnMetadata (org.talend.dataprep.api.dataset.ColumnMetadata)48 InputStream (java.io.InputStream)45 Matchers.containsString (org.hamcrest.Matchers.containsString)28 Matchers.isEmptyString (org.hamcrest.Matchers.isEmptyString)28 TDPException (org.talend.dataprep.exception.TDPException)26 RowMetadata (org.talend.dataprep.api.dataset.RowMetadata)20 DataSetServiceTest (org.talend.dataprep.dataset.service.DataSetServiceTest)20 ApiOperation (io.swagger.annotations.ApiOperation)18 DataSet (org.talend.dataprep.api.dataset.DataSet)18 Type (org.talend.dataprep.api.type.Type)17 Timed (org.talend.dataprep.metrics.Timed)17 DistributedLock (org.talend.dataprep.lock.DistributedLock)16 Autowired (org.springframework.beans.factory.annotation.Autowired)14 DataSetRow (org.talend.dataprep.api.dataset.row.DataSetRow)14 IOException (java.io.IOException)13 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)13 ArrayList (java.util.ArrayList)12