/** * Validates action. Profiles are reset after the invocation. * @return <code>true</code> if validation is successful, otherwise returns <code>false</code> */ protected boolean validateAction(final String... profiles) { prepareValidator(); vtor.useProfiles(profiles); vtor.validate(this); vtor.resetProfiles(); List<Violation> violations = vtor.getViolations(); return violations == null; }
@Test void testUseProfiles_withNullValue() throws Exception { Vtor vtor = new Vtor(); vtor.useProfiles(null); assertNull(vtor.enabledProfiles); }
@Test void testUseProfiles_withTwoDifferentValues() throws Exception { //given Vtor vtor = new Vtor(); vtor.useProfiles("testProfile1", "testProfile2"); assertEquals(2, vtor.enabledProfiles.size()); ArrayList<String> enabledProfileList = new ArrayList<>(vtor.enabledProfiles); assertTrue(enabledProfileList.contains("testProfile1"), "first element must be equal to first added profile"); assertTrue(enabledProfileList.contains("testProfile2"), "second element must be equal to second added profile"); //when vtor.useProfile(null); //then assertEquals(2, vtor.enabledProfiles.size()); }
@Test void testAsJoyAction() { Vtor vtor = new Vtor(); vtor.useProfiles(Vtor.DEFAULT_PROFILE, "register"); vtor.validate(new Too()); List<Violation> violations = vtor.getViolations(); assertNull(violations); }
@Test void testAnn() { Vtor vtor = new Vtor(); vtor.validate(new Woo()); List<Violation> v = vtor.getViolations(); assertEquals(1, v.size()); vtor.resetViolations(); vtor.useProfiles("p1", "p2"); vtor.validate(new Woo()); v = vtor.getViolations(); assertEquals(2, v.size()); vtor.resetViolations(); vtor.useProfiles("default", "p1", "p2"); vtor.validate(new Woo()); v = vtor.getViolations(); assertEquals(3, v.size()); }
vtor.useProfiles("p1", "p2"); vtor.validate(too); vlist = vtor.getViolations(); vtor.useProfiles("p1", "p2", "p3"); vtor.validate(too); vlist = vtor.getViolations();
/** * Validates action. Profiles are reset after the invocation. * @return <code>true</code> if validation is successful, otherwise returns <code>false</code> */ protected boolean validateAction(final String... profiles) { prepareValidator(); vtor.useProfiles(profiles); vtor.validate(this); vtor.resetProfiles(); List<Violation> violations = vtor.getViolations(); return violations == null; }