method2testcases
stringlengths
118
3.08k
### Question: AbstractQueryInputHandler extends AbstractInputHandler<T> { public abstract QueryParameters update(Object[] outParamValues); protected AbstractQueryInputHandler(QueryInputProcessor processor); abstract QueryParameters update(Object[] outParamValues); abstract String getQueryString(); abstract QueryParameters getQueryParameters(); }### Answer: @Test public void testUpdate() throws Exception { String favouritePast = "superman"; String favouritePresent = "hulk"; invokeQueries(); verify(inputHandler, never()).update(any(Object[].class)); QueryInputHandler queryInputHandler = new QueryInputHandler("SELECT strength from HEROES WHEN name = :favourite", new QueryParameters().set("favourite", favouritePast, QueryParameters.Direction.INOUT)); Assert.assertEquals(favouritePast, queryInputHandler.getQueryParameters().getValue("favourite")); QueryParameters updateParams = queryInputHandler.update(new Object[]{favouritePresent}); Assert.assertEquals(favouritePresent, updateParams.getValue("favourite")); }
### Question: QueryInputHandler extends AbstractQueryInputHandler<QueryParameters> { @Override public QueryParameters getQueryParameters() { return this.queryParameters; } QueryInputHandler(String encodedQuery, QueryParameters inputParameter); QueryInputHandler(String encodedQuery, QueryParameters inputParameter, String parameterName); protected QueryInputHandler(QueryInputProcessor processor, String encodedQuery, QueryParameters inputParameter, String parameterName); @Override String getQueryString(); @Override QueryParameters getQueryParameters(); @Override QueryParameters update(Object[] outParamValues); }### Answer: @Test public void testGeneral() { QueryParameters params = new QueryParameters(); params.set("boss", "artie"); params.set("agent", "myka"); QueryInputHandler input = new QueryInputHandler("SELECT * FROM AGENTS WHERE name = :boss OR name = :agent", params); Assert.assertEquals(false, params == input.getQueryParameters()); Assert.assertEquals(params.getValue("boss"), input.getQueryParameters().getValue("boss")); Assert.assertEquals(params.getValue("agent"), input.getQueryParameters().getValue("agent")); }
### Question: AbstractInputHandler implements InputHandler<T> { protected void validateSqlString(String originalSql) { if (originalSql == null) { throw new IllegalArgumentException(ERROR_SQL_QUERY_NULL); } if (processor.hasUnnamedParameters(originalSql) == true) { throw new IllegalArgumentException(ERROR_FOUND_UNNAMED_PARAMETER); } } protected AbstractInputHandler(QueryInputProcessor processor); }### Answer: @Test public void testValidateSqlString() throws Exception { TestAbstractInputHandler testInputHandler = new TestAbstractInputHandler(); try { testInputHandler.validateSqlString(null); fail(); } catch (IllegalArgumentException ex) { } try { testInputHandler.validateSqlString("some acceptable string"); } catch (IllegalArgumentException ex) { fail(); } try { testInputHandler.validateSqlString("SELECT GOLD from BANK where AMOUNT > :expectedGoldAmount AND ADDRESS = ?"); fail(); } catch (IllegalArgumentException ex) { } try { testInputHandler.validateSqlString("SELECT GOLD from BANK where AMOUNT > :expectedGoldAmount AND ADDRESS = :someAddress"); } catch (IllegalArgumentException ex) { fail(); } }
### Question: AbstractNamedInputHandler extends AbstractInputHandler<T> { protected Map<String, Object> updateMap(Map<String, Object> target, Map<String, Object> source) { Map<String, Object> resultMap = new HashMap<String, Object>(target); String keyWOClassName = null; for (String sourceKey : source.keySet()) { keyWOClassName = InputUtils.removeClassName(sourceKey); if (target.containsKey(sourceKey) == true) { resultMap.put(sourceKey, source.get(sourceKey)); } else if (target.containsKey(keyWOClassName) == true) { resultMap.put(keyWOClassName, source.get(keyWOClassName)); } } return resultMap; } protected AbstractNamedInputHandler(QueryInputProcessor processor); abstract T updateInput(QueryParameters updatedInput); abstract String getEncodedQueryString(); abstract String getQueryString(); abstract QueryParameters getQueryParameters(); }### Answer: @Test public void testUpdateMap() throws Exception { Map<String, Object> washMap = new HashMap<String, Object>(); washMap.put("name", "Wash"); washMap.put("skill", "Pilot"); washMap.put("number", 7); Map<String, Object> jayneMap = new HashMap<String, Object>(); jayneMap.put("name", "Jayne"); jayneMap.put("skill", "Hired gun"); jayneMap.put("number", 5); Map<String, Object> jayneMapClone = new TestNamedInputHandler<Character>().updateMap(washMap, jayneMap); Assert.assertEquals("Jayne", jayneMapClone.get("name")); Assert.assertEquals("Hired gun", jayneMapClone.get("skill")); Assert.assertEquals(5, ((Integer) jayneMapClone.get("number")).intValue()); }
### Question: AbstractNamedInputHandler extends AbstractInputHandler<T> { protected T updateBean(T object, Map<String, Object> source) { T clone = copyProperties(object); updateProperties(clone, source); return clone; } protected AbstractNamedInputHandler(QueryInputProcessor processor); abstract T updateInput(QueryParameters updatedInput); abstract String getEncodedQueryString(); abstract String getQueryString(); abstract QueryParameters getQueryParameters(); }### Answer: @Test public void testUpdateBean() throws Exception { Character mal = new Character(); mal.setName("Mal"); mal.setSkill("Sergeant/Smuggler"); mal.setNumber(57); Map<String, Object> zoeMap = new HashMap<String, Object>(); zoeMap.put("name", "Zoe"); zoeMap.put("skill", "Corporal/Warrior woman"); zoeMap.put("number", 57); Character zoe = new TestNamedInputHandler<Character>().updateBean(mal, zoeMap); Assert.assertEquals("Zoe", zoe.getName()); Assert.assertEquals("Corporal/Warrior woman", zoe.getSkill()); Assert.assertEquals(57, zoe.getNumber().intValue()); }
### Question: BeanListOutputHandler extends AbstractOutputListHandler<T> { public List<T> handle(List<QueryParameters> outputList) throws MjdbcException { return this.outputProcessor.toBeanList(outputList, this.type); } BeanListOutputHandler(Class<T> type); BeanListOutputHandler(Class<T> type, QueryOutputProcessor processor); List<T> handle(List<QueryParameters> outputList); }### Answer: @Test public void testHandle() throws MjdbcException { List<Character> result = new BeanListOutputHandler<Character>(Character.class).handle(paramsList); Assert.assertArrayEquals(new Object[]{"jack", "sheriff", 36}, new Object[]{result.get(0).getName(), result.get(0).getOccupation(), result.get(0).getAge()}); Assert.assertArrayEquals(new Object[]{"henry", "mechanic", 36}, new Object[]{result.get(1).getName(), result.get(1).getOccupation(), result.get(1).getAge()}); Assert.assertArrayEquals(new Object[]{"alison", "agent", 30}, new Object[]{result.get(2).getName(), result.get(2).getOccupation(), result.get(2).getAge()}); } @Test public void testEmpty() throws MjdbcException { List<Character> result = new BeanListOutputHandler<Character>(Character.class).handle(emptyList); Assert.assertEquals(0, result.size()); }
### Question: Overrider { public void override(String operation, Object value) { this.override.put(operation, value); } Overrider(); Overrider(Overrider overrider); void overrideOnce(String operation, Object value); void override(String operation, Object value); void removeOverride(String operation); boolean hasOverride(String operation); Object getOverride(String operation); }### Answer: @Test public void testOverride() throws Exception { String name = "value"; String value = "many"; overrider.override(name, value); Assert.assertEquals(overrider.hasOverride(name), true); Assert.assertEquals(overrider.getOverride(name), value); Assert.assertEquals(overrider.getOverride(name), value); Assert.assertEquals(overrider.hasOverride(name), true); }
### Question: BeanOutputHandler extends AbstractOutputHandler<T> { public T handle(List<QueryParameters> outputList) throws MjdbcException { return (T) this.outputProcessor.toBean(outputList, this.type); } BeanOutputHandler(Class<T> type); BeanOutputHandler(Class<T> type, QueryOutputProcessor outputProcessor); T handle(List<QueryParameters> outputList); }### Answer: @Test public void testHandle() throws Exception { BeanOutputHandler<Character> handler = new BeanOutputHandler<Character>(Character.class); Character result = handler.handle(paramsList); org.junit.Assert.assertArrayEquals(new Object[]{"jack", "sheriff", 36}, new Object[]{result.getName(), result.getOccupation(), result.getAge()}); } @Test public void testEmpty() throws MjdbcException { BeanOutputHandler<Character> handler = new BeanOutputHandler<Character>(Character.class); Character result = handler.handle(emptyList); Assert.assertEquals(null, result); }
### Question: ArrayOutputHandler extends AbstractOutputHandler<Object[]> { public Object[] handle(List<QueryParameters> outputList) { return this.outputProcessor.toArray(outputList); } ArrayOutputHandler(); ArrayOutputHandler(QueryOutputProcessor outputProcessor); Object[] handle(List<QueryParameters> outputList); }### Answer: @Test public void testHandle() { Object[] result = new ArrayOutputHandler().handle(paramsList); Assert.assertArrayEquals(new Object[]{"jack", "sheriff", 36}, result); } @Test public void testEmpty() { Object[] result = new ArrayOutputHandler().handle(emptyList); Assert.assertEquals(0, result.length); }
### Question: ArrayListOutputHandler extends AbstractOutputListHandler<Object[]> { public List<Object[]> handle(List<QueryParameters> outputList) { return this.outputProcessor.toArrayList(outputList); } ArrayListOutputHandler(); ArrayListOutputHandler(QueryOutputProcessor processor); List<Object[]> handle(List<QueryParameters> outputList); }### Answer: @Test public void testHandle() { List<Object[]> result = new ArrayListOutputHandler().handle(paramsList); Assert.assertArrayEquals(new Object[]{"jack", "sheriff", 36}, result.get(0)); Assert.assertArrayEquals(new Object[]{"henry", "mechanic", 36}, result.get(1)); Assert.assertArrayEquals(new Object[]{"alison", "agent", 30}, result.get(2)); } @Test public void testEmpty() { List<Object[]> result = new ArrayListOutputHandler().handle(emptyList); Assert.assertEquals(0, result.size()); }
### Question: RowCountOutputHandler extends AbstractOutputHandler<T> { public T handle(List<QueryParameters> outputList) { Number result = 0; if (outputList == null || outputList.isEmpty() == true) { throw new IllegalArgumentException("Error! Output should always contain at least one element"); } QueryParameters stmtParams = outputList.get(0); if (stmtParams.containsKey(HandlersConstants.STMT_UPDATE_COUNT) == false) { throw new IllegalArgumentException("Error! Expected to get update count, but key wasn't found!"); } result = (Integer) stmtParams.getValue(HandlersConstants.STMT_UPDATE_COUNT); return (T) result; } RowCountOutputHandler(); T handle(List<QueryParameters> outputList); }### Answer: @Test public void testHandle() throws Exception { RowCountOutputHandler<Integer> handler = new RowCountOutputHandler<Integer>(); paramsList.get(0).set(HandlersConstants.STMT_UPDATE_COUNT, 3); Integer result = handler.handle(paramsList); Assert.assertEquals(3, result.intValue()); } @Test public void testIncorrect() { RowCountOutputHandler<Integer> handler = new RowCountOutputHandler<Integer>(); try { Integer result = handler.handle(paramsList); fail(); } catch (IllegalArgumentException ex) { } } @Test public void testEmpty() { RowCountOutputHandler<Integer> handler = new RowCountOutputHandler<Integer>(); try { Integer result = handler.handle(emptyList); fail(); } catch (IllegalArgumentException ex) { } }
### Question: Overrider { public void removeOverride(String operation) { if (this.overrideOnce.containsKey(operation) == true) { this.overrideOnce.remove(operation); } if (this.override.containsKey(operation) == true) { this.override.remove(operation); } } Overrider(); Overrider(Overrider overrider); void overrideOnce(String operation, Object value); void override(String operation, Object value); void removeOverride(String operation); boolean hasOverride(String operation); Object getOverride(String operation); }### Answer: @Test public void testRemoveOverride() throws Exception { String name = "value"; String value = "many"; overrider.override(name, value); Assert.assertEquals(overrider.hasOverride(name), true); Assert.assertEquals(overrider.getOverride(name), value); overrider.removeOverride(name); Assert.assertEquals(overrider.getOverride(name), null); Assert.assertEquals(overrider.hasOverride(name), false); }
### Question: KeyedOutputHandler extends AbstractKeyedOutputHandler<K, Map<String, Object>> { @Override protected Map<String, Object> createRow(QueryParameters params) throws MjdbcException { return this.outputProcessor.toMap(params); } KeyedOutputHandler(); KeyedOutputHandler(QueryOutputProcessor processor); KeyedOutputHandler(int columnIndex); KeyedOutputHandler(String columnName); private KeyedOutputHandler(QueryOutputProcessor processor, int columnIndex, String columnName); }### Answer: @Test public void testCreateRow() throws Exception { KeyedOutputHandler<String> handler = new KeyedOutputHandler<String>(); Map<String, Object> result = handler.createRow(params); Assert.assertEquals(params.getValue("name"), result.get("name")); Assert.assertEquals(params.getValue("occupation"), result.get("occupation")); Assert.assertEquals(params.getValue("age"), result.get("age")); }
### Question: BeanLazyScrollUpdateOutputHandler extends AbstractScrollUpdateLazyOutputHandler implements LazyScrollUpdateOutputHandler<BeanLazyScrollUpdateOutputHandler, S> { public boolean hasNext() { return super.innerHasNext(); } BeanLazyScrollUpdateOutputHandler(Class<S> type); BeanLazyScrollUpdateOutputHandler(Class<S> type, QueryOutputProcessor processor); private BeanLazyScrollUpdateOutputHandler(Class<S> type, QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); S getNext(); S getCurrent(); void close(); BeanLazyScrollUpdateOutputHandler handle(List<QueryParameters> outputList); boolean hasPrev(); S getPrev(); boolean moveTo(int row); boolean moveRelative(int rows); int position(); void updateRow(S row); void insertRow(S row); }### Answer: @Test public void testHasNext() throws Exception { innerTestHasPrepare(); innerTestHasNext(new BeanLazyScrollUpdateOutputHandler<Character>(Character.class).handle(new QueryParametersLazyList(stmt, typeHandler, false))); }
### Question: BeanLazyScrollUpdateOutputHandler extends AbstractScrollUpdateLazyOutputHandler implements LazyScrollUpdateOutputHandler<BeanLazyScrollUpdateOutputHandler, S> { public S getNext() { S result = null; QueryParameters params = innerGetNext(); try { result = processor.toBean(params, this.type); } catch (MjdbcException ex) { throw new MjdbcRuntimeException(ex); } return result; } BeanLazyScrollUpdateOutputHandler(Class<S> type); BeanLazyScrollUpdateOutputHandler(Class<S> type, QueryOutputProcessor processor); private BeanLazyScrollUpdateOutputHandler(Class<S> type, QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); S getNext(); S getCurrent(); void close(); BeanLazyScrollUpdateOutputHandler handle(List<QueryParameters> outputList); boolean hasPrev(); S getPrev(); boolean moveTo(int row); boolean moveRelative(int rows); int position(); void updateRow(S row); void insertRow(S row); }### Answer: @Test public void testGetNext() throws Exception { innerTestGetPrepare(); innerTestGetNext(new BeanLazyScrollUpdateOutputHandler<Character>(Character.class).handle(new QueryParametersLazyList(stmt, typeHandler, false))); }
### Question: BeanLazyScrollUpdateOutputHandler extends AbstractScrollUpdateLazyOutputHandler implements LazyScrollUpdateOutputHandler<BeanLazyScrollUpdateOutputHandler, S> { public S getCurrent() { S result = null; QueryParameters params = innerGetCurrent(); try { result = processor.toBean(params, this.type); } catch (MjdbcException ex) { throw new MjdbcRuntimeException(ex); } return result; } BeanLazyScrollUpdateOutputHandler(Class<S> type); BeanLazyScrollUpdateOutputHandler(Class<S> type, QueryOutputProcessor processor); private BeanLazyScrollUpdateOutputHandler(Class<S> type, QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); S getNext(); S getCurrent(); void close(); BeanLazyScrollUpdateOutputHandler handle(List<QueryParameters> outputList); boolean hasPrev(); S getPrev(); boolean moveTo(int row); boolean moveRelative(int rows); int position(); void updateRow(S row); void insertRow(S row); }### Answer: @Test public void testGetCurrent() throws Exception { innerTestGetPrepare(); innerTestGetCurrent(new BeanLazyScrollUpdateOutputHandler<Character>(Character.class).handle(new QueryParametersLazyList(stmt, typeHandler, false))); }
### Question: BeanLazyScrollUpdateOutputHandler extends AbstractScrollUpdateLazyOutputHandler implements LazyScrollUpdateOutputHandler<BeanLazyScrollUpdateOutputHandler, S> { public void close() { innerClose(); } BeanLazyScrollUpdateOutputHandler(Class<S> type); BeanLazyScrollUpdateOutputHandler(Class<S> type, QueryOutputProcessor processor); private BeanLazyScrollUpdateOutputHandler(Class<S> type, QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); S getNext(); S getCurrent(); void close(); BeanLazyScrollUpdateOutputHandler handle(List<QueryParameters> outputList); boolean hasPrev(); S getPrev(); boolean moveTo(int row); boolean moveRelative(int rows); int position(); void updateRow(S row); void insertRow(S row); }### Answer: @Test public void testClose() throws Exception { innerTestClosePrepare(); innerTestClose(new BeanLazyScrollUpdateOutputHandler<Character>(Character.class).handle(new QueryParametersLazyList(stmt, typeHandler, false))); }
### Question: BeanLazyScrollUpdateOutputHandler extends AbstractScrollUpdateLazyOutputHandler implements LazyScrollUpdateOutputHandler<BeanLazyScrollUpdateOutputHandler, S> { public BeanLazyScrollUpdateOutputHandler handle(List<QueryParameters> outputList) throws MjdbcException { if (outputList instanceof QueryParametersLazyList) { return new BeanLazyScrollUpdateOutputHandler(this.type, this.processor, (QueryParametersLazyList) outputList); } else { throw new MjdbcRuntimeException("LazyOutputHandler can be used only together with LazyStatementHandler. \n" + "Please assign LazyStatementHandler to this QueryRunner or create new QueryRunnerService via MjdbcFactory"); } } BeanLazyScrollUpdateOutputHandler(Class<S> type); BeanLazyScrollUpdateOutputHandler(Class<S> type, QueryOutputProcessor processor); private BeanLazyScrollUpdateOutputHandler(Class<S> type, QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); S getNext(); S getCurrent(); void close(); BeanLazyScrollUpdateOutputHandler handle(List<QueryParameters> outputList); boolean hasPrev(); S getPrev(); boolean moveTo(int row); boolean moveRelative(int rows); int position(); void updateRow(S row); void insertRow(S row); }### Answer: @Test public void testHandle() throws Exception { innerTestHandle(new BeanLazyScrollUpdateOutputHandler<Character>(Character.class).handle(new QueryParametersLazyList(stmt, typeHandler, false)) instanceof BeanLazyScrollUpdateOutputHandler); } @Test public void testEmpty() throws Exception { innerTestEmpty(new BeanLazyScrollUpdateOutputHandler<Character>(Character.class).handle(new QueryParametersLazyList(stmt, typeHandler, false))); }
### Question: BeanLazyScrollUpdateOutputHandler extends AbstractScrollUpdateLazyOutputHandler implements LazyScrollUpdateOutputHandler<BeanLazyScrollUpdateOutputHandler, S> { public boolean hasPrev() { return innerHasPrev(); } BeanLazyScrollUpdateOutputHandler(Class<S> type); BeanLazyScrollUpdateOutputHandler(Class<S> type, QueryOutputProcessor processor); private BeanLazyScrollUpdateOutputHandler(Class<S> type, QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); S getNext(); S getCurrent(); void close(); BeanLazyScrollUpdateOutputHandler handle(List<QueryParameters> outputList); boolean hasPrev(); S getPrev(); boolean moveTo(int row); boolean moveRelative(int rows); int position(); void updateRow(S row); void insertRow(S row); }### Answer: @Test public void testHasPrev() throws Exception { innerTestHasPrepare(); innerTestHasPrev(new BeanLazyScrollUpdateOutputHandler<Character>(Character.class).handle(new QueryParametersLazyList(stmt, typeHandler, false))); }
### Question: BeanLazyScrollUpdateOutputHandler extends AbstractScrollUpdateLazyOutputHandler implements LazyScrollUpdateOutputHandler<BeanLazyScrollUpdateOutputHandler, S> { public S getPrev() { S result = null; QueryParameters params = innerGetPrev(); try { result = processor.toBean(params, this.type); } catch (MjdbcException ex) { throw new MjdbcRuntimeException(ex); } return result; } BeanLazyScrollUpdateOutputHandler(Class<S> type); BeanLazyScrollUpdateOutputHandler(Class<S> type, QueryOutputProcessor processor); private BeanLazyScrollUpdateOutputHandler(Class<S> type, QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); S getNext(); S getCurrent(); void close(); BeanLazyScrollUpdateOutputHandler handle(List<QueryParameters> outputList); boolean hasPrev(); S getPrev(); boolean moveTo(int row); boolean moveRelative(int rows); int position(); void updateRow(S row); void insertRow(S row); }### Answer: @Test public void testGetPrev() throws Exception { innerTestGetPrepare(); innerTestGetPrev(new BeanLazyScrollUpdateOutputHandler<Character>(Character.class).handle(new QueryParametersLazyList(stmt, typeHandler, false))); }
### Question: BeanLazyScrollUpdateOutputHandler extends AbstractScrollUpdateLazyOutputHandler implements LazyScrollUpdateOutputHandler<BeanLazyScrollUpdateOutputHandler, S> { public boolean moveTo(int row) { return innerMoveTo(row); } BeanLazyScrollUpdateOutputHandler(Class<S> type); BeanLazyScrollUpdateOutputHandler(Class<S> type, QueryOutputProcessor processor); private BeanLazyScrollUpdateOutputHandler(Class<S> type, QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); S getNext(); S getCurrent(); void close(); BeanLazyScrollUpdateOutputHandler handle(List<QueryParameters> outputList); boolean hasPrev(); S getPrev(); boolean moveTo(int row); boolean moveRelative(int rows); int position(); void updateRow(S row); void insertRow(S row); }### Answer: @Test public void testMoveTo() throws Exception { innerTestGetPrepare(); innerTestMoveTo(new BeanLazyScrollUpdateOutputHandler<Character>(Character.class).handle(new QueryParametersLazyList(stmt, typeHandler, false))); }
### Question: Overrider { public boolean hasOverride(String operation) { boolean result = false; if (this.overrideOnce.containsKey(operation) == true || this.override.containsKey(operation) == true) { result = true; } return result; } Overrider(); Overrider(Overrider overrider); void overrideOnce(String operation, Object value); void override(String operation, Object value); void removeOverride(String operation); boolean hasOverride(String operation); Object getOverride(String operation); }### Answer: @Test public void testHasOverride() throws Exception { String name = "value"; String value = "once"; overrider.overrideOnce(name, value); Assert.assertEquals(overrider.hasOverride(name), true); overrider.removeOverride(name); Assert.assertEquals(overrider.hasOverride(name), false); }
### Question: BeanLazyScrollUpdateOutputHandler extends AbstractScrollUpdateLazyOutputHandler implements LazyScrollUpdateOutputHandler<BeanLazyScrollUpdateOutputHandler, S> { public boolean moveRelative(int rows) { return innerMoveRelative(rows); } BeanLazyScrollUpdateOutputHandler(Class<S> type); BeanLazyScrollUpdateOutputHandler(Class<S> type, QueryOutputProcessor processor); private BeanLazyScrollUpdateOutputHandler(Class<S> type, QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); S getNext(); S getCurrent(); void close(); BeanLazyScrollUpdateOutputHandler handle(List<QueryParameters> outputList); boolean hasPrev(); S getPrev(); boolean moveTo(int row); boolean moveRelative(int rows); int position(); void updateRow(S row); void insertRow(S row); }### Answer: @Test public void testMoveRelative() throws Exception { innerTestGetPrepare(); innerTestMoveRelative(new BeanLazyScrollUpdateOutputHandler<Character>(Character.class).handle(new QueryParametersLazyList(stmt, typeHandler, false))); }
### Question: BeanLazyScrollUpdateOutputHandler extends AbstractScrollUpdateLazyOutputHandler implements LazyScrollUpdateOutputHandler<BeanLazyScrollUpdateOutputHandler, S> { public int position() { return innerPosition(); } BeanLazyScrollUpdateOutputHandler(Class<S> type); BeanLazyScrollUpdateOutputHandler(Class<S> type, QueryOutputProcessor processor); private BeanLazyScrollUpdateOutputHandler(Class<S> type, QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); S getNext(); S getCurrent(); void close(); BeanLazyScrollUpdateOutputHandler handle(List<QueryParameters> outputList); boolean hasPrev(); S getPrev(); boolean moveTo(int row); boolean moveRelative(int rows); int position(); void updateRow(S row); void insertRow(S row); }### Answer: @Test public void testPosition() throws Exception { innerTestGetPrepare(); innerTestPosition(new BeanLazyScrollUpdateOutputHandler<Character>(Character.class).handle(new QueryParametersLazyList(stmt, typeHandler, false))); }
### Question: BeanLazyScrollUpdateOutputHandler extends AbstractScrollUpdateLazyOutputHandler implements LazyScrollUpdateOutputHandler<BeanLazyScrollUpdateOutputHandler, S> { public void updateRow(S row) throws SQLException { innerUpdateRow(new QueryParameters(row.getClass(), row)); } BeanLazyScrollUpdateOutputHandler(Class<S> type); BeanLazyScrollUpdateOutputHandler(Class<S> type, QueryOutputProcessor processor); private BeanLazyScrollUpdateOutputHandler(Class<S> type, QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); S getNext(); S getCurrent(); void close(); BeanLazyScrollUpdateOutputHandler handle(List<QueryParameters> outputList); boolean hasPrev(); S getPrev(); boolean moveTo(int row); boolean moveRelative(int rows); int position(); void updateRow(S row); void insertRow(S row); }### Answer: @Test public void testUpdateRow() throws Exception { testTestUpdatePrepare(); QueryParametersLazyList queryParamsLazyList = new QueryParametersLazyList(stmt, typeHandler, false); queryParamsLazyList.setType(QueryParametersLazyList.Type.UPDATE_SCROLL); testTestUpdateRow(new BeanLazyScrollUpdateOutputHandler<Character>(Character.class).handle(queryParamsLazyList), zoe); }
### Question: BeanLazyScrollUpdateOutputHandler extends AbstractScrollUpdateLazyOutputHandler implements LazyScrollUpdateOutputHandler<BeanLazyScrollUpdateOutputHandler, S> { public void insertRow(S row) throws SQLException { innerInsertRow(new QueryParameters(row.getClass(), row)); } BeanLazyScrollUpdateOutputHandler(Class<S> type); BeanLazyScrollUpdateOutputHandler(Class<S> type, QueryOutputProcessor processor); private BeanLazyScrollUpdateOutputHandler(Class<S> type, QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); S getNext(); S getCurrent(); void close(); BeanLazyScrollUpdateOutputHandler handle(List<QueryParameters> outputList); boolean hasPrev(); S getPrev(); boolean moveTo(int row); boolean moveRelative(int rows); int position(); void updateRow(S row); void insertRow(S row); }### Answer: @Test public void testInsertRow() throws Exception { testTestUpdatePrepare(); QueryParametersLazyList queryParamsLazyList = new QueryParametersLazyList(stmt, typeHandler, false); queryParamsLazyList.setType(QueryParametersLazyList.Type.UPDATE_SCROLL); testTestInsertRow(new BeanLazyScrollUpdateOutputHandler<Character>(Character.class).handle(queryParamsLazyList), zoe); }
### Question: MapLazyScrollUpdateOutputHandler extends AbstractScrollUpdateLazyOutputHandler implements LazyScrollUpdateOutputHandler<MapLazyScrollUpdateOutputHandler, Map<String, Object>> { public boolean hasNext() { return innerHasNext(); } MapLazyScrollUpdateOutputHandler(); MapLazyScrollUpdateOutputHandler(QueryOutputProcessor processor); private MapLazyScrollUpdateOutputHandler(QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); Map<String, Object> getNext(); Map<String, Object> getCurrent(); void close(); MapLazyScrollUpdateOutputHandler handle(List<QueryParameters> outputList); boolean hasPrev(); Map<String, Object> getPrev(); boolean moveTo(int row); boolean moveRelative(int rows); int position(); void updateRow(Map<String, Object> row); void insertRow(Map<String, Object> row); }### Answer: @Test public void testHasNext() throws Exception { innerTestHasPrepare(); innerTestHasNext(new MapLazyScrollUpdateOutputHandler().handle(new QueryParametersLazyList(stmt, typeHandler, false))); }
### Question: MapLazyScrollUpdateOutputHandler extends AbstractScrollUpdateLazyOutputHandler implements LazyScrollUpdateOutputHandler<MapLazyScrollUpdateOutputHandler, Map<String, Object>> { public Map<String, Object> getNext() { Map<String, Object> result = null; QueryParameters params = innerGetNext(); result = processor.toMap(params); return result; } MapLazyScrollUpdateOutputHandler(); MapLazyScrollUpdateOutputHandler(QueryOutputProcessor processor); private MapLazyScrollUpdateOutputHandler(QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); Map<String, Object> getNext(); Map<String, Object> getCurrent(); void close(); MapLazyScrollUpdateOutputHandler handle(List<QueryParameters> outputList); boolean hasPrev(); Map<String, Object> getPrev(); boolean moveTo(int row); boolean moveRelative(int rows); int position(); void updateRow(Map<String, Object> row); void insertRow(Map<String, Object> row); }### Answer: @Test public void testGetNext() throws Exception { innerTestGetPrepare(); innerTestGetNext(new MapLazyScrollUpdateOutputHandler().handle(new QueryParametersLazyList(stmt, typeHandler, false))); }
### Question: MapLazyScrollUpdateOutputHandler extends AbstractScrollUpdateLazyOutputHandler implements LazyScrollUpdateOutputHandler<MapLazyScrollUpdateOutputHandler, Map<String, Object>> { public Map<String, Object> getCurrent() { Map<String, Object> result = null; QueryParameters params = innerGetCurrent(); result = processor.toMap(params); return result; } MapLazyScrollUpdateOutputHandler(); MapLazyScrollUpdateOutputHandler(QueryOutputProcessor processor); private MapLazyScrollUpdateOutputHandler(QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); Map<String, Object> getNext(); Map<String, Object> getCurrent(); void close(); MapLazyScrollUpdateOutputHandler handle(List<QueryParameters> outputList); boolean hasPrev(); Map<String, Object> getPrev(); boolean moveTo(int row); boolean moveRelative(int rows); int position(); void updateRow(Map<String, Object> row); void insertRow(Map<String, Object> row); }### Answer: @Test public void testGetCurrent() throws Exception { innerTestGetPrepare(); innerTestGetCurrent(new MapLazyScrollUpdateOutputHandler().handle(new QueryParametersLazyList(stmt, typeHandler, false))); }
### Question: MapLazyScrollUpdateOutputHandler extends AbstractScrollUpdateLazyOutputHandler implements LazyScrollUpdateOutputHandler<MapLazyScrollUpdateOutputHandler, Map<String, Object>> { public void close() { innerClose(); } MapLazyScrollUpdateOutputHandler(); MapLazyScrollUpdateOutputHandler(QueryOutputProcessor processor); private MapLazyScrollUpdateOutputHandler(QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); Map<String, Object> getNext(); Map<String, Object> getCurrent(); void close(); MapLazyScrollUpdateOutputHandler handle(List<QueryParameters> outputList); boolean hasPrev(); Map<String, Object> getPrev(); boolean moveTo(int row); boolean moveRelative(int rows); int position(); void updateRow(Map<String, Object> row); void insertRow(Map<String, Object> row); }### Answer: @Test public void testClose() throws Exception { innerTestClosePrepare(); innerTestClose(new MapLazyScrollUpdateOutputHandler().handle(new QueryParametersLazyList(stmt, typeHandler, false))); }
### Question: MapLazyScrollUpdateOutputHandler extends AbstractScrollUpdateLazyOutputHandler implements LazyScrollUpdateOutputHandler<MapLazyScrollUpdateOutputHandler, Map<String, Object>> { public MapLazyScrollUpdateOutputHandler handle(List<QueryParameters> outputList) throws MjdbcException { if (outputList instanceof QueryParametersLazyList) { return new MapLazyScrollUpdateOutputHandler(this.processor, (QueryParametersLazyList) outputList); } else { throw new MjdbcRuntimeException("LazyOutputHandler can be used only together with LazyStatementHandler. \n" + "Please assign LazyStatementHandler to this QueryRunner or create new QueryRunnerService via MjdbcFactory"); } } MapLazyScrollUpdateOutputHandler(); MapLazyScrollUpdateOutputHandler(QueryOutputProcessor processor); private MapLazyScrollUpdateOutputHandler(QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); Map<String, Object> getNext(); Map<String, Object> getCurrent(); void close(); MapLazyScrollUpdateOutputHandler handle(List<QueryParameters> outputList); boolean hasPrev(); Map<String, Object> getPrev(); boolean moveTo(int row); boolean moveRelative(int rows); int position(); void updateRow(Map<String, Object> row); void insertRow(Map<String, Object> row); }### Answer: @Test public void testHandle() throws Exception { innerTestHandle(new MapLazyScrollUpdateOutputHandler().handle(new QueryParametersLazyList(stmt, typeHandler, false)) instanceof MapLazyScrollUpdateOutputHandler); } @Test public void testEmpty() throws Exception { innerTestEmpty(new MapLazyScrollUpdateOutputHandler().handle(new QueryParametersLazyList(stmt, typeHandler, false))); }
### Question: Overrider { public Object getOverride(String operation) { Object result = null; if (this.overrideOnce.containsKey(operation) == true) { result = this.overrideOnce.get(operation); this.overrideOnce.remove(operation); } else if (this.override.containsKey(operation) == true) { result = this.override.get(operation); } return result; } Overrider(); Overrider(Overrider overrider); void overrideOnce(String operation, Object value); void override(String operation, Object value); void removeOverride(String operation); boolean hasOverride(String operation); Object getOverride(String operation); }### Answer: @Test public void testGetOverride() throws Exception { testOverrideOnce(); testOverride(); }
### Question: MapLazyScrollUpdateOutputHandler extends AbstractScrollUpdateLazyOutputHandler implements LazyScrollUpdateOutputHandler<MapLazyScrollUpdateOutputHandler, Map<String, Object>> { public boolean hasPrev() { return innerHasPrev(); } MapLazyScrollUpdateOutputHandler(); MapLazyScrollUpdateOutputHandler(QueryOutputProcessor processor); private MapLazyScrollUpdateOutputHandler(QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); Map<String, Object> getNext(); Map<String, Object> getCurrent(); void close(); MapLazyScrollUpdateOutputHandler handle(List<QueryParameters> outputList); boolean hasPrev(); Map<String, Object> getPrev(); boolean moveTo(int row); boolean moveRelative(int rows); int position(); void updateRow(Map<String, Object> row); void insertRow(Map<String, Object> row); }### Answer: @Test public void testHasPrev() throws Exception { innerTestHasPrepare(); innerTestHasPrev(new MapLazyScrollUpdateOutputHandler().handle(new QueryParametersLazyList(stmt, typeHandler, false))); }
### Question: MapLazyScrollUpdateOutputHandler extends AbstractScrollUpdateLazyOutputHandler implements LazyScrollUpdateOutputHandler<MapLazyScrollUpdateOutputHandler, Map<String, Object>> { public Map<String, Object> getPrev() { Map<String, Object> result = null; QueryParameters params = innerGetPrev(); result = processor.toMap(params); return result; } MapLazyScrollUpdateOutputHandler(); MapLazyScrollUpdateOutputHandler(QueryOutputProcessor processor); private MapLazyScrollUpdateOutputHandler(QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); Map<String, Object> getNext(); Map<String, Object> getCurrent(); void close(); MapLazyScrollUpdateOutputHandler handle(List<QueryParameters> outputList); boolean hasPrev(); Map<String, Object> getPrev(); boolean moveTo(int row); boolean moveRelative(int rows); int position(); void updateRow(Map<String, Object> row); void insertRow(Map<String, Object> row); }### Answer: @Test public void testGetPrev() throws Exception { innerTestGetPrepare(); innerTestGetPrev(new MapLazyScrollUpdateOutputHandler().handle(new QueryParametersLazyList(stmt, typeHandler, false))); }
### Question: MapLazyScrollUpdateOutputHandler extends AbstractScrollUpdateLazyOutputHandler implements LazyScrollUpdateOutputHandler<MapLazyScrollUpdateOutputHandler, Map<String, Object>> { public boolean moveTo(int row) { return innerMoveTo(row); } MapLazyScrollUpdateOutputHandler(); MapLazyScrollUpdateOutputHandler(QueryOutputProcessor processor); private MapLazyScrollUpdateOutputHandler(QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); Map<String, Object> getNext(); Map<String, Object> getCurrent(); void close(); MapLazyScrollUpdateOutputHandler handle(List<QueryParameters> outputList); boolean hasPrev(); Map<String, Object> getPrev(); boolean moveTo(int row); boolean moveRelative(int rows); int position(); void updateRow(Map<String, Object> row); void insertRow(Map<String, Object> row); }### Answer: @Test public void testMoveTo() throws Exception { innerTestGetPrepare(); innerTestMoveTo(new MapLazyScrollUpdateOutputHandler().handle(new QueryParametersLazyList(stmt, typeHandler, false))); }
### Question: MapLazyScrollUpdateOutputHandler extends AbstractScrollUpdateLazyOutputHandler implements LazyScrollUpdateOutputHandler<MapLazyScrollUpdateOutputHandler, Map<String, Object>> { public boolean moveRelative(int rows) { return innerMoveRelative(rows); } MapLazyScrollUpdateOutputHandler(); MapLazyScrollUpdateOutputHandler(QueryOutputProcessor processor); private MapLazyScrollUpdateOutputHandler(QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); Map<String, Object> getNext(); Map<String, Object> getCurrent(); void close(); MapLazyScrollUpdateOutputHandler handle(List<QueryParameters> outputList); boolean hasPrev(); Map<String, Object> getPrev(); boolean moveTo(int row); boolean moveRelative(int rows); int position(); void updateRow(Map<String, Object> row); void insertRow(Map<String, Object> row); }### Answer: @Test public void testMoveRelative() throws Exception { innerTestGetPrepare(); innerTestMoveRelative(new MapLazyScrollUpdateOutputHandler().handle(new QueryParametersLazyList(stmt, typeHandler, false))); }
### Question: MapLazyScrollUpdateOutputHandler extends AbstractScrollUpdateLazyOutputHandler implements LazyScrollUpdateOutputHandler<MapLazyScrollUpdateOutputHandler, Map<String, Object>> { public int position() { return innerPosition(); } MapLazyScrollUpdateOutputHandler(); MapLazyScrollUpdateOutputHandler(QueryOutputProcessor processor); private MapLazyScrollUpdateOutputHandler(QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); Map<String, Object> getNext(); Map<String, Object> getCurrent(); void close(); MapLazyScrollUpdateOutputHandler handle(List<QueryParameters> outputList); boolean hasPrev(); Map<String, Object> getPrev(); boolean moveTo(int row); boolean moveRelative(int rows); int position(); void updateRow(Map<String, Object> row); void insertRow(Map<String, Object> row); }### Answer: @Test public void testPosition() throws Exception { innerTestGetPrepare(); innerTestPosition(new MapLazyScrollUpdateOutputHandler().handle(new QueryParametersLazyList(stmt, typeHandler, false))); }
### Question: MapLazyScrollUpdateOutputHandler extends AbstractScrollUpdateLazyOutputHandler implements LazyScrollUpdateOutputHandler<MapLazyScrollUpdateOutputHandler, Map<String, Object>> { public void updateRow(Map<String, Object> row) throws SQLException { innerUpdateRow(new QueryParameters(row)); } MapLazyScrollUpdateOutputHandler(); MapLazyScrollUpdateOutputHandler(QueryOutputProcessor processor); private MapLazyScrollUpdateOutputHandler(QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); Map<String, Object> getNext(); Map<String, Object> getCurrent(); void close(); MapLazyScrollUpdateOutputHandler handle(List<QueryParameters> outputList); boolean hasPrev(); Map<String, Object> getPrev(); boolean moveTo(int row); boolean moveRelative(int rows); int position(); void updateRow(Map<String, Object> row); void insertRow(Map<String, Object> row); }### Answer: @Test public void testUpdateRow() throws Exception { testTestUpdatePrepare(); QueryParametersLazyList queryParamsLazyList = new QueryParametersLazyList(stmt, typeHandler, false); queryParamsLazyList.setType(QueryParametersLazyList.Type.UPDATE_SCROLL); testTestUpdateRow(new MapLazyScrollUpdateOutputHandler().handle(queryParamsLazyList), params.toMap()); }
### Question: MapLazyScrollUpdateOutputHandler extends AbstractScrollUpdateLazyOutputHandler implements LazyScrollUpdateOutputHandler<MapLazyScrollUpdateOutputHandler, Map<String, Object>> { public void insertRow(Map<String, Object> row) throws SQLException { innerInsertRow(new QueryParameters(row)); } MapLazyScrollUpdateOutputHandler(); MapLazyScrollUpdateOutputHandler(QueryOutputProcessor processor); private MapLazyScrollUpdateOutputHandler(QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); Map<String, Object> getNext(); Map<String, Object> getCurrent(); void close(); MapLazyScrollUpdateOutputHandler handle(List<QueryParameters> outputList); boolean hasPrev(); Map<String, Object> getPrev(); boolean moveTo(int row); boolean moveRelative(int rows); int position(); void updateRow(Map<String, Object> row); void insertRow(Map<String, Object> row); }### Answer: @Test public void testInsertRow() throws Exception { testTestUpdatePrepare(); QueryParametersLazyList queryParamsLazyList = new QueryParametersLazyList(stmt, typeHandler, false); queryParamsLazyList.setType(QueryParametersLazyList.Type.UPDATE_SCROLL); testTestInsertRow(new MapLazyScrollUpdateOutputHandler().handle(queryParamsLazyList), params.toMap()); }
### Question: BeanLazyUpdateOutputHandler extends AbstractScrollUpdateLazyOutputHandler implements LazyUpdateOutputHandler<BeanLazyUpdateOutputHandler, S> { public boolean hasNext() { return super.innerHasNext(); } BeanLazyUpdateOutputHandler(Class<S> type); BeanLazyUpdateOutputHandler(Class<S> type, QueryOutputProcessor processor); private BeanLazyUpdateOutputHandler(Class<S> type, QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); S getNext(); S getCurrent(); void close(); BeanLazyUpdateOutputHandler handle(List<QueryParameters> outputList); void updateRow(S row); void insertRow(S row); }### Answer: @Test public void testHasNext() throws Exception { innerTestHasPrepare(); innerTestHasNext(new BeanLazyUpdateOutputHandler<Character>(Character.class).handle(new QueryParametersLazyList(stmt, typeHandler, false))); }
### Question: BeanLazyUpdateOutputHandler extends AbstractScrollUpdateLazyOutputHandler implements LazyUpdateOutputHandler<BeanLazyUpdateOutputHandler, S> { public S getNext() { S result = null; QueryParameters params = innerGetNext(); try { result = processor.toBean(params, this.type); } catch (MjdbcException ex) { throw new MjdbcRuntimeException(ex); } return result; } BeanLazyUpdateOutputHandler(Class<S> type); BeanLazyUpdateOutputHandler(Class<S> type, QueryOutputProcessor processor); private BeanLazyUpdateOutputHandler(Class<S> type, QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); S getNext(); S getCurrent(); void close(); BeanLazyUpdateOutputHandler handle(List<QueryParameters> outputList); void updateRow(S row); void insertRow(S row); }### Answer: @Test public void testGetNext() throws Exception { innerTestGetPrepare(); innerTestGetNext(new BeanLazyUpdateOutputHandler<Character>(Character.class).handle(new QueryParametersLazyList(stmt, typeHandler, false))); }
### Question: BeanLazyUpdateOutputHandler extends AbstractScrollUpdateLazyOutputHandler implements LazyUpdateOutputHandler<BeanLazyUpdateOutputHandler, S> { public S getCurrent() { S result = null; QueryParameters params = innerGetCurrent(); try { result = processor.toBean(params, this.type); } catch (MjdbcException ex) { throw new MjdbcRuntimeException(ex); } return result; } BeanLazyUpdateOutputHandler(Class<S> type); BeanLazyUpdateOutputHandler(Class<S> type, QueryOutputProcessor processor); private BeanLazyUpdateOutputHandler(Class<S> type, QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); S getNext(); S getCurrent(); void close(); BeanLazyUpdateOutputHandler handle(List<QueryParameters> outputList); void updateRow(S row); void insertRow(S row); }### Answer: @Test public void testGetCurrent() throws Exception { innerTestGetPrepare(); innerTestGetCurrent(new BeanLazyUpdateOutputHandler<Character>(Character.class).handle(new QueryParametersLazyList(stmt, typeHandler, false))); }
### Question: BeanLazyUpdateOutputHandler extends AbstractScrollUpdateLazyOutputHandler implements LazyUpdateOutputHandler<BeanLazyUpdateOutputHandler, S> { public void close() { innerClose(); } BeanLazyUpdateOutputHandler(Class<S> type); BeanLazyUpdateOutputHandler(Class<S> type, QueryOutputProcessor processor); private BeanLazyUpdateOutputHandler(Class<S> type, QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); S getNext(); S getCurrent(); void close(); BeanLazyUpdateOutputHandler handle(List<QueryParameters> outputList); void updateRow(S row); void insertRow(S row); }### Answer: @Test public void testClose() throws Exception { innerTestClosePrepare(); innerTestClose(new BeanLazyUpdateOutputHandler<Character>(Character.class).handle(new QueryParametersLazyList(stmt, typeHandler, false))); }
### Question: BeanLazyUpdateOutputHandler extends AbstractScrollUpdateLazyOutputHandler implements LazyUpdateOutputHandler<BeanLazyUpdateOutputHandler, S> { public BeanLazyUpdateOutputHandler handle(List<QueryParameters> outputList) throws MjdbcException { if (outputList instanceof QueryParametersLazyList) { return new BeanLazyUpdateOutputHandler(this.type, this.processor, (QueryParametersLazyList) outputList); } else { throw new MjdbcRuntimeException("LazyOutputHandler can be used only together with LazyStatementHandler. \n" + "Please assign LazyStatementHandler to this QueryRunner or create new QueryRunnerService via MjdbcFactory"); } } BeanLazyUpdateOutputHandler(Class<S> type); BeanLazyUpdateOutputHandler(Class<S> type, QueryOutputProcessor processor); private BeanLazyUpdateOutputHandler(Class<S> type, QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); S getNext(); S getCurrent(); void close(); BeanLazyUpdateOutputHandler handle(List<QueryParameters> outputList); void updateRow(S row); void insertRow(S row); }### Answer: @Test public void testHandle() throws Exception { innerTestHandle(new BeanLazyUpdateOutputHandler<Character>(Character.class).handle(new QueryParametersLazyList(stmt, typeHandler, false)) instanceof BeanLazyUpdateOutputHandler); } @Test public void testEmpty() throws Exception { innerTestEmpty(new BeanLazyUpdateOutputHandler<Character>(Character.class).handle(new QueryParametersLazyList(stmt, typeHandler, false))); }
### Question: BeanLazyUpdateOutputHandler extends AbstractScrollUpdateLazyOutputHandler implements LazyUpdateOutputHandler<BeanLazyUpdateOutputHandler, S> { public void updateRow(S row) throws SQLException { innerUpdateRow(new QueryParameters(row.getClass(), row)); } BeanLazyUpdateOutputHandler(Class<S> type); BeanLazyUpdateOutputHandler(Class<S> type, QueryOutputProcessor processor); private BeanLazyUpdateOutputHandler(Class<S> type, QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); S getNext(); S getCurrent(); void close(); BeanLazyUpdateOutputHandler handle(List<QueryParameters> outputList); void updateRow(S row); void insertRow(S row); }### Answer: @Test public void testUpdateRow() throws Exception { testTestUpdatePrepare(); QueryParametersLazyList queryParamsLazyList = new QueryParametersLazyList(stmt, typeHandler, false); queryParamsLazyList.setType(QueryParametersLazyList.Type.UPDATE_SCROLL); testTestUpdateRow(new BeanLazyUpdateOutputHandler<Character>(Character.class).handle(queryParamsLazyList), zoe); }
### Question: BeanLazyUpdateOutputHandler extends AbstractScrollUpdateLazyOutputHandler implements LazyUpdateOutputHandler<BeanLazyUpdateOutputHandler, S> { public void insertRow(S row) throws SQLException { innerInsertRow(new QueryParameters(row.getClass(), row)); } BeanLazyUpdateOutputHandler(Class<S> type); BeanLazyUpdateOutputHandler(Class<S> type, QueryOutputProcessor processor); private BeanLazyUpdateOutputHandler(Class<S> type, QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); S getNext(); S getCurrent(); void close(); BeanLazyUpdateOutputHandler handle(List<QueryParameters> outputList); void updateRow(S row); void insertRow(S row); }### Answer: @Test public void testInsertRow() throws Exception { testTestUpdatePrepare(); QueryParametersLazyList queryParamsLazyList = new QueryParametersLazyList(stmt, typeHandler, false); queryParamsLazyList.setType(QueryParametersLazyList.Type.UPDATE_SCROLL); testTestInsertRow(new BeanLazyUpdateOutputHandler<Character>(Character.class).handle(queryParamsLazyList), zoe); }
### Question: BeanLazyScrollOutputHandler extends AbstractScrollUpdateLazyOutputHandler implements LazyScrollOutputHandler<BeanLazyScrollOutputHandler, S> { public boolean hasNext() { return super.innerHasNext(); } BeanLazyScrollOutputHandler(Class<S> type); BeanLazyScrollOutputHandler(Class<S> type, QueryOutputProcessor processor); private BeanLazyScrollOutputHandler(Class<S> type, QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); S getNext(); S getCurrent(); void close(); BeanLazyScrollOutputHandler handle(List<QueryParameters> outputList); boolean hasPrev(); S getPrev(); boolean moveTo(int row); boolean moveRelative(int rows); int position(); }### Answer: @Test public void testHasNext() throws Exception { innerTestHasPrepare(); innerTestHasNext(new BeanLazyScrollOutputHandler<Character>(Character.class).handle(new QueryParametersLazyList(stmt, typeHandler, false))); }
### Question: BeanLazyScrollOutputHandler extends AbstractScrollUpdateLazyOutputHandler implements LazyScrollOutputHandler<BeanLazyScrollOutputHandler, S> { public S getNext() { S result = null; QueryParameters params = innerGetNext(); try { result = processor.toBean(params, this.type); } catch (MjdbcException ex) { throw new MjdbcRuntimeException(ex); } return result; } BeanLazyScrollOutputHandler(Class<S> type); BeanLazyScrollOutputHandler(Class<S> type, QueryOutputProcessor processor); private BeanLazyScrollOutputHandler(Class<S> type, QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); S getNext(); S getCurrent(); void close(); BeanLazyScrollOutputHandler handle(List<QueryParameters> outputList); boolean hasPrev(); S getPrev(); boolean moveTo(int row); boolean moveRelative(int rows); int position(); }### Answer: @Test public void testGetNext() throws Exception { innerTestGetPrepare(); innerTestGetNext(new BeanLazyScrollOutputHandler<Character>(Character.class).handle(new QueryParametersLazyList(stmt, typeHandler, false))); }
### Question: BeanLazyScrollOutputHandler extends AbstractScrollUpdateLazyOutputHandler implements LazyScrollOutputHandler<BeanLazyScrollOutputHandler, S> { public S getCurrent() { S result = null; QueryParameters params = innerGetCurrent(); try { result = processor.toBean(params, this.type); } catch (MjdbcException ex) { throw new MjdbcRuntimeException(ex); } return result; } BeanLazyScrollOutputHandler(Class<S> type); BeanLazyScrollOutputHandler(Class<S> type, QueryOutputProcessor processor); private BeanLazyScrollOutputHandler(Class<S> type, QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); S getNext(); S getCurrent(); void close(); BeanLazyScrollOutputHandler handle(List<QueryParameters> outputList); boolean hasPrev(); S getPrev(); boolean moveTo(int row); boolean moveRelative(int rows); int position(); }### Answer: @Test public void testGetCurrent() throws Exception { innerTestGetPrepare(); innerTestGetCurrent(new BeanLazyScrollOutputHandler<Character>(Character.class).handle(new QueryParametersLazyList(stmt, typeHandler, false))); }
### Question: BeanLazyScrollOutputHandler extends AbstractScrollUpdateLazyOutputHandler implements LazyScrollOutputHandler<BeanLazyScrollOutputHandler, S> { public void close() { innerClose(); } BeanLazyScrollOutputHandler(Class<S> type); BeanLazyScrollOutputHandler(Class<S> type, QueryOutputProcessor processor); private BeanLazyScrollOutputHandler(Class<S> type, QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); S getNext(); S getCurrent(); void close(); BeanLazyScrollOutputHandler handle(List<QueryParameters> outputList); boolean hasPrev(); S getPrev(); boolean moveTo(int row); boolean moveRelative(int rows); int position(); }### Answer: @Test public void testClose() throws Exception { innerTestClosePrepare(); innerTestClose(new BeanLazyScrollOutputHandler<Character>(Character.class).handle(new QueryParametersLazyList(stmt, typeHandler, false))); }
### Question: BeanLazyScrollOutputHandler extends AbstractScrollUpdateLazyOutputHandler implements LazyScrollOutputHandler<BeanLazyScrollOutputHandler, S> { public BeanLazyScrollOutputHandler handle(List<QueryParameters> outputList) throws MjdbcException { if (outputList instanceof QueryParametersLazyList) { return new BeanLazyScrollOutputHandler(this.type, this.processor, (QueryParametersLazyList) outputList); } else { throw new MjdbcRuntimeException("LazyOutputHandler can be used only together with LazyStatementHandler. \n" + "Please assign LazyStatementHandler to this QueryRunner or create new QueryRunnerService via MjdbcFactory"); } } BeanLazyScrollOutputHandler(Class<S> type); BeanLazyScrollOutputHandler(Class<S> type, QueryOutputProcessor processor); private BeanLazyScrollOutputHandler(Class<S> type, QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); S getNext(); S getCurrent(); void close(); BeanLazyScrollOutputHandler handle(List<QueryParameters> outputList); boolean hasPrev(); S getPrev(); boolean moveTo(int row); boolean moveRelative(int rows); int position(); }### Answer: @Test public void testHandle() throws Exception { innerTestHandle(new BeanLazyScrollOutputHandler<Character>(Character.class).handle(new QueryParametersLazyList(stmt, typeHandler, false)) instanceof BeanLazyScrollOutputHandler); } @Test public void testEmpty() throws Exception { innerTestEmpty(new BeanLazyScrollOutputHandler<Character>(Character.class).handle(new QueryParametersLazyList(stmt, typeHandler, false))); }
### Question: BeanLazyScrollOutputHandler extends AbstractScrollUpdateLazyOutputHandler implements LazyScrollOutputHandler<BeanLazyScrollOutputHandler, S> { public boolean hasPrev() { return innerHasPrev(); } BeanLazyScrollOutputHandler(Class<S> type); BeanLazyScrollOutputHandler(Class<S> type, QueryOutputProcessor processor); private BeanLazyScrollOutputHandler(Class<S> type, QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); S getNext(); S getCurrent(); void close(); BeanLazyScrollOutputHandler handle(List<QueryParameters> outputList); boolean hasPrev(); S getPrev(); boolean moveTo(int row); boolean moveRelative(int rows); int position(); }### Answer: @Test public void testHasPrev() throws Exception { innerTestHasPrepare(); innerTestHasPrev(new BeanLazyScrollOutputHandler<Character>(Character.class).handle(new QueryParametersLazyList(stmt, typeHandler, false))); }
### Question: BeanLazyScrollOutputHandler extends AbstractScrollUpdateLazyOutputHandler implements LazyScrollOutputHandler<BeanLazyScrollOutputHandler, S> { public S getPrev() { S result = null; QueryParameters params = innerGetPrev(); try { result = processor.toBean(params, this.type); } catch (MjdbcException ex) { throw new MjdbcRuntimeException(ex); } return result; } BeanLazyScrollOutputHandler(Class<S> type); BeanLazyScrollOutputHandler(Class<S> type, QueryOutputProcessor processor); private BeanLazyScrollOutputHandler(Class<S> type, QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); S getNext(); S getCurrent(); void close(); BeanLazyScrollOutputHandler handle(List<QueryParameters> outputList); boolean hasPrev(); S getPrev(); boolean moveTo(int row); boolean moveRelative(int rows); int position(); }### Answer: @Test public void testGetPrev() throws Exception { innerTestGetPrepare(); innerTestGetPrev(new BeanLazyScrollOutputHandler<Character>(Character.class).handle(new QueryParametersLazyList(stmt, typeHandler, false))); }
### Question: BeanLazyScrollOutputHandler extends AbstractScrollUpdateLazyOutputHandler implements LazyScrollOutputHandler<BeanLazyScrollOutputHandler, S> { public boolean moveTo(int row) { return innerMoveTo(row); } BeanLazyScrollOutputHandler(Class<S> type); BeanLazyScrollOutputHandler(Class<S> type, QueryOutputProcessor processor); private BeanLazyScrollOutputHandler(Class<S> type, QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); S getNext(); S getCurrent(); void close(); BeanLazyScrollOutputHandler handle(List<QueryParameters> outputList); boolean hasPrev(); S getPrev(); boolean moveTo(int row); boolean moveRelative(int rows); int position(); }### Answer: @Test public void testMoveTo() throws Exception { innerTestGetPrepare(); innerTestMoveTo(new BeanLazyScrollOutputHandler<Character>(Character.class).handle(new QueryParametersLazyList(stmt, typeHandler, false))); }
### Question: BeanLazyScrollOutputHandler extends AbstractScrollUpdateLazyOutputHandler implements LazyScrollOutputHandler<BeanLazyScrollOutputHandler, S> { public boolean moveRelative(int rows) { return innerMoveRelative(rows); } BeanLazyScrollOutputHandler(Class<S> type); BeanLazyScrollOutputHandler(Class<S> type, QueryOutputProcessor processor); private BeanLazyScrollOutputHandler(Class<S> type, QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); S getNext(); S getCurrent(); void close(); BeanLazyScrollOutputHandler handle(List<QueryParameters> outputList); boolean hasPrev(); S getPrev(); boolean moveTo(int row); boolean moveRelative(int rows); int position(); }### Answer: @Test public void testMoveRelative() throws Exception { innerTestGetPrepare(); innerTestMoveRelative(new BeanLazyScrollOutputHandler<Character>(Character.class).handle(new QueryParametersLazyList(stmt, typeHandler, false))); }
### Question: BeanLazyScrollOutputHandler extends AbstractScrollUpdateLazyOutputHandler implements LazyScrollOutputHandler<BeanLazyScrollOutputHandler, S> { public int position() { return innerPosition(); } BeanLazyScrollOutputHandler(Class<S> type); BeanLazyScrollOutputHandler(Class<S> type, QueryOutputProcessor processor); private BeanLazyScrollOutputHandler(Class<S> type, QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); S getNext(); S getCurrent(); void close(); BeanLazyScrollOutputHandler handle(List<QueryParameters> outputList); boolean hasPrev(); S getPrev(); boolean moveTo(int row); boolean moveRelative(int rows); int position(); }### Answer: @Test public void testPosition() throws Exception { innerTestGetPrepare(); innerTestPosition(new BeanLazyScrollOutputHandler<Character>(Character.class).handle(new QueryParametersLazyList(stmt, typeHandler, false))); }
### Question: MapLazyUpdateOutputHandler extends AbstractScrollUpdateLazyOutputHandler implements LazyUpdateOutputHandler<MapLazyUpdateOutputHandler, Map<String, Object>> { public boolean hasNext() { return innerHasNext(); } MapLazyUpdateOutputHandler(); MapLazyUpdateOutputHandler(QueryOutputProcessor processor); private MapLazyUpdateOutputHandler(QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); Map<String, Object> getNext(); Map<String, Object> getCurrent(); void close(); MapLazyUpdateOutputHandler handle(List<QueryParameters> outputList); void updateRow(Map<String, Object> row); void insertRow(Map<String, Object> row); }### Answer: @Test public void testHasNext() throws Exception { innerTestHasPrepare(); innerTestHasNext(new MapLazyUpdateOutputHandler().handle(new QueryParametersLazyList(stmt, typeHandler, false))); }
### Question: MapLazyUpdateOutputHandler extends AbstractScrollUpdateLazyOutputHandler implements LazyUpdateOutputHandler<MapLazyUpdateOutputHandler, Map<String, Object>> { public Map<String, Object> getNext() { Map<String, Object> result = null; QueryParameters params = innerGetNext(); result = processor.toMap(params); return result; } MapLazyUpdateOutputHandler(); MapLazyUpdateOutputHandler(QueryOutputProcessor processor); private MapLazyUpdateOutputHandler(QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); Map<String, Object> getNext(); Map<String, Object> getCurrent(); void close(); MapLazyUpdateOutputHandler handle(List<QueryParameters> outputList); void updateRow(Map<String, Object> row); void insertRow(Map<String, Object> row); }### Answer: @Test public void testGetNext() throws Exception { innerTestGetPrepare(); innerTestGetNext(new MapLazyUpdateOutputHandler().handle(new QueryParametersLazyList(stmt, typeHandler, false))); }
### Question: MapLazyUpdateOutputHandler extends AbstractScrollUpdateLazyOutputHandler implements LazyUpdateOutputHandler<MapLazyUpdateOutputHandler, Map<String, Object>> { public Map<String, Object> getCurrent() { Map<String, Object> result = null; QueryParameters params = innerGetCurrent(); result = processor.toMap(params); return result; } MapLazyUpdateOutputHandler(); MapLazyUpdateOutputHandler(QueryOutputProcessor processor); private MapLazyUpdateOutputHandler(QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); Map<String, Object> getNext(); Map<String, Object> getCurrent(); void close(); MapLazyUpdateOutputHandler handle(List<QueryParameters> outputList); void updateRow(Map<String, Object> row); void insertRow(Map<String, Object> row); }### Answer: @Test public void testGetCurrent() throws Exception { innerTestGetPrepare(); innerTestGetCurrent(new MapLazyUpdateOutputHandler().handle(new QueryParametersLazyList(stmt, typeHandler, false))); }
### Question: MapLazyUpdateOutputHandler extends AbstractScrollUpdateLazyOutputHandler implements LazyUpdateOutputHandler<MapLazyUpdateOutputHandler, Map<String, Object>> { public void close() { innerClose(); } MapLazyUpdateOutputHandler(); MapLazyUpdateOutputHandler(QueryOutputProcessor processor); private MapLazyUpdateOutputHandler(QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); Map<String, Object> getNext(); Map<String, Object> getCurrent(); void close(); MapLazyUpdateOutputHandler handle(List<QueryParameters> outputList); void updateRow(Map<String, Object> row); void insertRow(Map<String, Object> row); }### Answer: @Test public void testClose() throws Exception { innerTestClosePrepare(); innerTestClose(new MapLazyUpdateOutputHandler().handle(new QueryParametersLazyList(stmt, typeHandler, false))); }
### Question: MapLazyUpdateOutputHandler extends AbstractScrollUpdateLazyOutputHandler implements LazyUpdateOutputHandler<MapLazyUpdateOutputHandler, Map<String, Object>> { public MapLazyUpdateOutputHandler handle(List<QueryParameters> outputList) throws MjdbcException { if (outputList instanceof QueryParametersLazyList) { return new MapLazyUpdateOutputHandler(this.processor, (QueryParametersLazyList) outputList); } else { throw new MjdbcRuntimeException("LazyOutputHandler can be used only together with LazyStatementHandler. \n" + "Please assign LazyStatementHandler to this QueryRunner or create new QueryRunnerService via MjdbcFactory"); } } MapLazyUpdateOutputHandler(); MapLazyUpdateOutputHandler(QueryOutputProcessor processor); private MapLazyUpdateOutputHandler(QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); Map<String, Object> getNext(); Map<String, Object> getCurrent(); void close(); MapLazyUpdateOutputHandler handle(List<QueryParameters> outputList); void updateRow(Map<String, Object> row); void insertRow(Map<String, Object> row); }### Answer: @Test public void testHandle() throws Exception { innerTestHandle(new MapLazyUpdateOutputHandler().handle(new QueryParametersLazyList(stmt, typeHandler, false)) instanceof MapLazyUpdateOutputHandler); } @Test public void testEmpty() throws Exception { innerTestEmpty(new MapLazyUpdateOutputHandler().handle(new QueryParametersLazyList(stmt, typeHandler, false))); }
### Question: MapLazyUpdateOutputHandler extends AbstractScrollUpdateLazyOutputHandler implements LazyUpdateOutputHandler<MapLazyUpdateOutputHandler, Map<String, Object>> { public void updateRow(Map<String, Object> row) throws SQLException { innerUpdateRow(new QueryParameters(row)); } MapLazyUpdateOutputHandler(); MapLazyUpdateOutputHandler(QueryOutputProcessor processor); private MapLazyUpdateOutputHandler(QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); Map<String, Object> getNext(); Map<String, Object> getCurrent(); void close(); MapLazyUpdateOutputHandler handle(List<QueryParameters> outputList); void updateRow(Map<String, Object> row); void insertRow(Map<String, Object> row); }### Answer: @Test public void testUpdateRow() throws Exception { testTestUpdatePrepare(); QueryParametersLazyList queryParamsLazyList = new QueryParametersLazyList(stmt, typeHandler, false); queryParamsLazyList.setType(QueryParametersLazyList.Type.UPDATE_SCROLL); testTestUpdateRow(new MapLazyUpdateOutputHandler().handle(queryParamsLazyList), params.toMap()); }
### Question: MapLazyUpdateOutputHandler extends AbstractScrollUpdateLazyOutputHandler implements LazyUpdateOutputHandler<MapLazyUpdateOutputHandler, Map<String, Object>> { public void insertRow(Map<String, Object> row) throws SQLException { innerInsertRow(new QueryParameters(row)); } MapLazyUpdateOutputHandler(); MapLazyUpdateOutputHandler(QueryOutputProcessor processor); private MapLazyUpdateOutputHandler(QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); Map<String, Object> getNext(); Map<String, Object> getCurrent(); void close(); MapLazyUpdateOutputHandler handle(List<QueryParameters> outputList); void updateRow(Map<String, Object> row); void insertRow(Map<String, Object> row); }### Answer: @Test public void testInsertRow() throws Exception { testTestUpdatePrepare(); QueryParametersLazyList queryParamsLazyList = new QueryParametersLazyList(stmt, typeHandler, false); queryParamsLazyList.setType(QueryParametersLazyList.Type.UPDATE_SCROLL); testTestInsertRow(new MapLazyUpdateOutputHandler().handle(queryParamsLazyList), params.toMap()); }
### Question: BeanLazyOutputHandler extends AbstractLazyOutputHandler implements LazyOutputHandler<BeanLazyOutputHandler, S> { public boolean hasNext() { return super.innerHasNext(); } BeanLazyOutputHandler(Class<S> type); BeanLazyOutputHandler(Class<S> type, QueryOutputProcessor processor); private BeanLazyOutputHandler(Class<S> type, QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); S getNext(); S getCurrent(); void close(); BeanLazyOutputHandler handle(List<QueryParameters> outputList); }### Answer: @Test public void testHasNext() throws Exception { innerTestHasPrepare(); innerTestHasNext(new BeanLazyOutputHandler<Character>(Character.class).handle(new QueryParametersLazyList(stmt, typeHandler, false))); }
### Question: BeanLazyOutputHandler extends AbstractLazyOutputHandler implements LazyOutputHandler<BeanLazyOutputHandler, S> { public S getNext() { S result = null; QueryParameters params = innerGetNext(); try { result = processor.toBean(params, this.type); } catch (MjdbcException ex) { throw new MjdbcRuntimeException(ex); } return result; } BeanLazyOutputHandler(Class<S> type); BeanLazyOutputHandler(Class<S> type, QueryOutputProcessor processor); private BeanLazyOutputHandler(Class<S> type, QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); S getNext(); S getCurrent(); void close(); BeanLazyOutputHandler handle(List<QueryParameters> outputList); }### Answer: @Test public void testGetNext() throws Exception { innerTestGetPrepare(); innerTestGetNext(new BeanLazyOutputHandler<Character>(Character.class).handle(new QueryParametersLazyList(stmt, typeHandler, false))); }
### Question: BeanLazyOutputHandler extends AbstractLazyOutputHandler implements LazyOutputHandler<BeanLazyOutputHandler, S> { public S getCurrent() { S result = null; QueryParameters params = innerGetCurrent(); try { result = processor.toBean(params, this.type); } catch (MjdbcException ex) { throw new MjdbcRuntimeException(ex); } return result; } BeanLazyOutputHandler(Class<S> type); BeanLazyOutputHandler(Class<S> type, QueryOutputProcessor processor); private BeanLazyOutputHandler(Class<S> type, QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); S getNext(); S getCurrent(); void close(); BeanLazyOutputHandler handle(List<QueryParameters> outputList); }### Answer: @Test public void testGetCurrent() throws Exception { innerTestGetPrepare(); innerTestGetCurrent(new BeanLazyOutputHandler<Character>(Character.class).handle(new QueryParametersLazyList(stmt, typeHandler, false))); }
### Question: BeanLazyOutputHandler extends AbstractLazyOutputHandler implements LazyOutputHandler<BeanLazyOutputHandler, S> { public void close() { innerClose(); } BeanLazyOutputHandler(Class<S> type); BeanLazyOutputHandler(Class<S> type, QueryOutputProcessor processor); private BeanLazyOutputHandler(Class<S> type, QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); S getNext(); S getCurrent(); void close(); BeanLazyOutputHandler handle(List<QueryParameters> outputList); }### Answer: @Test public void testClose() throws Exception { innerTestClosePrepare(); innerTestClose(new BeanLazyOutputHandler<Character>(Character.class).handle(new QueryParametersLazyList(stmt, typeHandler, false))); }
### Question: BeanLazyOutputHandler extends AbstractLazyOutputHandler implements LazyOutputHandler<BeanLazyOutputHandler, S> { public BeanLazyOutputHandler handle(List<QueryParameters> outputList) throws MjdbcException { if (outputList instanceof QueryParametersLazyList) { return new BeanLazyOutputHandler(this.type, this.processor, (QueryParametersLazyList) outputList); } else { throw new MjdbcRuntimeException("LazyOutputHandler can be used only together with LazyStatementHandler. \n" + "Please assign LazyStatementHandler to this QueryRunner or create new QueryRunnerService via MjdbcFactory"); } } BeanLazyOutputHandler(Class<S> type); BeanLazyOutputHandler(Class<S> type, QueryOutputProcessor processor); private BeanLazyOutputHandler(Class<S> type, QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); S getNext(); S getCurrent(); void close(); BeanLazyOutputHandler handle(List<QueryParameters> outputList); }### Answer: @Test public void testHandle() throws Exception { innerTestHandle(new BeanLazyOutputHandler<Character>(Character.class).handle(new QueryParametersLazyList(stmt, typeHandler, false)) instanceof BeanLazyOutputHandler); } @Test public void testEmpty() throws Exception { innerTestEmpty(new BeanLazyOutputHandler<Character>(Character.class).handle(new QueryParametersLazyList(stmt, typeHandler, false))); }
### Question: MapLazyOutputHandler extends AbstractLazyOutputHandler implements LazyOutputHandler<MapLazyOutputHandler, Map<String, Object>> { public boolean hasNext() { return innerHasNext(); } MapLazyOutputHandler(); MapLazyOutputHandler(QueryOutputProcessor processor); private MapLazyOutputHandler(QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); Map<String, Object> getNext(); Map<String, Object> getCurrent(); void close(); MapLazyOutputHandler handle(List<QueryParameters> outputList); }### Answer: @Test public void testHasNext() throws Exception { innerTestHasPrepare(); innerTestHasNext(new MapLazyOutputHandler().handle(new QueryParametersLazyList(stmt, typeHandler, false))); }
### Question: MapLazyOutputHandler extends AbstractLazyOutputHandler implements LazyOutputHandler<MapLazyOutputHandler, Map<String, Object>> { public Map<String, Object> getNext() { Map<String, Object> result = null; QueryParameters params = innerGetNext(); result = processor.toMap(params); return result; } MapLazyOutputHandler(); MapLazyOutputHandler(QueryOutputProcessor processor); private MapLazyOutputHandler(QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); Map<String, Object> getNext(); Map<String, Object> getCurrent(); void close(); MapLazyOutputHandler handle(List<QueryParameters> outputList); }### Answer: @Test public void testGetNext() throws Exception { innerTestGetPrepare(); innerTestGetNext(new MapLazyOutputHandler().handle(new QueryParametersLazyList(stmt, typeHandler, false))); }
### Question: MapLazyOutputHandler extends AbstractLazyOutputHandler implements LazyOutputHandler<MapLazyOutputHandler, Map<String, Object>> { public Map<String, Object> getCurrent() { Map<String, Object> result = null; QueryParameters params = innerGetCurrent(); result = processor.toMap(params); return result; } MapLazyOutputHandler(); MapLazyOutputHandler(QueryOutputProcessor processor); private MapLazyOutputHandler(QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); Map<String, Object> getNext(); Map<String, Object> getCurrent(); void close(); MapLazyOutputHandler handle(List<QueryParameters> outputList); }### Answer: @Test public void testGetCurrent() throws Exception { innerTestGetPrepare(); innerTestGetCurrent(new MapLazyOutputHandler().handle(new QueryParametersLazyList(stmt, typeHandler, false))); }
### Question: MapLazyOutputHandler extends AbstractLazyOutputHandler implements LazyOutputHandler<MapLazyOutputHandler, Map<String, Object>> { public void close() { innerClose(); } MapLazyOutputHandler(); MapLazyOutputHandler(QueryOutputProcessor processor); private MapLazyOutputHandler(QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); Map<String, Object> getNext(); Map<String, Object> getCurrent(); void close(); MapLazyOutputHandler handle(List<QueryParameters> outputList); }### Answer: @Test public void testClose() throws Exception { innerTestClosePrepare(); innerTestClose(new MapLazyOutputHandler().handle(new QueryParametersLazyList(stmt, typeHandler, false))); }
### Question: MapLazyOutputHandler extends AbstractLazyOutputHandler implements LazyOutputHandler<MapLazyOutputHandler, Map<String, Object>> { public MapLazyOutputHandler handle(List<QueryParameters> outputList) throws MjdbcException { if (outputList instanceof QueryParametersLazyList) { return new MapLazyOutputHandler(this.processor, (QueryParametersLazyList) outputList); } else { throw new MjdbcRuntimeException("LazyOutputHandler can be used only together with LazyStatementHandler. \n" + "Please assign LazyStatementHandler to this QueryRunner or create new QueryRunnerService via MjdbcFactory"); } } MapLazyOutputHandler(); MapLazyOutputHandler(QueryOutputProcessor processor); private MapLazyOutputHandler(QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); Map<String, Object> getNext(); Map<String, Object> getCurrent(); void close(); MapLazyOutputHandler handle(List<QueryParameters> outputList); }### Answer: @Test public void testHandle() throws Exception { innerTestHandle(new MapLazyOutputHandler().handle(new QueryParametersLazyList(stmt, typeHandler, false)) instanceof MapLazyOutputHandler); } @Test public void testEmpty() throws Exception { innerTestEmpty(new MapLazyOutputHandler().handle(new QueryParametersLazyList(stmt, typeHandler, false))); }
### Question: MapLazyScrollOutputHandler extends AbstractScrollUpdateLazyOutputHandler implements LazyScrollOutputHandler<MapLazyScrollOutputHandler, Map<String, Object>> { public boolean hasNext() { return innerHasNext(); } MapLazyScrollOutputHandler(); MapLazyScrollOutputHandler(QueryOutputProcessor processor); private MapLazyScrollOutputHandler(QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); Map<String, Object> getNext(); Map<String, Object> getCurrent(); void close(); MapLazyScrollOutputHandler handle(List<QueryParameters> outputList); boolean hasPrev(); Map<String, Object> getPrev(); boolean moveTo(int row); boolean moveRelative(int rows); int position(); }### Answer: @Test public void testHasNext() throws Exception { innerTestHasPrepare(); innerTestHasNext(new MapLazyScrollOutputHandler().handle(new QueryParametersLazyList(stmt, typeHandler, false))); }
### Question: MapLazyScrollOutputHandler extends AbstractScrollUpdateLazyOutputHandler implements LazyScrollOutputHandler<MapLazyScrollOutputHandler, Map<String, Object>> { public Map<String, Object> getNext() { Map<String, Object> result = null; QueryParameters params = innerGetNext(); result = processor.toMap(params); return result; } MapLazyScrollOutputHandler(); MapLazyScrollOutputHandler(QueryOutputProcessor processor); private MapLazyScrollOutputHandler(QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); Map<String, Object> getNext(); Map<String, Object> getCurrent(); void close(); MapLazyScrollOutputHandler handle(List<QueryParameters> outputList); boolean hasPrev(); Map<String, Object> getPrev(); boolean moveTo(int row); boolean moveRelative(int rows); int position(); }### Answer: @Test public void testGetNext() throws Exception { innerTestGetPrepare(); innerTestGetNext(new MapLazyScrollOutputHandler().handle(new QueryParametersLazyList(stmt, typeHandler, false))); }
### Question: MapLazyScrollOutputHandler extends AbstractScrollUpdateLazyOutputHandler implements LazyScrollOutputHandler<MapLazyScrollOutputHandler, Map<String, Object>> { public Map<String, Object> getCurrent() { Map<String, Object> result = null; QueryParameters params = innerGetCurrent(); result = processor.toMap(params); return result; } MapLazyScrollOutputHandler(); MapLazyScrollOutputHandler(QueryOutputProcessor processor); private MapLazyScrollOutputHandler(QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); Map<String, Object> getNext(); Map<String, Object> getCurrent(); void close(); MapLazyScrollOutputHandler handle(List<QueryParameters> outputList); boolean hasPrev(); Map<String, Object> getPrev(); boolean moveTo(int row); boolean moveRelative(int rows); int position(); }### Answer: @Test public void testGetCurrent() throws Exception { innerTestGetPrepare(); innerTestGetCurrent(new MapLazyScrollOutputHandler().handle(new QueryParametersLazyList(stmt, typeHandler, false))); }
### Question: MapLazyScrollOutputHandler extends AbstractScrollUpdateLazyOutputHandler implements LazyScrollOutputHandler<MapLazyScrollOutputHandler, Map<String, Object>> { public void close() { innerClose(); } MapLazyScrollOutputHandler(); MapLazyScrollOutputHandler(QueryOutputProcessor processor); private MapLazyScrollOutputHandler(QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); Map<String, Object> getNext(); Map<String, Object> getCurrent(); void close(); MapLazyScrollOutputHandler handle(List<QueryParameters> outputList); boolean hasPrev(); Map<String, Object> getPrev(); boolean moveTo(int row); boolean moveRelative(int rows); int position(); }### Answer: @Test public void testClose() throws Exception { innerTestClosePrepare(); innerTestClose(new MapLazyScrollOutputHandler().handle(new QueryParametersLazyList(stmt, typeHandler, false))); }
### Question: MapLazyScrollOutputHandler extends AbstractScrollUpdateLazyOutputHandler implements LazyScrollOutputHandler<MapLazyScrollOutputHandler, Map<String, Object>> { public MapLazyScrollOutputHandler handle(List<QueryParameters> outputList) throws MjdbcException { if (outputList instanceof QueryParametersLazyList) { return new MapLazyScrollOutputHandler(this.processor, (QueryParametersLazyList) outputList); } else { throw new MjdbcRuntimeException("LazyOutputHandler can be used only together with LazyStatementHandler. \n" + "Please assign LazyStatementHandler to this QueryRunner or create new QueryRunnerService via MjdbcFactory"); } } MapLazyScrollOutputHandler(); MapLazyScrollOutputHandler(QueryOutputProcessor processor); private MapLazyScrollOutputHandler(QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); Map<String, Object> getNext(); Map<String, Object> getCurrent(); void close(); MapLazyScrollOutputHandler handle(List<QueryParameters> outputList); boolean hasPrev(); Map<String, Object> getPrev(); boolean moveTo(int row); boolean moveRelative(int rows); int position(); }### Answer: @Test public void testHandle() throws Exception { innerTestHandle(new MapLazyScrollOutputHandler().handle(new QueryParametersLazyList(stmt, typeHandler, false)) instanceof MapLazyScrollOutputHandler); } @Test public void testEmpty() throws Exception { innerTestEmpty(new MapLazyScrollOutputHandler().handle(new QueryParametersLazyList(stmt, typeHandler, false))); }
### Question: MapLazyScrollOutputHandler extends AbstractScrollUpdateLazyOutputHandler implements LazyScrollOutputHandler<MapLazyScrollOutputHandler, Map<String, Object>> { public boolean hasPrev() { return innerHasPrev(); } MapLazyScrollOutputHandler(); MapLazyScrollOutputHandler(QueryOutputProcessor processor); private MapLazyScrollOutputHandler(QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); Map<String, Object> getNext(); Map<String, Object> getCurrent(); void close(); MapLazyScrollOutputHandler handle(List<QueryParameters> outputList); boolean hasPrev(); Map<String, Object> getPrev(); boolean moveTo(int row); boolean moveRelative(int rows); int position(); }### Answer: @Test public void testHasPrev() throws Exception { innerTestHasPrepare(); innerTestHasPrev(new MapLazyScrollOutputHandler().handle(new QueryParametersLazyList(stmt, typeHandler, false))); }
### Question: MapLazyScrollOutputHandler extends AbstractScrollUpdateLazyOutputHandler implements LazyScrollOutputHandler<MapLazyScrollOutputHandler, Map<String, Object>> { public Map<String, Object> getPrev() { Map<String, Object> result = null; QueryParameters params = innerGetPrev(); result = processor.toMap(params); return result; } MapLazyScrollOutputHandler(); MapLazyScrollOutputHandler(QueryOutputProcessor processor); private MapLazyScrollOutputHandler(QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); Map<String, Object> getNext(); Map<String, Object> getCurrent(); void close(); MapLazyScrollOutputHandler handle(List<QueryParameters> outputList); boolean hasPrev(); Map<String, Object> getPrev(); boolean moveTo(int row); boolean moveRelative(int rows); int position(); }### Answer: @Test public void testGetPrev() throws Exception { innerTestGetPrepare(); innerTestGetPrev(new MapLazyScrollOutputHandler().handle(new QueryParametersLazyList(stmt, typeHandler, false))); }
### Question: MapLazyScrollOutputHandler extends AbstractScrollUpdateLazyOutputHandler implements LazyScrollOutputHandler<MapLazyScrollOutputHandler, Map<String, Object>> { public boolean moveTo(int row) { return innerMoveTo(row); } MapLazyScrollOutputHandler(); MapLazyScrollOutputHandler(QueryOutputProcessor processor); private MapLazyScrollOutputHandler(QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); Map<String, Object> getNext(); Map<String, Object> getCurrent(); void close(); MapLazyScrollOutputHandler handle(List<QueryParameters> outputList); boolean hasPrev(); Map<String, Object> getPrev(); boolean moveTo(int row); boolean moveRelative(int rows); int position(); }### Answer: @Test public void testMoveTo() throws Exception { innerTestGetPrepare(); innerTestMoveTo(new MapLazyScrollOutputHandler().handle(new QueryParametersLazyList(stmt, typeHandler, false))); }
### Question: MapLazyScrollOutputHandler extends AbstractScrollUpdateLazyOutputHandler implements LazyScrollOutputHandler<MapLazyScrollOutputHandler, Map<String, Object>> { public boolean moveRelative(int rows) { return innerMoveRelative(rows); } MapLazyScrollOutputHandler(); MapLazyScrollOutputHandler(QueryOutputProcessor processor); private MapLazyScrollOutputHandler(QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); Map<String, Object> getNext(); Map<String, Object> getCurrent(); void close(); MapLazyScrollOutputHandler handle(List<QueryParameters> outputList); boolean hasPrev(); Map<String, Object> getPrev(); boolean moveTo(int row); boolean moveRelative(int rows); int position(); }### Answer: @Test public void testMoveRelative() throws Exception { innerTestGetPrepare(); innerTestMoveRelative(new MapLazyScrollOutputHandler().handle(new QueryParametersLazyList(stmt, typeHandler, false))); }
### Question: MapLazyScrollOutputHandler extends AbstractScrollUpdateLazyOutputHandler implements LazyScrollOutputHandler<MapLazyScrollOutputHandler, Map<String, Object>> { public int position() { return innerPosition(); } MapLazyScrollOutputHandler(); MapLazyScrollOutputHandler(QueryOutputProcessor processor); private MapLazyScrollOutputHandler(QueryOutputProcessor processor, QueryParametersLazyList paramsList); boolean hasNext(); Map<String, Object> getNext(); Map<String, Object> getCurrent(); void close(); MapLazyScrollOutputHandler handle(List<QueryParameters> outputList); boolean hasPrev(); Map<String, Object> getPrev(); boolean moveTo(int row); boolean moveRelative(int rows); int position(); }### Answer: @Test public void testPosition() throws Exception { innerTestGetPrepare(); innerTestPosition(new MapLazyScrollOutputHandler().handle(new QueryParametersLazyList(stmt, typeHandler, false))); }
### Question: ScalarOutputHandler extends AbstractOutputHandler<T> { public T handle(List<QueryParameters> output) { T result = null; String parameterName = null; Object parameterValue = null; if (output.size() > 1) { if (this.columnName == null) { parameterName = output.get(1).getNameByPosition(columnIndex); parameterValue = output.get(1).getValue(parameterName); result = (T) parameterValue; } else { parameterValue = output.get(1).getValue(this.columnName); result = (T) parameterValue; } } return result; } ScalarOutputHandler(); ScalarOutputHandler(int columnIndex); ScalarOutputHandler(String columnName); private ScalarOutputHandler(int columnIndex, String columnName); T handle(List<QueryParameters> output); }### Answer: @Test public void testHandle() throws Exception { ScalarOutputHandler<String> handler = new ScalarOutputHandler<String>(); String result = handler.handle(paramsList); Assert.assertEquals("jack", result); } @Test public void testEmpty() { ScalarOutputHandler<String> handler = new ScalarOutputHandler<String>(); String result = handler.handle(emptyList); Assert.assertEquals(null, result); }
### Question: MapOutputHandler extends AbstractOutputHandler<Map<String, Object>> { public Map<String, Object> handle(List<QueryParameters> outputList) throws MjdbcException { return this.outputProcessor.toMap(outputList); } MapOutputHandler(); MapOutputHandler(QueryOutputProcessor processor); Map<String, Object> handle(List<QueryParameters> outputList); }### Answer: @Test public void testHandle() throws Exception { MapOutputHandler handler = new MapOutputHandler(); Map<String, Object> result = handler.handle(paramsList); org.junit.Assert.assertArrayEquals(new Object[]{"jack", "sheriff", 36}, new Object[]{result.get("name"), result.get("occupation"), result.get("age")}); } @Test public void testEmpty() throws MjdbcException { MapOutputHandler handler = new MapOutputHandler(); Map<String, Object> result = handler.handle(emptyList); Assert.assertEquals(0, result.size()); }
### Question: BeanMapOutputHandler extends AbstractKeyedOutputHandler<K, V> { @Override protected V createRow(QueryParameters params) throws MjdbcException { return this.outputProcessor.toBean(params, type); } BeanMapOutputHandler(Class<V> type); BeanMapOutputHandler(Class<V> type, QueryOutputProcessor processor); BeanMapOutputHandler(Class<V> type, int columnIndex); BeanMapOutputHandler(Class<V> type, String columnName); private BeanMapOutputHandler(Class<V> type, QueryOutputProcessor processor, int columnIndex, String columnName); }### Answer: @Test public void testCreateRow() throws Exception { BeanMapOutputHandler<String, Character> handler = new BeanMapOutputHandler<String, Character>(Character.class); Character result = handler.createRow(params); Assert.assertEquals(params.getValue("name"), result.getName()); Assert.assertEquals(params.getValue("occupation"), result.getOccupation()); Assert.assertEquals(params.getValue("age"), result.getAge()); }
### Question: ColumnListOutputHandler extends AbstractOutputListHandler<T> { public List<T> handle(List<QueryParameters> outputList) throws MjdbcException { List<T> result = new ArrayList<T>(); String parameterName = null; Object parameterValue = null; for (int i = 1; i < outputList.size(); i++) { if (this.columnName == null) { parameterName = outputList.get(i).getNameByPosition(this.columnIndex); parameterValue = outputList.get(i).getValue(parameterName); result.add((T) parameterValue); } else { parameterValue = outputList.get(i).getValue(this.columnName); result.add((T) parameterValue); } } return result; } ColumnListOutputHandler(); ColumnListOutputHandler(int columnIndex); ColumnListOutputHandler(String columnName); private ColumnListOutputHandler(int columnIndex, String columnName); List<T> handle(List<QueryParameters> outputList); }### Answer: @Test public void testHandle() throws Exception { List<String> result = new ColumnListOutputHandler<String>().handle(paramsList); Assert.assertArrayEquals(new Object[]{"jack", "henry", "alison"}, result.toArray()); } @Test public void testEmpty() throws MjdbcException { List<String> result = new ColumnListOutputHandler<String>().handle(emptyList); Assert.assertEquals(0, result.size()); }
### Question: MapListOutputHandler extends AbstractOutputListHandler<Map<String, Object>> { public List<Map<String, Object>> handle(List<QueryParameters> outputList) throws MjdbcException { return this.outputProcessor.toMapList(outputList); } MapListOutputHandler(); MapListOutputHandler(QueryOutputProcessor processor); List<Map<String, Object>> handle(List<QueryParameters> outputList); }### Answer: @Test public void testHandle() throws Exception { MapListOutputHandler handler = new MapListOutputHandler(); List<Map<String, Object>> result = handler.handle(paramsList); org.junit.Assert.assertArrayEquals(new Object[]{"jack", "sheriff", 36}, new Object[]{result.get(0).get("name"), result.get(0).get("occupation"), result.get(0).get("age")}); org.junit.Assert.assertArrayEquals(new Object[]{"henry", "mechanic", 36}, new Object[]{result.get(1).get("name"), result.get(1).get("occupation"), result.get(1).get("age")}); org.junit.Assert.assertArrayEquals(new Object[]{"alison", "agent", 30}, new Object[]{result.get(2).get("name"), result.get(2).get("occupation"), result.get(2).get("age")}); } @Test public void testEmpty() throws MjdbcException { MapListOutputHandler handler = new MapListOutputHandler(); List<Map<String, Object>> result = handler.handle(emptyList); Assert.assertEquals(0, result.size()); }
### Question: StoredProcedure implements Comparable<StoredProcedure> { @Override public boolean equals(Object obj) { boolean result = false; StoredProcedure procedure = null; if (obj instanceof StoredProcedure) { procedure = (StoredProcedure) obj; AssertUtils.assertNotNull(procedure.getProcedureName(), "Procedure name cannot be null"); if (equalsNull(getCatalog(), procedure.getCatalog()) == true) { if (equalsNull(getSchema(), procedure.getSchema()) == true) { if (equalsNull(getProcedureName(), procedure.getProcedureName()) == true) { result = true; } } } } return result; } StoredProcedure(String catalog, String schema, String procedureName); String getCatalog(); String getSchema(); String getProcedureName(); @Override boolean equals(Object obj); @Override int hashCode(); int compareTo(StoredProcedure o); @Override String toString(); }### Answer: @Test public void testEquals() throws Exception { String catalog = "catalog"; String schema = "schema"; String name = "executeproc"; StoredProcedure proc = new StoredProcedure(catalog, schema, name); StoredProcedure procCompare = new StoredProcedure(null, null, name); Assert.assertEquals(false, proc.equals(procCompare)); Assert.assertEquals(true, procCompare.equals(proc)); Assert.assertEquals(true, proc.equals(proc)); Assert.assertEquals(true, procCompare.equals(procCompare)); Assert.assertEquals(false, proc.equals(new StoredProcedure(null, null, "something_else"))); } @Test(expected = Exception.class) public void testEqualsException() throws Exception { String catalog = "catalog"; String schema = "schema"; String name = "executeproc"; StoredProcedure proc = new StoredProcedure(catalog, schema, name); StoredProcedure procCompare = new StoredProcedure(null, null, null); Assert.assertEquals(true, proc.equals(procCompare)); }
### Question: MjdbcFactory { public static AsyncQueryRunnerService getAsyncQueryRunner(QueryRunner runner, ExecutorService executorService) { return new AsyncQueryRunner(runner, executorService); } static QueryRunnerService getQueryRunner(DataSource ds); static QueryRunnerService getQueryRunner(DataSource ds, Class<? extends TypeHandler> typeHandlerClazz); static QueryRunnerService getQueryRunner(DataSource ds, Class<? extends TypeHandler> typeHandlerClazz, Class<? extends StatementHandler> statementHandlerClazz); static QueryRunnerService getQueryRunner(Connection conn); static QueryRunnerService getQueryRunner(Connection conn, Class<? extends TypeHandler> typeHandlerClazz); static QueryRunnerService getQueryRunner(Connection conn, Class<? extends TypeHandler> typeHandlerClazz, Class<? extends StatementHandler> statementHandlerClazz); static AsyncQueryRunnerService getAsyncQueryRunner(QueryRunner runner, ExecutorService executorService); static DataSource createDataSource(Properties poolProperties); static DataSource createDataSource(String url); static DataSource createDataSource(String url, String userName, String password); static DataSource createDataSource(String driverClassName, String url, String userName, String password); static DataSource createDataSource(String driverClassName, String url, String userName, String password, int initialSize, int maxActive); }### Answer: @Test public void testGetAsyncQueryRunner() throws Exception { Assert.assertEquals(true, MjdbcFactory.getAsyncQueryRunner(null, null) instanceof AsyncQueryRunner); }
### Question: StoredProcedure implements Comparable<StoredProcedure> { public int compareTo(StoredProcedure o) { int result = -2; result = order(getCatalog(), o.getCatalog()); result = (result == 0 ? order(getSchema(), o.getSchema()) : result); result = (result == 0 ? order(getProcedureName(), o.getProcedureName()) : result); return result; } StoredProcedure(String catalog, String schema, String procedureName); String getCatalog(); String getSchema(); String getProcedureName(); @Override boolean equals(Object obj); @Override int hashCode(); int compareTo(StoredProcedure o); @Override String toString(); }### Answer: @Test public void testCompareTo() throws Exception { String catalog = "catalog"; String schema = "schema"; String name = "executeproc"; StoredProcedure proc = new StoredProcedure(catalog, schema, name); StoredProcedure procCompare = new StoredProcedure(null, null, name); Assert.assertEquals(1, proc.compareTo(procCompare)); Assert.assertEquals(-1, procCompare.compareTo(proc)); Assert.assertEquals(0, proc.compareTo(proc)); Assert.assertEquals(0, procCompare.compareTo(procCompare)); Assert.assertEquals(1, proc.compareTo(new StoredProcedure(null, null, "something_else"))); }
### Question: StoredProcedure implements Comparable<StoredProcedure> { @Override public String toString() { return this.getCatalog() + "." + this.getSchema() + "." + this.getProcedureName(); } StoredProcedure(String catalog, String schema, String procedureName); String getCatalog(); String getSchema(); String getProcedureName(); @Override boolean equals(Object obj); @Override int hashCode(); int compareTo(StoredProcedure o); @Override String toString(); }### Answer: @Test public void testToString() throws Exception { String catalog = "catalog"; String schema = "schema"; String name = "executeproc"; String expectedString = catalog + "." + schema + "." + name; StoredProcedure proc = new StoredProcedure(catalog, schema, name); Assert.assertEquals(expectedString, proc.toString()); }
### Question: MetadataUtils { public static String processDatabaseProductName(String databaseProductName) { String result = databaseProductName; if (databaseProductName != null && databaseProductName.startsWith("DB2") == true) { result = "DB2"; } else if ("Sybase SQL Server".equals(databaseProductName) == true || "Adaptive Server Enterprise".equals(databaseProductName) == true || "ASE".equals(databaseProductName) == true || "sql server".equals(databaseProductName) == true) { result = "Sybase"; } return result; } static String processDatabaseProductName(String databaseProductName); }### Answer: @Test public void testProcessDatabaseProductName() throws Exception { Assert.assertEquals("Sybase", MetadataUtils.processDatabaseProductName("Sybase SQL Server")); Assert.assertEquals("DB2", MetadataUtils.processDatabaseProductName("DB2 Database Server")); }
### Question: MjdbcFactory { public static DataSource createDataSource(Properties poolProperties) throws SQLException { try { return MjdbcPoolBinder.createDataSource(poolProperties); } catch (NoClassDefFoundError ex) { throw new NoClassDefFoundError(ERROR_COULDNT_FIND_POOL_PROVIDER); } } static QueryRunnerService getQueryRunner(DataSource ds); static QueryRunnerService getQueryRunner(DataSource ds, Class<? extends TypeHandler> typeHandlerClazz); static QueryRunnerService getQueryRunner(DataSource ds, Class<? extends TypeHandler> typeHandlerClazz, Class<? extends StatementHandler> statementHandlerClazz); static QueryRunnerService getQueryRunner(Connection conn); static QueryRunnerService getQueryRunner(Connection conn, Class<? extends TypeHandler> typeHandlerClazz); static QueryRunnerService getQueryRunner(Connection conn, Class<? extends TypeHandler> typeHandlerClazz, Class<? extends StatementHandler> statementHandlerClazz); static AsyncQueryRunnerService getAsyncQueryRunner(QueryRunner runner, ExecutorService executorService); static DataSource createDataSource(Properties poolProperties); static DataSource createDataSource(String url); static DataSource createDataSource(String url, String userName, String password); static DataSource createDataSource(String driverClassName, String url, String userName, String password); static DataSource createDataSource(String driverClassName, String url, String userName, String password, int initialSize, int maxActive); }### Answer: @Test(expected = NoClassDefFoundError.class) public void testCreateDataSourceProp() throws Exception { MjdbcFactory.createDataSource(new Properties()); } @Test(expected = NoClassDefFoundError.class) public void testCreateDataSourceUrl1() throws Exception { MjdbcFactory.createDataSource(""); } @Test(expected = NoClassDefFoundError.class) public void testCreateDataSourceUrl2() throws Exception { MjdbcFactory.createDataSource("", "", ""); } @Test(expected = NoClassDefFoundError.class) public void testCreateDataSourceUrl3() throws Exception { MjdbcFactory.createDataSource("", "", "", ""); } @Test(expected = NoClassDefFoundError.class) public void testCreateDataSourceUrl4() throws Exception { MjdbcFactory.createDataSource("", "", "", "", 0, 0); }
### Question: ConnectionProxy implements java.lang.reflect.InvocationHandler { public static Connection newInstance(Connection conn) { return (Connection) java.lang.reflect.Proxy.newProxyInstance(Connection.class.getClassLoader(), new Class[]{Connection.class}, new ConnectionProxy(conn)); } ConnectionProxy(Connection conn); static Connection newInstance(Connection conn); Object invoke(Object proxy, Method method, Object[] args); }### Answer: @Test public void testNewInstance() throws Exception { Connection result = null; result = ConnectionProxy.newInstance(conn); Assert.assertEquals(true, Proxy.isProxyClass(result.getClass())); Assert.assertEquals(true, result instanceof Connection); }
### Question: ConnectionProxy implements java.lang.reflect.InvocationHandler { public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { Object result = null; String methodName = method.getName(); if ("close".equals(methodName) == true) { } else { try { result = method.invoke(conn, args); } catch (InvocationTargetException e) { throw e.getTargetException(); } catch (Exception e) { throw new RuntimeException("unexpected invocation exception: " + e.getMessage()); } } return result; } ConnectionProxy(Connection conn); static Connection newInstance(Connection conn); Object invoke(Object proxy, Method method, Object[] args); }### Answer: @Test public void testInvoke() throws Exception { Connection result = null; result = ConnectionProxy.newInstance(conn); result.isClosed(); result.close(); verify(conn, times(1)).isClosed(); verify(conn, never()).close(); }
### Question: BaseTransactionHandler implements TransactionHandler { public Connection getConnection() throws SQLException { Connection activeConn = null; if (this.getDataSource() != null) { if (this.conn == null) { this.conn = this.getDataSource().getConnection(); } if (this.conn != null) { initConnection(this.conn); } } if (this.conn == null) { throw new SQLException("Null connection"); } if (this.conn.getAutoCommit() != false) { this.conn.setAutoCommit(false); } if (this.isolationLevel != null) { if (this.conn.getTransactionIsolation() != this.isolationLevel.intValue()) { this.conn.setTransactionIsolation(this.isolationLevel); } } activeConn = this.conn; return ConnectionProxy.newInstance(activeConn); } BaseTransactionHandler(Connection conn); BaseTransactionHandler(DataSource ds); TransactionHandler newInstance(Connection conn); TransactionHandler newInstance(DataSource ds); void setManualMode(boolean manualMode); boolean getManualMode(); void setIsolationLevel(Integer level); Integer getIsolationLevel(); Connection getConnection(); void closeConnection(); void commit(); void rollback(); Savepoint setSavepoint(); Savepoint setSavepoint(String name); void releaseSavepoint(Savepoint savepoint); void rollback(Savepoint savepoint); }### Answer: @Test public void testIsolationLevelDS() throws SQLException { QueryRunnerService queryRunner = null; queryRunner = MjdbcFactory.getQueryRunner(ds); testIsolationLevel(queryRunner); verify(ds, times(4)).getConnection(); verify(conn, never()).setTransactionIsolation(any(int.class)); queryRunner.setTransactionIsolationLevel(1); testIsolationLevel(queryRunner); verify(ds, times(8)).getConnection(); verify(conn, times(4)).setTransactionIsolation(any(int.class)); }
### Question: MidaoUtils { public static void close(Connection conn) throws SQLException { if (conn != null) { conn.close(); } } static void close(Connection conn); static void close(ResultSet rs); static void close(Statement stmt); static void closeQuietly(Connection conn); static void closeQuietly(Connection conn, Statement stmt, ResultSet rs); static void closeQuietly(ResultSet rs); static void closeQuietly(Statement stmt); static void commitAndClose(Connection conn); static void commitAndCloseQuietly(Connection conn); static boolean loadDriver(String driverClassName); static boolean loadDriver(ClassLoader classLoader, String driverClassName); static void printStackTrace(SQLException e); static void printStackTrace(SQLException e, PrintWriter pw); static void printWarnings(Connection conn); static void printWarnings(Connection conn, PrintWriter pw); static void rollback(Connection conn); static void rollbackAndClose(Connection conn); static void rollbackAndCloseQuietly(Connection conn); }### Answer: @Test public void closeNullConnection() throws Exception { MidaoUtils.close((Connection) null); } @Test public void closeConnection() throws Exception { Connection mockCon = mock(Connection.class); MidaoUtils.close(mockCon); verify(mockCon).close(); } @Test public void closeNullResultSet() throws Exception { MidaoUtils.close((ResultSet) null); } @Test public void closeResultSet() throws Exception { ResultSet mockResultSet = mock(ResultSet.class); MidaoUtils.close(mockResultSet); verify(mockResultSet).close(); } @Test public void closeNullStatement() throws Exception { MidaoUtils.close((Statement) null); } @Test public void closeStatement() throws Exception { Statement mockStatement = mock(Statement.class); MidaoUtils.close(mockStatement); verify(mockStatement).close(); }
### Question: MidaoUtils { public static void closeQuietly(Connection conn) { try { close(conn); } catch (SQLException e) { } } static void close(Connection conn); static void close(ResultSet rs); static void close(Statement stmt); static void closeQuietly(Connection conn); static void closeQuietly(Connection conn, Statement stmt, ResultSet rs); static void closeQuietly(ResultSet rs); static void closeQuietly(Statement stmt); static void commitAndClose(Connection conn); static void commitAndCloseQuietly(Connection conn); static boolean loadDriver(String driverClassName); static boolean loadDriver(ClassLoader classLoader, String driverClassName); static void printStackTrace(SQLException e); static void printStackTrace(SQLException e, PrintWriter pw); static void printWarnings(Connection conn); static void printWarnings(Connection conn, PrintWriter pw); static void rollback(Connection conn); static void rollbackAndClose(Connection conn); static void rollbackAndCloseQuietly(Connection conn); }### Answer: @Test public void closeQuietlyNullConnection() throws Exception { MidaoUtils.closeQuietly((Connection) null); } @Test public void closeQuietlyNullResultSet() throws Exception { MidaoUtils.closeQuietly((ResultSet) null); } @Test public void closeQuietlyNullStatement() throws Exception { MidaoUtils.closeQuietly((Statement) null); }
### Question: MidaoUtils { public static void commitAndClose(Connection conn) throws SQLException { if (conn != null) { try { conn.commit(); } finally { conn.close(); } } } static void close(Connection conn); static void close(ResultSet rs); static void close(Statement stmt); static void closeQuietly(Connection conn); static void closeQuietly(Connection conn, Statement stmt, ResultSet rs); static void closeQuietly(ResultSet rs); static void closeQuietly(Statement stmt); static void commitAndClose(Connection conn); static void commitAndCloseQuietly(Connection conn); static boolean loadDriver(String driverClassName); static boolean loadDriver(ClassLoader classLoader, String driverClassName); static void printStackTrace(SQLException e); static void printStackTrace(SQLException e, PrintWriter pw); static void printWarnings(Connection conn); static void printWarnings(Connection conn, PrintWriter pw); static void rollback(Connection conn); static void rollbackAndClose(Connection conn); static void rollbackAndCloseQuietly(Connection conn); }### Answer: @Test public void commitAndClose() throws Exception { Connection mockConnection = mock(Connection.class); MidaoUtils.commitAndClose(mockConnection); verify(mockConnection).commit(); verify(mockConnection).close(); }