use of io.lumeer.engine.api.data.DataDocument in project engine by Lumeer.
the class ImportFacadeIT method testImportCommaSeparatedCSV.
@Test
public void testImportCommaSeparatedCSV() {
final String commaSeparatedCsv = "h1,h2,h3\n" + "a,,c,d\n" + ",,,\n" + "a,b,c,d\n";
ImportedCollection importedCollection = createImportObject(commaSeparatedCsv);
Collection collection = importFacade.importDocuments(ImportFacade.FORMAT_CSV, importedCollection);
assertThat(collection).isNotNull();
List<DataDocument> data = dataDao.getData(collection.getId(), query());
assertThat(data).hasSize(3);
int h1Num = 0;
int h2Num = 0;
int h3Num = 0;
for (DataDocument dataDocument : data) {
String h1 = dataDocument.getString("h1");
String h2 = dataDocument.getString("h2");
String h3 = dataDocument.getString("h3");
h1Num += h1 != null && h1.equals("a") ? 1 : 0;
h2Num += h2 != null && h2.equals("b") ? 1 : 0;
h3Num += h3 != null && h3.equals("c") ? 1 : 0;
}
assertThat(h1Num).isEqualTo(2);
assertThat(h2Num).isEqualTo(1);
assertThat(h3Num).isEqualTo(2);
}
use of io.lumeer.engine.api.data.DataDocument in project engine by Lumeer.
the class ImportFacadeIT method testImportCorrectCSV.
@Test
public void testImportCorrectCSV() {
final String correctCsv = "h1;h2;h3;h4\n" + ";b;c;d\n" + ";;c;d\n" + "a;b;;d\n" + "a;b;;\n";
ImportedCollection importedCollection = createImportObject(correctCsv);
Collection collection = importFacade.importDocuments(ImportFacade.FORMAT_CSV, importedCollection);
assertThat(collection).isNotNull();
List<DataDocument> data = dataDao.getData(collection.getId(), query());
assertThat(data).hasSize(4);
int h1Num = 0;
int h2Num = 0;
int h3Num = 0;
int h4Num = 0;
for (DataDocument dataDocument : data) {
String h1 = dataDocument.getString("h1");
String h2 = dataDocument.getString("h2");
String h3 = dataDocument.getString("h3");
String h4 = dataDocument.getString("h4");
h1Num += h1 != null && h1.equals("a") ? 1 : 0;
h2Num += h2 != null && h2.equals("b") ? 1 : 0;
h3Num += h3 != null && h3.equals("c") ? 1 : 0;
h4Num += h4 != null && h4.equals("d") ? 1 : 0;
}
assertThat(h1Num).isEqualTo(2);
assertThat(h2Num).isEqualTo(3);
assertThat(h3Num).isEqualTo(2);
assertThat(h4Num).isEqualTo(3);
}
use of io.lumeer.engine.api.data.DataDocument in project engine by Lumeer.
the class ImportFacadeIT method testImportNoLinesCSV.
@Test
public void testImportNoLinesCSV() {
final String noLinesCsv = "h1;h2;h3;h4\n";
ImportedCollection importedCollection = createImportObject(noLinesCsv);
Collection collection = importFacade.importDocuments(ImportFacade.FORMAT_CSV, importedCollection);
assertThat(collection).isNotNull();
List<DataDocument> data = dataDao.getData(collection.getId(), query());
assertThat(data).isEmpty();
}
use of io.lumeer.engine.api.data.DataDocument in project engine by Lumeer.
the class ImportFacadeIT method testImportDiffRowsLengthCSV.
@Test
public void testImportDiffRowsLengthCSV() {
final String diffRowsLengthCsv = "h1;h2;h3\n" + "a;b;c;d\n" + "a;b;c;d;e;f;g;h\n" + "\n\n\n\n\n" + "a;b;c\n";
ImportedCollection importedCollection = createImportObject(diffRowsLengthCsv);
Collection collection = importFacade.importDocuments(ImportFacade.FORMAT_CSV, importedCollection);
assertThat(collection).isNotNull();
List<DataDocument> data = dataDao.getData(collection.getId(), query());
assertThat(data).hasSize(3);
int h1Num = 0;
int h2Num = 0;
int h3Num = 0;
for (DataDocument dataDocument : data) {
String h1 = dataDocument.getString("h1");
String h2 = dataDocument.getString("h2");
String h3 = dataDocument.getString("h3");
h1Num += h1 != null && h1.equals("a") ? 1 : 0;
h2Num += h2 != null && h2.equals("b") ? 1 : 0;
h3Num += h3 != null && h3.equals("c") ? 1 : 0;
}
assertThat(h1Num).isEqualTo(3);
assertThat(h2Num).isEqualTo(3);
assertThat(h3Num).isEqualTo(3);
}
use of io.lumeer.engine.api.data.DataDocument in project engine by Lumeer.
the class LinkInstanceFacadeIT method createDocument.
private Document createDocument(String collectionId) {
Document document = prepareDocument();
document.setCollectionId(collectionId);
document.setCreatedBy(USER);
document.setCreationDate(LocalDateTime.now());
document.setDataVersion(DocumentFacade.INITIAL_VERSION);
Document storedDocument = documentDao.createDocument(document);
DataDocument storedData = dataDao.createData(collectionId, storedDocument.getId(), document.getData());
storedDocument.setData(storedData);
return storedDocument;
}
Aggregations