### Question:
QueryCostBasedQueryHook extends NoOpDriverQueryHook { @Override public void postEstimate(AbstractQueryContext ctx) throws LensException { if (!allowedCosts.contains((T) ctx.getDriverQueryCost(getDriver()))) { throw new LensException("Driver " + getDriver() + " doesn't accept query " + "with cost " + ctx.getSelectedDriverQueryCost() + ". Allowed ranges: " + allowedCosts); } }  RangeSet<T> parseAllowedRangeSet(String rangeStr); RangeSet<T> parseDisallowedRangeSet(String rangeStr); RangeSet<T> parseRangeSet(String rangeStr); Range<T> parseRange(String rangeStr); @Override void setDriver(LensDriver driver); @Override void postEstimate(AbstractQueryContext ctx); static final String ALLOWED_RANGE_SETS; static final String DISALLOWED_RANGE_SETS; }### Answer:
@Test(dataProvider = "provideData") public void testHook(Double cost, boolean success) throws Exception { when(ctx.getDriverQueryCost(driver)).thenReturn(new FactPartitionBasedQueryCost(cost)); try { hook.postEstimate(ctx); assertTrue(success); } catch (Exception e) { assertFalse(success); } }