### Question:
ElementTransitionManager { public Collection<Animator> createTransitions(Transitions transitions, List<Element> fromElements, List<Element> toElements) { if (!transitions.hasValue() || fromElements.isEmpty() || toElements.isEmpty()) return Collections.EMPTY_LIST; Map<String, Element> from = keyBy(fromElements, Element::getElementId); Map<String, Element> to = keyBy(toElements, Element::getElementId); List<Transition> validTransitions = filter(transitions.get(), (t) -> validator.validate(t, from, to)); return animatorCreator.create(validTransitions, from, to); } @RestrictTo(RestrictTo.Scope.TESTS)  ElementTransitionManager(TransitionValidator validator, TransitionAnimatorCreator animatorCreator);  ElementTransitionManager(); Collection<Animator> createTransitions(Transitions transitions, List<Element> fromElements, List<Element> toElements);  }### Answer:
@Test public void createElementTransitions_returnsOnEmptyTransitions() { Collection<? extends Animator> result = uut.createTransitions( new Transitions(), Collections.singletonList(from1), Collections.singletonList(to1) ); assertThat(result).isEmpty(); }
@Test public void createElementTransitions_returnsIfNoElements() { Collection<? extends Animator> result = uut.createTransitions( new Transitions(Collections.singletonList(validTransition)), Collections.EMPTY_LIST, Collections.EMPTY_LIST ); assertThat(result).isEmpty(); }
@Test public void createElementTransitions_returnsIfNoMatchingElements() { Transition invalidTransition = new Transition(); invalidTransition.fromId = new Text("from1Id"); invalidTransition.toId = new Text("nonExistentElement"); Transitions transitions = new Transitions(Collections.singletonList(invalidTransition)); Collection<? extends Animator> result = uut.createTransitions( transitions, Collections.singletonList(from1), Collections.singletonList(to1) ); verify(validator).validate(eq(invalidTransition), any(), any()); assertThat(result).isEmpty(); }
@Test public void createElementTransitions_delegatesAnimatorCreationToCreator() { uut.createTransitions( new Transitions(Arrays.asList(validTransition, invalidTransition)), Collections.singletonList(from1), Collections.singletonList(to1) ); verify(animatorCreator).create(any(List.class), any(Map.class), any(Map.class)); }