UnresolvedPlanHelper { public UnresolvedPlan addSelectAll(UnresolvedPlan plan) { if ((plan instanceof Project) && !((Project) plan).isExcluded()) { return plan; } else { return new Project(ImmutableList.of(AllFields.of())).attach(plan); } }  UnresolvedPlan addSelectAll(UnresolvedPlan plan);  }
@Test public void addProjectForRenameOperator() { Rename rename = Mockito.mock(Rename.class); UnresolvedPlan plan = UnresolvedPlanHelper.addSelectAll(rename); assertTrue(plan instanceof Project); }
@Test public void addProjectForProjectExcludeOperator() { Project project = Mockito.mock(Project.class); when(project.isExcluded()).thenReturn(true); UnresolvedPlan plan = UnresolvedPlanHelper.addSelectAll(project); assertTrue(plan instanceof Project); assertThat(((Project) plan).getProjectList(), Matchers.contains(AllFields.of())); }
@Test public void dontAddProjectForProjectOperator() { Project project = Mockito.mock(Project.class); UnresolvedExpression expression = Mockito.mock(UnresolvedExpression.class); when(project.isExcluded()).thenReturn(false); when(project.getProjectList()).thenReturn(Arrays.asList(expression)); UnresolvedPlan plan = UnresolvedPlanHelper.addSelectAll(project); assertTrue(plan instanceof Project); assertThat(((Project) plan).getProjectList(), Matchers.contains(expression)); }