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

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


       
        assertTrue(res.containsAll(ctos) && ctos.containsAll(res));
    }
   
    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


        verify(dao).remove(order);
    }
   
    @Test
    public void testFindAll() {
        Customer c = newCustomer("Istvan", "Lelkes", "Hajovna 12", "54544");
        c.setId(22L);
        Order o = newOrder(c, null, null, null, extraServices, tyres, BigDecimal.ZERO);
        order.setId(1L);
        orderTO.setId(1L);
       
        List<Order> orders = Arrays.asList(new Order[] {order, o});
View Full Code Here

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

    /**
     * Test of get method, of class CustomerDAO.
     */
    @Test
    public void testGet() {
        Customer cust = newCustomer(null, null, null, null);
        customerDAO.create(cust);
        Long id = null;
        try {
            customerDAO.get(id);
            fail("Id null and didn't throw exception");
        } catch (DataAccessException ex) {
            //ok
        } catch (Exception ex) {
            fail("Id null and didn't throw appropriate exception");
        }
        Customer cust2 = customerDAO.get(cust.getId());
        assertNotNull("Customer is null", cust2);
        assertEquals("Customer are not the same", cust2, cust);
        assertDeepEquals(cust2, cust);
        Customer cust3 = customerDAO.get(cust.getId() + 1); // shouldn't exist
        assertNull("Customer is not null", cust3);
        removeAll();
    }
View Full Code Here

    /**
     * Test of update method, of class CustomerDAO.
     */
    @Test
    public void testUpdate() {
        Customer cust = newCustomer(null, null, null, null);
        customerDAO.create(cust);
        Long custId = cust.getId();
        cust.setId(null);
        //
        try {
            customerDAO.update(null);
            fail("Customer is null and didn't throw exception");
        } catch (DataAccessException ex) {
            //ok
        } catch (Exception ex) {
            fail("Customer is null and didn't throw appropriate exception");
        }
        try {
            customerDAO.update(cust);
            fail("Customer is ID null and didn't throw exception");
        } catch (DataAccessException ex) {
            //ok
        } catch (Exception ex) {
            fail("Customer is ID null and didn't throw appropriate exception");
        }
        //
        cust.setId(custId);
        customerDAO.update(cust);
        //
        Customer cust2 = customerDAO.get(cust.getId());
        assertEquals("Customer are not the same", cust2, cust);
        assertDeepEquals(cust2, cust);
    }
View Full Code Here

    /**
     * Test of remove method, of class CustomerDAO.
     */
    @Test
    public void testRemove() {
        Customer cust = newCustomer(null, null, null, null);
        customerDAO.create(cust);
        //
        try {
            customerDAO.remove(null);
            fail("Customer is null and didn't throw exception");
        } catch (DataAccessException ex) {
            //ok
        } catch (Exception ex) {
            fail("Customer is null and didn't throw appropriate exception");
        }
        try {
            customerDAO.remove(new Customer());
            fail("Customer ID is null and didn't throw exception");
        } catch (DataAccessException ex) {
            // ok
        } catch (Exception ex) {
            fail("Customer ID is null and didn't throw appropriate exception");
        }
        try {
            Customer cust2 = new Customer();
            cust2.setId(-1L);
            customerDAO.remove(cust2);
            fail("Shouldn't remove non-existent entity");
        } catch (DataAccessException ex) {
            //ok
        } catch (Exception ex) {
            fail("Non existent es (extra service) - should throw appropriate exception");
        }
        //
        customerDAO.remove(cust);
        Customer cust3 = customerDAO.get(cust.getId());
        assertNull("Found extraService that shouldn't be there", cust3);
        removeAll();
    }
View Full Code Here

    /**
     * Test of findByName method, of class CustomerDAO.
     */
    @Test
    public void testFindByName() {
        Customer cust1 = newCustomer("Laco", "Springel", "Ulica1 22, Dolny Kubin", "+421912345678");
        customerDAO.create(cust1);
        Customer cust2 = newCustomer("Peter", "Janosciak", "Ulica2 33, Brezno", "+421911222333");
        customerDAO.create(cust2);
       
        String firstName;
        String lastName;

        try {
            customerDAO.findByName(null, null);
            fail("String firstName and lastNameis null");
        } catch (DataAccessException e) {
            // ok
        } catch (Exception e) {
            fail("String name is null - should have been thrown another exception");
        }

        firstName = "Lacy";
        lastName = "Springel";
        List<Customer> customers = customerDAO.findByName(firstName, lastName);
        assertTrue("ExtraService is not in DB", customers.isEmpty());

        firstName = "Laco";
        lastName = "Springel";
        customers = customerDAO.findByName(firstName, lastName);
        assertEquals(cust1.getId(), customers.get(0).getId());
        assertDeepEquals(cust1, customers.get(0));

        Customer cust3 = newCustomer("Jakub", "Kmet", "Ulica3 44, Zilina", "+421911111111");
        customerDAO.create(cust3);
        Customer cust4 = newCustomer("Dusan", "Gorcak", "Ulica4 55, Lokca", "+421977777777");
        customerDAO.create(cust4);

        List<Customer> customerList = Arrays.asList(new Customer[]{cust1, cust2, cust3, cust4});

        customers = customerDAO.findByName(firstName, lastName);
View Full Code Here

            customerDAO.remove(t);
        }
    }
   
    private static Customer newCustomer(String firstName, String lastName, String address, String phone) {
        Customer customer = new Customer();
        customer.setFirstName(firstName);
        customer.setLastName(lastName);
        customer.setAddress(address);
        customer.setPhone(phone);

        return customer;
    }
View Full Code Here

        } catch (Exception ex) {
            fail("Customer is null and didn't throw appropriate exception");
        }
        //
        try {
            dao.findByCustomer(new Customer());
            fail("Customer id is null and didn't throw exception");
        } catch (DataAccessException ex) {
            //ok
        } catch (Exception ex) {
            fail("Customer ID is null and didn't throw appropriate exception");
View Full Code Here

       
        return es;
    }
   
    private static Customer newCustomer(String firstName, String lastName, String address, String phone) {
        Customer c = new Customer();
        c.setFirstName(firstName);
        c.setLastName(lastName);
        c.setAddress(address);
        c.setPhone(phone);
       
        return c;
    }
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.