@Override public void setUpTest() { organisationUnit = createOrganisationUnit('A'); organisationUnitService.addOrganisationUnit(organisationUnit); Program program = createProgram('A', new HashSet<ProgramStage>(), organisationUnit); programService.addProgram(program); stageA = new ProgramStage("A", program); programStageService.saveProgramStage(stageA); DataElement dataElementA = createDataElement('A'); DataElement dataElementB = createDataElement('B'); dataElementService.addDataElement(dataElementA); dataElementService.addDataElement(dataElementB); ProgramStageDataElement stageDeA = new ProgramStageDataElement(stageA, dataElementA, false, 1); ProgramStageDataElement stageDeB = new ProgramStageDataElement(stageA, dataElementB, false, 2); programStageDataElementService.addProgramStageDataElement(stageDeA); programStageDataElementService.addProgramStageDataElement(stageDeB); List<ProgramStageDataElement> psDataElements = new ArrayList<>(); psDataElements.add(stageDeA); psDataElements.add(stageDeB); stageB = new ProgramStage("B", program); programStageService.saveProgramStage(stageB); Set<ProgramStage> programStages = new HashSet<>(); programStages.add(stageA); programStages.add(stageB); program.setProgramStages(programStages); programService.updateProgram(program); sectionA = new ProgramStageSection(); sectionA.setName("A"); sectionA.setProgramStageDataElements(psDataElements); sectionA.setSortOrder(1); sectionB = new ProgramStageSection(); sectionB.setName("B"); sectionB.setSortOrder(2); Set<ProgramStageSection> sections = new HashSet<>(); sections.add(sectionA); sections.add(sectionB); stageA.setProgramStageSections(sections); }
@Test public void testUpdateProgramStageSection() { int idA = programStageSectionService.saveProgramStageSection(sectionA); assertNotNull(programStageSectionService.getProgramStageSection(idA)); sectionA.setName("B"); programStageSectionService.updateProgramStageSection(sectionA); assertEquals("B", programStageSectionService.getProgramStageSection(idA).getName()); }