### Question:
HasItemsAvailableValuesAspectDefinition extends AvailableValuesAspectDefinition<HasItems<?>> { @SuppressWarnings("unchecked") private static void setDataProvider(HasItems<?> component, ListDataProvider<Object> listDataProvider) { if (component instanceof HasDataProvider) { ((HasDataProvider<Object>)component).setDataProvider(listDataProvider); } else if (component instanceof ComboBox) { ((ComboBox<Object>)component).setDataProvider(listDataProvider); } else if (component instanceof HasFilterableDataProvider) { ((HasFilterableDataProvider<Object, SerializablePredicate<Object>>)component) .setDataProvider(listDataProvider); } } HasItemsAvailableValuesAspectDefinition(AvailableValuesType availableValuesType);   }### Answer:
@Test public void testSetDataProvider_HasDataProvider() { HasItemsAvailableValuesAspectDefinition hasItemsAvailableValuesAspectDefinition = new HasItemsAvailableValuesAspectDefinition( AvailableValuesType.DYNAMIC); @SuppressWarnings("unchecked") ListDataProvider<Object> dataProvider = mock(ListDataProvider.class); @SuppressWarnings("unchecked") HasDataProvider<Object> component = mock(HasDataProvider.class, withSettings().extraInterfaces(Component.class)); hasItemsAvailableValuesAspectDefinition.setDataProvider(new LabelComponentWrapper(component), dataProvider); verify(component).setDataProvider(dataProvider); }
@Test public void testSetDataProvider_HasFilterableDataProvider() { HasItemsAvailableValuesAspectDefinition hasItemsAvailableValuesAspectDefinition = new HasItemsAvailableValuesAspectDefinition( AvailableValuesType.DYNAMIC); @SuppressWarnings("unchecked") ListDataProvider<Object> dataProvider = mock(ListDataProvider.class); @SuppressWarnings("unchecked") HasFilterableDataProvider<Object, SerializablePredicate<Object>> component = mock(HasFilterableDataProvider.class, withSettings() .extraInterfaces(Component.class)); hasItemsAvailableValuesAspectDefinition.setDataProvider(new LabelComponentWrapper(component), dataProvider); verify(component).setDataProvider(dataProvider); }
@Test public void testSetDataProvider_Other() { HasItemsAvailableValuesAspectDefinition hasItemsAvailableValuesAspectDefinition = new HasItemsAvailableValuesAspectDefinition( AvailableValuesType.DYNAMIC); @SuppressWarnings("unchecked") ListDataProvider<Object> dataProvider = mock(ListDataProvider.class); Component component = mock(HasItems.class, withSettings().extraInterfaces(Component.class)); hasItemsAvailableValuesAspectDefinition.setDataProvider(new LabelComponentWrapper(component), dataProvider); verifyNoMoreInteractions(component); }