Package cz.muni.fi.pa165.stis.entity

Examples of cz.muni.fi.pa165.stis.entity.Customer


    @Override
    public Customer get(Long id) {
        if (id == null) {
            throw new IllegalArgumentException("null id");
        }
        Customer customer = em.find(Customer.class, id);
        return customer;
    }
View Full Code Here


            throw new IllegalArgumentException("customer is null");
        }
        if (customer.getId() == null) {
            throw new IllegalArgumentException("customer.id is null");
        }
        Customer c = em.find(Customer.class, customer.getId());
        em.remove(c);
    }
View Full Code Here

    @Override
    public Customer getByUsername(String username) {
        Query query = em.createQuery("SELECT c FROM Customer c WHERE c.user.username = :username");
        query.setParameter("username", username);

        Customer customer = (Customer) query.getSingleResult();
        return customer;
    }
View Full Code Here

        }
        if (customer.getId() != null) {
            throw new IllegalArgumentException("customer.id is not null");
        }

        Customer c = mapper.map(customer, Customer.class);
        dao.create(c);
        customer.setId(c.getId());
    }
View Full Code Here

    @Override
    public CustomerTO get(Long id) {
        if (id == null) {
            throw new IllegalArgumentException("null id");
        }
        Customer customer = dao.get(id);
        if (customer == null) {
            return null;
        }
        return mapper.map(customer, CustomerTO.class);
    }   
View Full Code Here

        }
        if (customer.getId() == null) {
            throw new IllegalArgumentException("customer.id is null");
        }

        Customer c = mapper.map(customer, Customer.class);
        dao.update(c);
    }
View Full Code Here

            throw new IllegalArgumentException("customer is null");
        }
        if (customer.getId() == null) {
            throw new IllegalArgumentException("customer.id is null");
        }
        Customer c = mapper.map(customer, Customer.class);
        dao.remove(c);
    }
View Full Code Here

    @Override
    public CustomerTO getByUsername(String username) {
        if (username == null || username.equals("")) {
            throw new IllegalArgumentException("null or empty username");
        }
        Customer customer = dao.getByUsername(username);
        CustomerTO customerTO = mapper.map(customer, CustomerTO.class);
        return customerTO;
    }
View Full Code Here

        verify(cservice).getByUsername("mrkvicka");
        assertTrue(cuto.equals(customerUserTO));
    }

    private static Customer createCustomer(Long id, String firstName, String lastName, String address, String phone) {
        Customer c = new Customer();
        c.setId(id);
        c.setFirstName(firstName);
        c.setLastName(lastName);
        c.setAddress(address);
        c.setPhone(phone);
        return c;
    }
View Full Code Here

        CustomerUserTO customerUserTO = new CustomerUserTO(customerTO, userTO);
        customerTO.setUser(userTO)
               
        User user2 = createUser("ferko22", "bak!s$#", false);
        UserTO userTO2 = mapper.map(user2, UserTO.class);       
        Customer customer2 = createCustomer(null, "Petko", "Mravcek", "Teplicka nad Vahom 142", "772222222");
        CustomerTO customerTO2 = mapper.map(customer2, CustomerTO.class);       
        CustomerUserTO customerUserTO2 = new CustomerUserTO(customerTO2, userTO2);
        customerTO2.setUser(userTO2)
       
        List<CustomerTO> customerList = new ArrayList<>();
View Full Code Here

TOP

Related Classes of cz.muni.fi.pa165.stis.entity.Customer

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.