@Test public void testGetFormattedState_actualStateExists() throws Exception { final String expectedState = "state"; StateHolder stateHolderMock = createMock(StateHolder.class); StateFormatter tested = new StateFormatter(stateHolderMock); expect(stateHolderMock.getState()).andReturn(expectedState); replay(stateHolderMock); final String actualState = tested.getFormattedState(); verify(stateHolderMock); assertEquals(expectedState, actualState); }
public String getFormattedState() { String safeState = "State information is missing"; final String actualState = stateHolder.getState(); if (actualState != null) { safeState = actualState; } return safeState; }
StateFormatter { public String getFormattedState() { String safeState = "State information is missing"; final String actualState = stateHolder.getState(); if (actualState != null) { safeState = actualState; } return safeState; } }
StateFormatter { public String getFormattedState() { String safeState = "State information is missing"; final String actualState = stateHolder.getState(); if (actualState != null) { safeState = actualState; } return safeState; } StateFormatter(StateHolder stateHolder); }
StateFormatter { public String getFormattedState() { String safeState = "State information is missing"; final String actualState = stateHolder.getState(); if (actualState != null) { safeState = actualState; } return safeState; } StateFormatter(StateHolder stateHolder); String getFormattedState(); }
StateFormatter { public String getFormattedState() { String safeState = "State information is missing"; final String actualState = stateHolder.getState(); if (actualState != null) { safeState = actualState; } return safeState; } StateFormatter(StateHolder stateHolder); String getFormattedState();  }