java - JdbcTemplate update query giving AssertionError ? -


i writing test cases dao class , using jdbc template , power mock .in dao method calling 2 times jdbctemplate method getting error. please find below code

jdbctemplate jt = createstrictmock(jdbctemplate.class); string sql = "select sqn_alerts_cch_job_id.nextval dual"; string sqlinsert = "insert c_alerts_cch_job (msg_id, message, action, action_tm, err_desc, seq_no)"                         + " values (?,?,?,?,?,?)"; easymock.expect(jt.queryforlong(sql)).andreturn(529340l).times(1); easymock.expect(jt.update(sqlinsert, parameters)).andreturn(1).times(1); powermock.replay(jt); powermock.replayall(); object[] parameters = new object[6]; parameters[0] = jt.queryforlong(sql); jt.update(sql, parameters); 

then getting below error

    java.lang.assertionerror:  unexpected method call jdbctemplate.update("insert c_alerts_cch_job (msg_id, message, action, action_tm, err_desc, seq_no) values (?,?,?,?,?,?)", [null, null, null, 2015-05-11 19:49:29.585, null, 529340]): jdbctemplate.queryforlong("select sqn_alerts_cch_job_id.nextval dual"): expected: 1, actual: 1 jdbctemplate.update("insert c_alerts_cch_job (msg_id, message, action, action_tm, err_desc, seq_no) values (?,?,?,?,?,?)", [null, null, null, 2015-05-11 19:49:29.585, null, 529340]): expected: 1, actual: 0 @ org.easymock.internal.mockinvocationhandler.invoke(mockinvocationhandler.java:44) @ org.easymock.internal.objectmethodsfilter.invoke(objectmethodsfilter.java:94) @ org.easymock.internal.classproxyfactory$mockmethodinterceptor.intercept(classproxyfactory.java:97) @ org.springframework.jdbc.core.jdbctemplate$$enhancerbycglib$$6e3c18ec.update(<generated>) 

why ?

your second mock returning 0 when expecting 1... hence assertion error


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -