### Question:
GridComponentFilterUtils { public static String addAliases(final SearchCriteriaBuilder criteria, final String field, final JoinType joinType) { if (field == null) { return null; } String[] path = field.split("\\."); if (path.length == 1) { return field; } String lastAlias = ""; for (int i = 0; i < path.length - 1; i++) { criteria.createAlias(lastAlias + path[i], path[i] + "_a", joinType); lastAlias = path[i] + "_a."; } return lastAlias + path[path.length - 1]; } private  GridComponentFilterUtils(); static void addFilters(final Map<String, String> filters, final Map<String, GridComponentColumn> columns,
            final DataDefinition dataDefinition, final SearchCriteriaBuilder criteria); static void addMultiSearchFilter(GridComponentMultiSearchFilter multiSearchFilter,
            Map<String, GridComponentColumn> columns, DataDefinition dataDefinition, SearchCriteriaBuilder criteria); static String addAliases(final SearchCriteriaBuilder criteria, final String field, final JoinType joinType); static String getFieldNameByColumnName(final Map<String, GridComponentColumn> columns, final String columnName);  }### Answer:
@Test public final void shouldNotCreateAliasForSimplePath() { String field = "fieldName"; GridComponentFilterUtils.addAliases(criteria, field, JoinType.LEFT); verify(criteria, never()).createAlias(Mockito.anyString(), Mockito.anyString(), Mockito.any(JoinType.class)); }
@Test public final void shouldCreateAliasForOneLevelDeepPath() { String field = "firstBelongsTo.fieldName"; GridComponentFilterUtils.addAliases(criteria, field, JoinType.LEFT); verify(criteria).createAlias("firstBelongsTo", "firstBelongsTo_a", JoinType.LEFT); }
@Test public final void shouldCreateAliasForTwoLevelDeepPath() { String field = "firstBelongsTo.secondBelongsTo.fieldName"; GridComponentFilterUtils.addAliases(criteria, field, JoinType.LEFT); verify(criteria).createAlias("firstBelongsTo", "firstBelongsTo_a", JoinType.LEFT); verify(criteria).createAlias("firstBelongsTo_a.secondBelongsTo", "secondBelongsTo_a", JoinType.LEFT); }
@Test public final void shouldCreateAliasForThreeLevelDeepPath() { String field = "firstBelongsTo.secondBelongsTo.thirdBelongsTo.fieldName"; GridComponentFilterUtils.addAliases(criteria, field, JoinType.LEFT); verify(criteria).createAlias("firstBelongsTo", "firstBelongsTo_a", JoinType.LEFT); verify(criteria).createAlias("firstBelongsTo_a.secondBelongsTo", "secondBelongsTo_a", JoinType.LEFT); verify(criteria).createAlias("secondBelongsTo_a.thirdBelongsTo", "thirdBelongsTo_a", JoinType.LEFT); }
@Test public final void shouldCreateAliasForFourLevelDeepPath() { String field = "firstBelongsTo.secondBelongsTo.thirdBelongsTo.fourthBelongsTo.fieldName"; GridComponentFilterUtils.addAliases(criteria, field, JoinType.LEFT); verify(criteria).createAlias("firstBelongsTo", "firstBelongsTo_a", JoinType.LEFT); verify(criteria).createAlias("firstBelongsTo_a.secondBelongsTo", "secondBelongsTo_a", JoinType.LEFT); verify(criteria).createAlias("secondBelongsTo_a.thirdBelongsTo", "thirdBelongsTo_a", JoinType.LEFT); verify(criteria).createAlias("thirdBelongsTo_a.fourthBelongsTo", "fourthBelongsTo_a", JoinType.LEFT); }