use of org.simpleflatmapper.test.beans.DbObject in project SimpleFlatMapper by arnaudroger.
the class SfmBindTest method checkObjectInserted.
public void checkObjectInserted(SfmBindExample attach, Handle handle, DbObject dbObject) {
DbObject o = attach.selectOne(dbObject.getId());
assertEquals(dbObject, o);
}
use of org.simpleflatmapper.test.beans.DbObject in project SimpleFlatMapper by arnaudroger.
the class SettableDataMapperTest method checkObjectInserted.
protected void checkObjectInserted(Session session, int i) {
if (session == null)
throw new NullPointerException();
DbObject object = dbObjects.get(i);
if (object == null)
throw new NullPointerException();
DatastaxMapper<DbObject> dbObjectDatastaxMapper = DatastaxMapperFactory.newInstance().mapTo(DbObject.class);
PreparedStatement preparedStatement = session.prepare("select * from dbobjects where id = ?");
if (preparedStatement == null)
throw new NullPointerException();
System.out.println("preparedStatement = " + preparedStatement);
System.out.println("object = " + object);
System.out.println("object.getId() = " + object.getId());
try {
BoundStatement boundStatement = preparedStatement.bind(object.getId());
ResultSet execute = session.execute(boundStatement);
DbObject actual = dbObjectDatastaxMapper.iterator(execute).next();
assertEquals(object, actual);
} catch (NullPointerException e) {
e.printStackTrace(System.out);
throw e;
}
}
use of org.simpleflatmapper.test.beans.DbObject in project SimpleFlatMapper by arnaudroger.
the class CsvWriterBuilderTest method testWriteCsvOnDbObject.
@Test
public void testWriteCsvOnDbObject() throws Exception {
MapperConfig<CsvColumnKey, FieldMapperColumnDefinition<CsvColumnKey>> config = MapperConfig.<CsvColumnKey>fieldMapperConfig();
CsvWriterBuilder<DbObject> builder = CsvWriterBuilder.newBuilder(DbObject.class);
Mapper<DbObject, Appendable> mapper = builder.addColumn("id").addColumn("name").addColumn("email").addColumn("creation_time", new DateFormatProperty("dd/MM/yyyy HH:mm:ss")).addColumn("type_ordinal", new EnumOrdinalFormatProperty()).addColumn("type_name").mapper();
DbObject dbObject = CsvWriterTest.newDbObject();
assertEquals("13,name,email,06/06/2015 17:46:23,1,type3\r\n", mapper.map(dbObject).toString());
dbObject.setEmail("email,e\" ");
assertEquals("13,name,\"email,e\"\" \",06/06/2015 17:46:23,1,type3\r\n", mapper.map(dbObject).toString());
}
use of org.simpleflatmapper.test.beans.DbObject in project SimpleFlatMapper by arnaudroger.
the class CsvWriterTest method newDbObject.
public static DbObject newDbObject() throws ParseException {
DbObject dbObject = new DbObject();
dbObject.setId(13);
dbObject.setEmail("email");
dbObject.setName("name");
dbObject.setCreationTime(new SimpleDateFormat("dd/MM/yyyy HH:mm:ss").parse("06/06/2015 17:46:23"));
dbObject.setTypeOrdinal(DbObject.Type.type2);
dbObject.setTypeName(DbObject.Type.type3);
return dbObject;
}
use of org.simpleflatmapper.test.beans.DbObject in project SimpleFlatMapper by arnaudroger.
the class CsvWriterTest method testWriterWithOneManualColumnWithFormat.
@Test
public void testWriterWithOneManualColumnWithFormat() throws Exception {
StringWriter sw = new StringWriter();
final CsvWriter.CsvWriterDSL<DbObject> dbObjectCsvWriterDSL = CsvWriter.from(DbObject.class).skipHeaders();
final CsvWriter<DbObject> to = dbObjectCsvWriterDSL.column("creation_time", new SimpleDateFormat("yyyyMMdd")).to(sw);
to.append(newDbObject());
assertEquals("20150606\r\n", sw.toString());
}
Aggregations