### Question:
FSMDescription { public FSMDescription addState(final String name, final StateType type) throws FSMException { throwIfBuilt(); if (name != null && !states.containsKey(name)) { if (type == StateType.START) { if (startState == null) startState = name; else throw new FSMException("Could not add " + name + " as start state. State " + startState + " is already assigned start state"); } states.put(name, new State(name, type)); } else { throw new FSMException("Could not add state " + name + ". State with that name already exists."); } 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 testAddState() throws FSMException { final FSMDescription desc = new FSMDescription(); final String start = "start"; desc.addState(start, StateType.START); final State startState = desc.getStartState(); assertTrue(start.equals(startState.getName())); assertSame(StateType.START, startState.getType()); assertSame(startState, desc.getState(start)); final String end = "end"; desc.addState(end, StateType.END); final State endState = desc.getState(end); assertTrue(end.equals(endState.getName())); assertSame(StateType.END, endState.getType()); final String s1 = "s1"; desc.addState(s1, StateType.ACTIVE); assertTrue(s1.equals(desc.getState(s1).getName())); assertSame(StateType.ACTIVE, desc.getState(s1).getType()); final String s2 = "s2"; desc.addState(s2); assertTrue(s2.equals(desc.getState(s2).getName())); assertSame(StateType.ACTIVE, desc.getState(s2).getType()); desc.addState(States.OTHER); assertTrue(States.OTHER.name().equals(desc.getState(States.OTHER.name()).getName())); assertNull(desc.getState("Start")); desc.addState("StarT"); try { desc.addState(start); fail(); } catch (FSMException e) { } try { desc.addState(States.START, StateType.START); fail(); } catch (FSMException e) { } desc.addState(States.END, StateType.END); try { String nullState = null; desc.addState(nullState); fail(); } catch (FSMException e) { } }