[
https://issues.jboss.org/browse/ARQ-1015?page=com.atlassian.jira.plugin.s...
]
Nicklas Karlsson updated ARQ-1015:
----------------------------------
Description:
It would be handy to automagically be able to test JPA queries with a method like
{code}
@Test
@UsingDataSet("all.xls")
@ShouldMatchDataSet("hits.xls")
public List<Customer> getAllowedCustomers() {
return em.createNamedQuery("customers", Customer.class).getResultList();
}
{code}
for methods with signatures returning List<?>. Currently I have functionality like
{code}
@Test
@UsingDataSet("all.xls")
public void testCustomers() throws Exception
{
IDataSet expected = new
XlsDataSet(getClass().getResourceAsStream("/hits.xls"));
ITableMetaData metadata = expected.getTableMetaData(expected.getTableNames()[0]);
IDataSet real = new PojoDataSet(em.createNamedQuery("customers",
Customer.class).getResultList(), metadata);
Assertion.assertEquals(expected, real);
}
{code}
and
{code}
public class PojoDataSet extends DefaultDataSet
{
public PojoDataSet(List<?> entities, ITableMetaData metaData)
{
try
{
DefaultTable table = new DefaultTable(metaData);
for (Object entity : entities)
{
List<Object> values = new ArrayList<Object>();
for (Column column : metaData.getColumns())
{
values.add(BeanUtils.getNestedProperty(entity, column.getColumnName()));
}
table.addRow(values.toArray());
}
addTable(table);
} catch (Exception e)
{
throw new IllegalArgumentException(e);
}
}
}
{code}
With the column names in the metadata (from the xls) mapped to Apache BeanUtils nested
properties. This approach only verifies the identities of the top-level objects (OK, it
can descend @OneToOne relations) and doesn't cover the whole POJO structure.
It would be nice if this process could somehow be automated with Arquillian-persistence.
was:
It would be handy to automagically be able to test JPA queries with a method like
@Test
@UsingDataSet("all.xls")
@ShouldMatchDataSet("hits.xls")
public List<Customer> getAllowedCustomers() {
return em.createNamedQuery("customers", Customer.class).getResultList();
}
for methods with signatures returning List<?>. Currently I have functionality like
@Test
@UsingDataSet("all.xls")
public void testCustomers() throws Exception
{
IDataSet expected = new
XlsDataSet(getClass().getResourceAsStream("/hits.xls"));
ITableMetaData metadata = expected.getTableMetaData(expected.getTableNames()[0]);
IDataSet real = new PojoDataSet(em.createNamedQuery("customers",
Customer.class).getResultList(), metadata);
Assertion.assertEquals(expected, real);
}
and
ublic class PojoDataSet extends DefaultDataSet
{
public PojoDataSet(List<?> entities, ITableMetaData metaData)
{
try
{
DefaultTable table = new DefaultTable(metaData);
for (Object entity : entities)
{
List<Object> values = new ArrayList<Object>();
for (Column column : metaData.getColumns())
{
values.add(BeanUtils.getNestedProperty(entity, column.getColumnName()));
}
table.addRow(values.toArray());
}
addTable(table);
} catch (Exception e)
{
throw new IllegalArgumentException(e);
}
}
}
With the column names in the metadata (from the xls) mapped to Apache BeanUtils nested
properties. This approach only verifies the identities of the top-level objects (OK, it
can descend @OneToOne relations) and doesn't cover the whole POJO structure.
It would be nice if this process could somehow be automated with Arquillian-persistence.
Testing of JPA queries with @UsingDataSet and @ShouldMatchDataSet
-----------------------------------------------------------------
Key: ARQ-1015
URL:
https://issues.jboss.org/browse/ARQ-1015
Project: Arquillian
Issue Type: Feature Request
Security Level: Public(Everyone can see)
Components: Extension - Persistence
Affects Versions: persistence_1.0.0.Alpha4
Reporter: Nicklas Karlsson
Assignee: Bartosz Majsak
It would be handy to automagically be able to test JPA queries with a method like
{code}
@Test
@UsingDataSet("all.xls")
@ShouldMatchDataSet("hits.xls")
public List<Customer> getAllowedCustomers() {
return em.createNamedQuery("customers", Customer.class).getResultList();
}
{code}
for methods with signatures returning List<?>. Currently I have functionality like
{code}
@Test
@UsingDataSet("all.xls")
public void testCustomers() throws Exception
{
IDataSet expected = new
XlsDataSet(getClass().getResourceAsStream("/hits.xls"));
ITableMetaData metadata = expected.getTableMetaData(expected.getTableNames()[0]);
IDataSet real = new PojoDataSet(em.createNamedQuery("customers",
Customer.class).getResultList(), metadata);
Assertion.assertEquals(expected, real);
}
{code}
and
{code}
public class PojoDataSet extends DefaultDataSet
{
public PojoDataSet(List<?> entities, ITableMetaData metaData)
{
try
{
DefaultTable table = new DefaultTable(metaData);
for (Object entity : entities)
{
List<Object> values = new ArrayList<Object>();
for (Column column : metaData.getColumns())
{
values.add(BeanUtils.getNestedProperty(entity, column.getColumnName()));
}
table.addRow(values.toArray());
}
addTable(table);
} catch (Exception e)
{
throw new IllegalArgumentException(e);
}
}
}
{code}
With the column names in the metadata (from the xls) mapped to Apache BeanUtils nested
properties. This approach only verifies the identities of the top-level objects (OK, it
can descend @OneToOne relations) and doesn't cover the whole POJO structure.
It would be nice if this process could somehow be automated with Arquillian-persistence.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see:
http://www.atlassian.com/software/jira