AbstractWorkflowStep implements Serializable { public void save() { plan.getPlanProperties().setState(requiredPlanState); plan.getPlanProperties().touch(); saveWithoutModifyingPlanState(); } AbstractWorkflowStep(); void init(Plan p); boolean proceed(List<ValidationError> errors); void save(); void saveWithoutModifyingPlanState(); void discard(); DigitalObject fetchResultFile(Alternative alternative, SampleObject sampleObject); DigitalObject fetchDigitalObject(DigitalObject object); boolean characteriseFits(DigitalObject digitalObject, boolean updateFormatInfo); boolean characteriseFits(DigitalObject digitalObject); void setPlan(Plan p); Plan getPlan();  }
@Test public void save_planStateSetCorrectly() { AbstractWorkflowStep step = mock(AbstractWorkflowStep.class); Mockito.doCallRealMethod().when(step).save(); step.requiredPlanState = PlanState.CREATED; Plan p = new Plan(); p.getPlanProperties().setState(PlanState.PLAN_VALIDATED); step.plan = p; PrepareChangesForPersist prepareChangesForPersist = mock(PrepareChangesForPersist.class); step.prepareChangesForPersist = prepareChangesForPersist; EntityManager em = mock(EntityManager.class); when(em.merge(p)).thenReturn(p); step.em = em; step.save(); Assert.assertTrue(p.getPlanProperties().getState() == PlanState.CREATED); }