Github user ilooner commented on a diff in the pull request:

    https://github.com/apache/drill/pull/1045#discussion_r162511432
  
    --- Diff: exec/java-exec/src/test/java/org/apache/drill/PlanningBase.java 
---
    @@ -84,28 +82,17 @@ protected void testSqlPlan(String sqlCommands) throws 
Exception {
         systemOptions.init();
         @SuppressWarnings("resource")
         final UserSession userSession = 
UserSession.Builder.newBuilder().withOptionManager(systemOptions).build();
    -    final SessionOptionManager sessionOptions = (SessionOptionManager) 
userSession.getOptions();
    +    final SessionOptionManager sessionOptions = userSession.getOptions();
         final QueryOptionManager queryOptions = new 
QueryOptionManager(sessionOptions);
         final ExecutionControls executionControls = new 
ExecutionControls(queryOptions, DrillbitEndpoint.getDefaultInstance());
     
    -    new NonStrictExpectations() {
    -      {
    -        dbContext.getMetrics();
    -        result = new MetricRegistry();
    -        dbContext.getAllocator();
    -        result = allocator;
    -        dbContext.getConfig();
    -        result = config;
    -        dbContext.getOptionManager();
    -        result = systemOptions;
    -        dbContext.getStoreProvider();
    -        result = provider;
    -        dbContext.getClasspathScan();
    -        result = scanResult;
    -        dbContext.getLpPersistence();
    -        result = logicalPlanPersistence;
    -      }
    -    };
    +    when(dbContext.getMetrics()).thenReturn(new MetricRegistry());
    +    when(dbContext.getAllocator()).thenReturn(allocator);
    +    when(dbContext.getConfig()).thenReturn(config);
    +    when(dbContext.getOptionManager()).thenReturn(systemOptions);
    +    when(dbContext.getStoreProvider()).thenReturn(provider);
    +    when(dbContext.getClasspathScan()).thenReturn(scanResult);
    +    when(dbContext.getLpPersistence()).thenReturn(logicalPlanPersistence);
    --- End diff --
    
    I completely agree with this in the long term. Since this code deals with 
the QueryContext I did not dive into creating an interface for the QueryContext 
and a Mock implementation of the interface. I want to limit the scope of this 
PR since it is already quite large, but I have created a follow up ticket to 
handle the mocking of the QueryContext correctly 
https://issues.apache.org/jira/browse/DRILL-6097 . As an additional note, the 
only reason why this code was changed was to take a step towards removing 
JMockit which does not play nice with Eclipse as you have noticed. Removing 
JMockit and replacing it with Mockito was the easiest thing to do at this 
point. Once this change goes in we can revisit the QueryContext in DRILL-6097.


---

Reply via email to