Package de.huepattl.playground.validation

Examples of de.huepattl.playground.validation.Employee


     *
     * @return Current employee instance.
     */
    public Employee getEmployee() {
        if (employee == null) {
            employee = new Employee();
            employee.setDateOfBirth(Date.valueOf(LocalDate.MIN));
        }
        return employee;
    }
View Full Code Here


     * itself.
     *
     * @return Valid bean.
     */
    public Employee newValidBean() {
        Employee bean = new Employee();
        {
            bean.setId(3);
            bean.setSalary(new BigDecimal("12.34"));
            bean.setActive(true);
            bean.setLastName("abc");
            bean.setFirstName("s");
            bean.setDateOfBirth(Date.valueOf(LocalDate.of(1977, Month.DECEMBER, 9)));
            bean.setStricterValueThanOthers("ABCDE");
            bean.setUsingSeverity("ABCDE");
            bean.setCheckedByCustomAnnotation("ThisStringMustContainTheNumber3");
        }
        return bean;
    }
View Full Code Here

     *
     * @throws Exception BAM!
     */
    @Test
    public void validBean() throws Exception {
        Employee bean = super.newValidBean();
        service.doSomething(bean); // if fails, the unit test throws exception
    }
View Full Code Here

     *
     * @throws Exception BAM!
     */
    @Test
    public void invalidBean() throws Exception {
        Employee bean = new Employee();

        // This is for @BeanConstraints
        bean.setLastName("A");
        bean.setFirstName("B");

        int errors = 0;

        try {
            service.doSomething(bean);
View Full Code Here

    @Test
    public void testManyInvalidBeans() throws Exception {
        int errors = 0;
        Collection<Employee> list = new HashSet<>();
        for (int i = 0; i < 10; i++) {
            list.add(new Employee());
        }

        try {
            service.doSomethingManyBeans(list);
        } catch (EJBException wrapped) {
View Full Code Here

        // Add 10 VALID beans.
        for (int i = 0; i < 10; i++) {
            list.add(super.newValidBean());
        }
        // Add one INVALID bean.
        list.add(new Employee());

        try {
            service.doSomethingManyBeans(list);
        } catch (EJBException wrapped) {
            ConstraintViolationException ve = (ConstraintViolationException) wrapped.getCausedByException();
View Full Code Here

     *
     * @throws Exception BAM!
     */
    @Test
    public void testGroups() throws Exception {
        Employee bean = super.newValidBean();
        service.doSomethingWithGroups(bean);

        int errors = 0;
        bean.setStricterValueThanOthers("AC");
        try {
            service.doSomethingWithGroups(bean);
        } catch (EJBException wrapped) {
            ConstraintViolationException ve = (ConstraintViolationException) wrapped.getCausedByException();
            errors = ve.getConstraintViolations().size();
View Full Code Here

     * @throws Exception BAM!
     */
    @Test
    public void persistValid() throws Exception {
        final int ID = 1;
        Employee employee = newValidBean();
        employee.setId(ID);

        service.persist(employee);
        employee = service.retrieve(ID);

        assertNotNull(employee);
View Full Code Here

     */
    @Test
    public void persistInvalid() throws Exception {
        final int ID = 1;

        Employee employee = newValidBean();
        employee.setId(ID);
        employee.setFirstName("!@#$%ˆ*(");
        employee.setLastName("!");

        try {
            service.persist(employee);
        } catch (ConstraintViolationException | PersistenceException | EJBException ok) {
            // FIXME: Calling logger here causes other exception...
View Full Code Here

    @GET
    @Produces({MediaType.APPLICATION_JSON})
    public //@Valid FIXME: Getting HV000041: Call to TraversableResolver.isReachable() threw an exception' even when removing JPA annotations from Employee... also, added a dummy persistence unit...
            Employee get() {
        LOG.info("HTTP request matching get()");
        Employee emp = new Employee();
        emp.setActive(true);
        emp.setFirstName("First");
        emp.setLastName("Last");
        emp.setDateOfBirth(Date.valueOf(LocalDate.of(2001, Month.APRIL, 19)));

        return emp;
    }
View Full Code Here

TOP

Related Classes of de.huepattl.playground.validation.Employee

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.