@Test public void deleteAll() { // TODO review the generated test code and remove the default call to fail. List<DataSourceRow> rows = new ArrayList(); Collection<DataSourceRow> save = null; for (int i = 0; i < 10; i++) { List<DataSourceField> fields = new ArrayList(); for (int r = 0; r < 6; r++) { DataSourceField<String> F = new DataSourceField(r, r + "_value" + i, DataType.TEXT); fields.add(F); } DataSourceField<Date> F = new DataSourceField( 6, DateUtils.addDays(DateUtils.getStartDate(new Date()), i), DataType.DATE); fields.add(F); DataSourceRow row = new DataSourceRow(dataSourceId, fields); rows.add(row); } save = (Collection<DataSourceRow>) dataSourceRowRep.save(rows); assertEquals(save.size(), rows.size()); dataSourceRowRep.delete(dataSourceRowRep.findByDataSourceId(dataSourceId)); Collection<DataSourceRow> findByDataSourceId = dataSourceRowRep.findByDataSourceId(dataSourceId); assertEquals(findByDataSourceId.size(), 0); }
@Test public void insertAll() { // find datasourceby id; List<DataSourceRow> rows = new ArrayList(); Iterable<DataSourceRow> save = null; try { for (int i = 0; i < 10; i++) { List<DataSourceField> fields = new ArrayList(); for (int r = 0; r < 6; r++) { DataSourceField<String> F = new DataSourceField(r, r + "_value" + i, DataType.TEXT); fields.add(F); } DataSourceField<Date> F = new DataSourceField( 6, DateUtils.addDays(DateUtils.getStartDate(new Date()), i), DataType.DATE); fields.add(F); DataSourceRow row = new DataSourceRow(dataSourceId, fields); rows.add(row); } save = dataSourceRowRep.save(rows); assertNotNull(save); Collection<DataSourceRow> findByColumnValue = dataSourceRowRep.findByColumnValue(dataSourceId, 2, "2_value3"); assertNotNull(findByColumnValue); assertTrue("FIND ONE", findByColumnValue.size() == 1); Collection<DataSourceRow> findByColumnDateValue = dataSourceRowRep.findByColumnValue( dataSourceId, 6, DateUtils.addDays(DateUtils.getStartDate(new Date()), 0)); assertNotNull(findByColumnDateValue); assertTrue("FIND ONE", findByColumnDateValue.size() == 1); Sort sort = new Sort(Sort.Direction.ASC, "id"); Pageable pageSpecification = new PageRequest(0, 2, sort); // Iterable<DataSourceRow> findAll = // dataSourceRowRep.findByDataSourceIdPaginated("52fcd88844aef19a6f3c74db",0, // pageSpecification); // assertNotNull(findAll); } finally { if (save != null) { for (DataSourceRow d : save) { assertNotNull(d.getId()); cleanUp.add(d.getId()); } } } }