### Question:
FluentElementInjectionSupportValidator { boolean isComponentList(Field field) { if (isList(field)) { boolean componentListClass = componentsManager.isComponentListClass((Class<? extends List<?>>) field.getType()); if (componentListClass) { Class<?> genericType = ReflectionUtils.getFirstGenericType(field); return genericType != null && componentsManager.isComponentClass(genericType); } } return false; } FluentElementInjectionSupportValidator(ComponentsManager componentsManager);   }### Answer:
@Test public void shouldReturnFalseIfFieldIsNotListForComponentList() throws NoSuchFieldException { Field notListField = getField("webElement"); assertThat(validator.isComponentList(notListField)).isFalse(); }
@Test public void shouldReturnFalseIfFieldIsNotComponentList() throws NoSuchFieldException { Field listOfFluentWebElementsField = getField("listOfFluentWebElements"); when(componentsManager.isComponentListClass((Class<? extends List<?>>) listOfFluentWebElementsField.getType())) .thenReturn(false); assertThat(validator.isComponentList(listOfFluentWebElementsField)).isFalse(); }
@Test public void shouldReturnFalseIfFieldGenericTypeIsNotComponent() throws NoSuchFieldException { Field componentFluentWebElementListField = getField("componentFluentWebElementList"); when(componentsManager.isComponentListClass((Class<? extends List<?>>) componentFluentWebElementListField.getType())) .thenReturn(true); when(componentsManager.isComponentClass(FluentWebElement.class)).thenReturn(false); assertThat(validator.isComponentList(componentFluentWebElementListField)).isFalse(); }
@Test public void shouldReturnFalseIfFieldHasNoGenericTypeForComponentList() throws NoSuchFieldException { Field componentListWithoutGenericTypeField = getField("componentListWithoutGenericType"); when(componentsManager.isComponentListClass((Class<? extends List<?>>) componentListWithoutGenericTypeField.getType())) .thenReturn(true); assertThat(validator.isComponentList(componentListWithoutGenericTypeField)).isFalse(); }
@Test public void shouldReturnTrueIfFieldIsComponentList() throws NoSuchFieldException { Field componentListField = getField("componentList"); when(componentsManager.isComponentListClass((Class<? extends List<?>>) componentListField.getType())).thenReturn(true); when(componentsManager.isComponentClass(TestComponent.class)).thenReturn(true); assertThat(validator.isComponentList(componentListField)).isTrue(); }