ProjectionsContext { public Optional<Integer> findProjectionIndex(final String projectionName) { int result = 1; for (Projection each : projections) { if (projectionName.equalsIgnoreCase(each.getExpression())) { return Optional.of(result); } result++; } return Optional.empty(); }  boolean isUnqualifiedShorthandProjection(); Optional<String> findAlias(final String projectionName); Optional<Integer> findProjectionIndex(final String projectionName); List<AggregationProjection> getAggregationProjections(); List<AggregationDistinctProjection> getAggregationDistinctProjections(); List<Projection> getExpandProjections();  }
@Test public void assertFindProjectionIndex() { Projection projection = getColumnProjection(); ProjectionsContext projectionsContext = new ProjectionsContext(0, 0, true, Collections.singleton(projection)); Optional<Integer> actual = projectionsContext.findProjectionIndex(projection.getExpression()); assertTrue(actual.isPresent()); assertThat(actual.get(), is(1)); }
@Test public void assertFindProjectionIndexFailure() { Projection projection = getColumnProjection(); ProjectionsContext projectionsContext = new ProjectionsContext(0, 0, true, Collections.singleton(projection)); Optional<Integer> actual = projectionsContext.findProjectionIndex(""); assertFalse(actual.isPresent()); }