### Question:
CustomTranslationsListViewHooks { public void addDiscriminatorRestrictionToGrid(final ViewDefinitionState view, final ComponentState state, final String[] args) { addDiscriminatorRestrictionToGrid(view); }  void updateRibbonState(final ViewDefinitionState view); void setLocaleToDefault(final ViewDefinitionState view); void addDiscriminatorRestrictionToGrid(final ViewDefinitionState view, final ComponentState state, final String[] args); void addDiscriminatorRestrictionToGrid(final ViewDefinitionState view);  }### Answer:
@Test public void shouldSetCustomRestrictionsToNullWhenAddDiscriminatorRestrictionToGridListenerIfLocaleIsEmpty() { given(view.getComponentByReference(QcadooViewConstants.L_GRID)).willReturn(customTranslationsGrid); given(view.getComponentByReference(LOCALE)).willReturn(localeField); given(localeField.getFieldValue()).willReturn(null); customTranslationsListViewHooks.addDiscriminatorRestrictionToGrid(view, null, null); verify(customTranslationsGrid).setCustomRestriction(null); }
@Test public void shouldSetCustomRestrictionsWhenAddDiscriminatorRestrictionToGridListenerIfLocaleIsntEmpty() { String locale = "pl"; given(view.getComponentByReference(QcadooViewConstants.L_GRID)).willReturn(customTranslationsGrid); given(view.getComponentByReference(LOCALE)).willReturn(localeField); given(localeField.getFieldValue()).willReturn(locale); customTranslationsListViewHooks.addDiscriminatorRestrictionToGrid(view); verify(customTranslationsGrid).setCustomRestriction(Mockito.any(CustomRestriction.class)); }
@Test public void shouldSetCustomRestrictionsToNullWhenAddDiscriminatorRestrictionToGridIfLocaleIsEmpty() { given(view.getComponentByReference(QcadooViewConstants.L_GRID)).willReturn(customTranslationsGrid); given(view.getComponentByReference(LOCALE)).willReturn(localeField); given(localeField.getFieldValue()).willReturn(null); customTranslationsListViewHooks.addDiscriminatorRestrictionToGrid(view); verify(customTranslationsGrid).setCustomRestriction(null); }
@Test public void shouldSetCustomRestrictionsWhenAddDiscriminatorRestrictionToGridIfLocaleIsntEmpty() { String locale = "pl"; given(view.getComponentByReference(QcadooViewConstants.L_GRID)).willReturn(customTranslationsGrid); given(view.getComponentByReference(LOCALE)).willReturn(localeField); given(localeField.getFieldValue()).willReturn(locale); ArgumentCaptor<CustomRestriction> customRestrictionCaptor = ArgumentCaptor.forClass(CustomRestriction.class); customTranslationsListViewHooks.addDiscriminatorRestrictionToGrid(view); verify(customTranslationsGrid).setCustomRestriction(Mockito.any(CustomRestriction.class)); verify(customTranslationsGrid).setCustomRestriction(customRestrictionCaptor.capture()); customRestriction = customRestrictionCaptor.getValue(); customRestriction.addRestriction(searchCriteriaBuilder); verify(searchCriteriaBuilder).add(Mockito.any(SearchCriterion.class)); }