### Question:
FSMDescription { public FSMDescription addTransition(final String name, TransitionCondition condition, final String start, final String end, Action action) throws FSMException { throwIfBuilt(); if (this.transitions.containsKey(name)) throw new FSMException("Could not add transition " + name + ". A transition with the same name already exists."); if (!this.states.containsKey(start)) throw new FSMException("Could not add transition " + name + ". Start state " + start + " does not exist"); if (!this.states.containsKey(end)) throw new FSMException("Could not add transition " + name + ". End state " + end + " does not exist"); if (getState(start).getType() == StateType.END) { throw new FSMException("End state cannot be origin of transitions"); } if (condition == null) condition = TransitionCondition.ALWAYS; if (action == null) action = Action.NOOP; Transition t = new Transition(name, getState(start), getState(end), condition, action); this.transitions.put(name, t); getState(start).addTransition(t); return this; }  FSMDescription addState(final String name, final StateType type); FSMDescription addState(final Enum<?> name, final StateType type); FSMDescription addState(final String name); FSMDescription addState(final Enum<?> name); FSMDescription addTransition(final String name, TransitionCondition condition,
			final String start, final String end, Action action); FSMDescription addTransition(final Enum<?> name, TransitionCondition condition,
			final Enum<?> start, final Enum<?> end, Action action); FSMDescription setTransitionCondition(String transitionName,
			TransitionCondition condition); FSMDescription setTransitionCondition(Enum<?> transitionName,
			TransitionCondition condition); FSMDescription setTransitionAction(String transitionName, Action action); FSMDescription setTransitionAction(Enum<?> transitionName, Action action); synchronized FSMDescription build();  }### Answer:
@Test public void testAddTransition() throws FSMException { final Mockery context = new Mockery(); final FSMDescription desc = new FSMDescription(); final String start = "start"; desc.addState(start, StateType.START); final String end = "end"; desc.addState(end, StateType.END); final TransitionCondition mockCondition = context.mock(TransitionCondition.class); final Action mockAction = context.mock(Action.class); final String t1name = "t1"; desc.addTransition(t1name, mockCondition, start, end, mockAction); final Transition t1 = desc.getTransition(t1name); assertTrue(t1.getName().equals(t1name)); assertSame(desc.getStartState(), t1.getStart()); assertSame(desc.getState(end), t1.getEnd()); assertSame(mockCondition, t1.getCondition()); assertSame(mockAction, t1.getAction()); assertTrue(desc.getStartState().getTransitions().size() == 1); assertTrue(desc.getStartState().getTransitions().contains(t1)); final String t2name = "t2"; desc.addTransition(t2name, null, start, end, null); final Transition t2 = desc.getTransition(t2name); assertSame(TransitionCondition.ALWAYS, t2.getCondition()); assertSame(Action.NOOP, t2.getAction()); desc.addState(States.END, StateType.END).addState(States.OTHER); desc.addTransition(Transitions.TEST, mockCondition, States.OTHER, States.END, null); final Transition t3 = desc.getTransition(Transitions.TEST.name()); assertTrue(t3.getName().equals(Transitions.TEST.name())); assertSame(desc.getState(States.OTHER.name()), t3.getStart()); assertSame(desc.getState(States.END.name()), t3.getEnd()); assertSame(mockCondition, t3.getCondition()); assertSame(Action.NOOP, t3.getAction()); try { desc.addTransition("from_end", null, end, States.OTHER.name(), null); fail(); } catch (FSMException e) { } try { desc.addTransition(t1name, null, start, States.END.name(), null); fail(); } catch (FSMException e) { } }