### Question:
TransitionValidator { protected boolean validate(Transition transition, Map<String, Element> fromMap, Map<String, Element> toMap) { return transition.fromId.hasValue() && fromMap.containsKey(transition.fromId.get()) && transition.toId.hasValue() && toMap.containsKey(transition.toId.get()) && transition.duration.hasValue(); }    }### Answer:
@Test public void validate_falseIfNullToId() { transition.toId = new NullText(); boolean result = uut.validate( transition, keyBy(Collections.singletonList(from1), Element::getElementId), keyBy(Collections.singletonList(from1), Element::getElementId) ); assertThat(result).isFalse(); }
@Test public void validate_falseIfNullFromId() { transition.fromId = new NullText(); boolean result = uut.validate( transition, keyBy(Collections.singletonList(from1), Element::getElementId), keyBy(Collections.singletonList(from1), Element::getElementId) ); assertThat(result).isFalse(); }
@Test public void validate_falseIfFromElementRequiredByTransitionDontExist() { boolean result = uut.validate( invalidFromElementTransition, keyBy(Collections.singletonList(from1), Element::getElementId), keyBy(Collections.singletonList(to1), Element::getElementId) ); assertThat(result).isFalse(); }
@Test public void validate_falseIfToElementRequiredByTransitionDontExist() { boolean result = uut.validate( invalidToElementTransition, keyBy(Collections.singletonList(from1), Element::getElementId), keyBy(Collections.singletonList(to1), Element::getElementId) ); assertThat(result).isFalse(); }
@Test public void validate_trueIfElementsRequiredByTransitionExist() { boolean result = uut.validate( transition, keyBy(Collections.singletonList(from1), Element::getElementId), keyBy(Collections.singletonList(to1), Element::getElementId) ); assertThat(result).isTrue(); }
@Test public void validate_hasDuration() { transition.duration = new NullNumber(); boolean result = uut.validate( transition, keyBy(Collections.singletonList(from1), Element::getElementId), keyBy(Collections.singletonList(to1), Element::getElementId) ); assertThat(result).isFalse(); }