Siva Sai kiran
Siva Sai kiran

Reputation: 67

How to mock executeNamedQuery(query, params) for Junit Testing

@Repository public class DAOImpl extends GenericDaoImpl implements SomeDAO {

@Autowired
EntityManager em;

@Override
public List<PropertyURL> getProperties(String env) throws Exception{
    List<String> inParam = new ArrayList<>();
    inParam.add(env);
    Map<String, Object> params = new HashMap<>();
    params.put(ProEnum.ENV.getProperty(), inParam);
    List<PropertyURL> URL = null;
    String query = "PropertyURL.getProperty";
    URL = executeNamedQuery(query, params);
    return URL;
}

How can i mock executeNamedQuery(query, params) call and return some thing Ex:Mockito.when(entityManagerMock.merge(Mockito.any())).thenReturn(someObject);

Upvotes: 0

Views: 407

Answers (0)

Related Questions