@Override protected void cloneInto(WorkflowBean clone, Cloning cloning) { super.cloneInto(clone, cloning); Profile cloneProfile = (Profile) clone; cloneProfile.setProfilePosition(getProfilePosition()); } }
@Test public void testCorrectnessOfInvalidProfilePosition() { Profile profile = new Profile(); Integer profilePosition = Integer.valueOf(-3); profile.setProfilePosition(profilePosition); CorrectnessValidator cv = new CorrectnessValidator(); ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener(); cv.checkCorrectness(profile, false, rcvl); Set<NegativeValueProblem> negativeValueProblems = rcvl.getNegativeValueProblems(); boolean problem = false; for (NegativeValueProblem nlp : negativeValueProblems) { if (nlp.getBean().equals(profile) && nlp.getFieldName().equals("profilePosition") && nlp.getFieldValue().equals(profilePosition)) { problem = true; } } assertTrue(problem); }
@Test public void testCorrectnessOfValidProfilePosition() { Profile profile = new Profile(); Integer profilePosition = Integer.valueOf(3); profile.setProfilePosition(profilePosition); CorrectnessValidator cv = new CorrectnessValidator(); ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener(); cv.checkCorrectness(profile, false, rcvl); Set<NegativeValueProblem> negativeValueProblems = rcvl.getNegativeValueProblems(); assertEquals(Collections.EMPTY_SET, negativeValueProblems); }
@Test public void testCompletenessOfMissingProfilePosition() { // should be OK Profile profile = new Profile(); profile.setProfilePosition(null); CorrectnessValidator cv = new CorrectnessValidator(); ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener(); cv.checkCorrectness(profile, true, rcvl); Set<NullFieldProblem> nullFieldProblems = rcvl.getNullFieldProblems(); boolean problem = false; for (NullFieldProblem nlp : nullFieldProblems) { if (nlp.getBean().equals(profile) && nlp.getFieldName().equals("profilePosition")) { problem = true; } } assertFalse(problem); }