How to write code coverage for lambda preparestatement

How to right code coverage for preparedStatment lambda action

this.jdbcTemplate.query(sqlQuery, (PreparedStatementSetter) ps -> {
            ps.setTimestamp(1, startTime);
            ps.setTimestamp(2, endTime);
            ps.setString(3, status);
            ps.setString(4, Constants.SUCCESS);
            }, new CountResultSet()).intValue();
LVL 20
Sathish David  Kumar NArchitectAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mccarlIT Business Systems Analyst / Software DeveloperCommented:
How to right code coverage

What do you mean by this? It doesn't really make much sense to me.
0
Sathish David Kumar NArchitectAuthor Commented:
sorry How to write code coverage for Lambda expression
0
mccarlIT Business Systems Analyst / Software DeveloperCommented:
Ok, I thought that you may have meant "write" too, but still it doesn't make any sense. You don't "write" code coverage. Your code is either covered by test case(s) or not. Since I am guessing it may just be a language issue, can you try asking for what you want in another way?
0
Become a CompTIA Certified Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

Sathish David Kumar NArchitectAuthor Commented:
yes your correct .

example

return this.jdbcTemplate.query(sqlQuery, (PreparedStatementSetter) ps -> {
            ps.setTimestamp(1, startTime);
            ps.setTimestamp(2, endTime);
 // still 5 more line
              }, new CountResultSet()).intValue();

My test case does not cover
       ps.setTimestamp(1, startTime);
            ps.setTimestamp(2, endTime);
 // still 5 more line

I need to cover this 7 line how to do that
0
mccarlIT Business Systems Analyst / Software DeveloperCommented:
As long as your test case is calling the actual query() method call, then PreparedStatementSetter lines will get called to.

Perhaps your code coverage tool is just not indicating what lines have been called properly, and maybe this is because it can't handle the lambda syntax properly. Just as a verification of the above, if you change your code from a lambda to the "old" way using an anonymous inner class, do the lines show up as being covered? If so, you may need to see if your code coverage tool has an update that might be able to handle lambda's properly.
0
Sathish David Kumar NArchitectAuthor Commented:
I found myself
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JUnit

From novice to tech pro — start learning today.