### Question:
FakegenUtils { @SafeVarargs public static <T> void modifyCollection(@NonNull Iterable<T> targets, @NonNull Consumer<T>... suppliers) { int counter = 0; for (T target : targets) { suppliers[counter % suppliers.length].accept(target); counter++; } }  static void inject(@NonNull Object target, @NonNull String fieldName, Object value); @SafeVarargs static void modifyCollection(@NonNull Iterable<T> targets, @NonNull Consumer<T>... suppliers);  }### Answer:
@Test void modifyCollection_one() { TestDataFiller tdf = new TestDataFiller(); List<SimpleType> simpleTypes = tdf.fillInstances(SimpleType.class, 1); FakegenUtils.modifyCollection(simpleTypes, simpleType -> simpleType.setName("Set By Consumer")); assertThat(simpleTypes) .allSatisfy(simpleType -> assertThat(simpleType.getName()).isEqualTo("Set By Consumer")); }
@Test void modifyCollection_many() { TestDataFiller tdf = new TestDataFiller(); List<SimpleType> simpleTypes = tdf.fillInstances(SimpleType.class, 3); FakegenUtils.modifyCollection(simpleTypes, simpleType -> simpleType.setName("Set By Consumer")); assertThat(simpleTypes) .allSatisfy(simpleType -> assertThat(simpleType.getName()).isEqualTo("Set By Consumer")); }
@Test void modifyCollection_different() { TestDataFiller tdf = new TestDataFiller(); List<SimpleType> simpleTypes = tdf.fillInstances(SimpleType.class, 3); FakegenUtils.modifyCollection(simpleTypes, simpleType -> simpleType.setName("Set By Consumer 1"), simpleType -> simpleType.setName("Set By Consumer 2"), simpleType -> simpleType.setName("Set By Consumer 3")); assertThat(simpleTypes.get(0).getName()).isEqualTo("Set By Consumer 1"); assertThat(simpleTypes.get(1).getName()).isEqualTo("Set By Consumer 2"); assertThat(simpleTypes.get(2).getName()).isEqualTo("Set By Consumer 3"); }
@Test void modifyCollection_circle() { TestDataFiller tdf = new TestDataFiller(); List<SimpleType> simpleTypes = tdf.fillInstances(SimpleType.class, 3); FakegenUtils.modifyCollection(simpleTypes, simpleType -> simpleType.setName("Set By Consumer 1"), simpleType -> simpleType.setName("Set By Consumer 2")); assertThat(simpleTypes.get(0).getName()).isEqualTo("Set By Consumer 1"); assertThat(simpleTypes.get(1).getName()).isEqualTo("Set By Consumer 2"); assertThat(simpleTypes.get(2).getName()).isEqualTo("Set By Consumer 1"); }