public Organization addOrg(String orgId, String orgKeys)
here I am returning key
of type Organization
.
And in the test,
`mockJdbcTemplate.queryForObject(DAOImpl.GET__KEY_FOR_ORG_IDS, (DAORowMapper) any, expectedId, expectedKeys);`
as you can see the expectedId
and expectedKeys
, I am passing String but it's expecting Organization not the String.
The following is the modified test class that worked for me:
@Test
public void testAddOrg() {
final Organization expectedOrg = new Organization();
expectedOrgAttr.setId("7c82facc");
expectedOrgAttr.setKeys("one");
new Expectations() {{
mockJdbcTemplate.queryForObject(DAOImpl.GET_KEY_FOR_ORG_IDS, (DAORowMapper) any, expectedOrgAttr.getId(), expectedOrgAttr.getKeys());
result = expectedOrgAttr;
}};
Organization actualKey =daoImpl.addOrg(expectedOrgAttr.getId(), expectedOrgAttr.getKeys());
assertEquals(expectedOrgAttr.getId(), actualKey.getId());
}
Thank you guys for the quick responses!