### Question:
WorkflowCollectionEditor extends PropertyEditorSupport { @Override public void setAsText(String text) throws IllegalArgumentException { if (StringUtils.hasText(text)) { ConceptService cs = Context.getConceptService(); ProgramWorkflowService pws = Context.getProgramWorkflowService(); try { int ind = text.indexOf(":"); String progIdStr = text.substring(0, ind); text = text.substring(ind + 1); if (program == null) { program = pws.getProgram(Integer.valueOf(progIdStr)); } } catch (Exception ex) {} String[] conceptIds = text.split(" "); Set<ProgramWorkflow> oldSet = program == null ? new HashSet<>() : program.getAllWorkflows(); Set<Integer> newConceptIds = new HashSet<>(); for (String id : conceptIds) { if (id.trim().length() == 0) { continue; } log.debug("trying " + id); newConceptIds.add(Integer.valueOf(id.trim())); } Set<Integer> alreadyDone = new HashSet<>(); for (ProgramWorkflow pw : oldSet) { if (!newConceptIds.contains(pw.getConcept().getConceptId())) { pw.setRetired(true); } else if (newConceptIds.contains(pw.getConcept().getConceptId()) && pw.getRetired()) { pw.setRetired(false); } alreadyDone.add(pw.getConcept().getConceptId()); } newConceptIds.removeAll(alreadyDone); for (Integer conceptId : newConceptIds) { ProgramWorkflow pw = new ProgramWorkflow(); pw.setProgram(program); pw.setConcept(cs.getConcept(conceptId)); oldSet.add(pw); } setValue(oldSet); } else { setValue(null); } } WorkflowCollectionEditor();  WorkflowCollectionEditor(Program program); @Override void setAsText(String text); @Override @SuppressWarnings("unchecked") String getAsText();  }### Answer:
@Test public void setAsText_shouldUpdateWorkflowsInProgram() { Program program = Context.getProgramWorkflowService().getProgram(1); WorkflowCollectionEditor editor = new WorkflowCollectionEditor(); Assert.assertEquals(2, program.getWorkflows().size()); editor.setAsText("1:3"); Assert.assertEquals(1, program.getWorkflows().size()); Assert.assertEquals(3, program.getWorkflows().iterator().next().getConcept().getConceptId().intValue()); Assert.assertEquals(3, program.getAllWorkflows().size()); }