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);
}
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);
}
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);
}
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());
}
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);
}
Aggregations