Package cz.muni.fi.pa165.library.web_layer.adminPages.Reader

Examples of cz.muni.fi.pa165.library.web_layer.adminPages.Reader.EditReader


    }
   
    private void createTestData(){
      
        for (int i=0; i<10;i++){
            Reader readers = new Reader();
            readers.setFirstName("Karel"+i);
            readers.setSurname("Novak"+i);
            readers.setBirthNumber(i+i+".3.2012");
            readers.setAddress("Nove Hrady "+i+", Praha");
            readers.setTelephoneNumber("+4207563627"+i+i);      
            readers.setEmail("mail"+i+"@seznam.cz");
            EntityManager em = emf.createEntityManager();
            em.getTransaction().begin();
            em.persist(readers);
            em.getTransaction().commit();
            if (em != null) {
View Full Code Here


            readerDAO.createReader(null);
            fail("NullPointerException has not been thrown");
        } catch (IllegalArgumentException ex) {
            //OK
        }
        Reader reader = addReader();
        reader.setId(1l);
        try {
            readerDAO.createReader(reader);
            fail("Wrong id, IllegalArgumentException has not been thrown");
        } catch (IllegalArgumentException ex) {
            //OK
        }
        reader.setId(new Long(-1));
        try {
            readerDAO.createReader(reader);
            fail("Wrong id, IllegalArgumentException has not been thrown");
        } catch (IllegalArgumentException ex) {
            //OK
        }
        reader.setFirstName(null);
        try {
            readerDAO.createReader(reader);
            fail("FirstName is null, NullPointerException has not been thrown");
        } catch (IllegalArgumentException ex) {
            //OK
        }
        reader.setFirstName("");
        try {
            readerDAO.createReader(reader);
            fail("FirstName is empty, IllegalArgumentException has not been thrown");
        } catch (IllegalArgumentException ex) {
            //OK
        }
        reader.setSurname(null);
        try {
            readerDAO.createReader(reader);
            fail("Surname is null, NullPointerException has not been thrown");
        } catch (IllegalArgumentException ex) {
            //OK
        }
        reader.setSurname("");
        try {
            readerDAO.createReader(reader);
            fail("Surname is empty, IllegalArgumentException has not been thrown");
        } catch (IllegalArgumentException ex) {
            //OK
        }
        reader.setBirthNumber(null);
        try {
            readerDAO.createReader(reader);
            fail("Birth number is null, NullPointerException has not been thrown");
        } catch (IllegalArgumentException ex) {
            //OK
        }
        reader.setBirthNumber("");
        try {
            readerDAO.createReader(reader);
            fail("Birth number is empty, IllegalArgumentException has not been thrown");
        } catch (IllegalArgumentException ex) {
            //OK
        }
        reader.setAddress(null);
        try {
            readerDAO.createReader(reader);
            fail("Address is null, NullPointerException has not been thrown");
        } catch (IllegalArgumentException ex) {
            //OK
        }
        reader.setAddress("");
        try {
            readerDAO.createReader(reader);
            fail("Address is empty, IllegalArgumentException has not been thrown");
        } catch (IllegalArgumentException ex) {
            //OK
        }
        reader.setEmail(null);
        try {
            readerDAO.createReader(reader);
            fail("Email is null, NullPointerException has not been thrown");
        } catch (IllegalArgumentException ex) {
            //OK
        }
        reader.setEmail("");
        try {
            readerDAO.createReader(reader);
            fail("Email is empty, IllegalArgumentException has not been thrown");
        } catch (IllegalArgumentException ex) {
            //OK
View Full Code Here

            //OK
        }
        createTestData();
        Reader[] readers = readerDAO.findAllReaders().toArray(new Reader[]{});
        for(int i=0;i<readers.length;i++){
            Reader result = readerDAO.findReaderById(readers[i].getId());
            assertEquals("Readers are not equals", readers[i], result);
            assertEquals("Correct ID is not return", readers[i].getId(), result.getId());
            assertEquals("Correct first name is not return",readers[i].getFirstName(), result.getFirstName());
            assertEquals("Correct surname is not return", readers[i].getSurname(), result.getSurname());
            assertEquals("Correct birthNumber is not return", readers[i].getBirthNumber(), result.getBirthNumber());
            assertEquals("Correct address is not return", readers[i].getAddress(), result.getAddress());
            assertEquals("Correct email is not return", readers[i].getEmail(), result.getEmail());
            assertEquals("Correct telephoneNumber is not return", readers[i].getTelephoneNumber(), result.getTelephoneNumber());
        }
      }
View Full Code Here

            fail("Surname of reader should not be null");
        } catch (IllegalArgumentException ex) {
            //OK
        }

        Reader reader = addReader();
        persist(reader);
        assertEquals("Reader was not find by name", 1, readerDAO.findReaderByName("Karel", "Novak").size());
        Reader[] readers = readerDAO.findReaderByName(reader.getFirstName(), reader.getSurname()).toArray(new Reader[]{});;
        assertEquals("Readers are not equals", readers[0], reader);
        assertEquals("Correct ID is not return", readers[0].getId(), reader.getId());
        assertEquals("Correct first name is not return",readers[0].getFirstName(), reader.getFirstName());
        assertEquals("Correct surname is not return", readers[0].getSurname(), reader.getSurname());
        assertEquals("Correct birthNumber is not return", readers[0].getBirthNumber(), reader.getBirthNumber());
        assertEquals("Correct address is not return", readers[0].getAddress(), reader.getAddress());
        assertEquals("Correct email is not return", readers[0].getEmail(), reader.getEmail());
        assertEquals("Correct telephoneNumber is not return", readers[0].getTelephoneNumber(), reader.getTelephoneNumber());
    }
View Full Code Here

            //OK
        }
        createTestData();
        Reader[] readers = readerDAO.findAllReaders().toArray(new Reader[]{});
        for(int i=0;i<readers.length;i++){
            Reader result = readerDAO.findReaderByBirthNumber(readers[i].getBirthNumber());
            assertEquals("Readers are not equals", readers[i], result);
            assertEquals("Correct ID is not return", readers[i].getId(), result.getId());
            assertEquals("Correct first name is not return",readers[i].getFirstName(), result.getFirstName());
            assertEquals("Correct surname is not return", readers[i].getSurname(), result.getSurname());
            assertEquals("Correct birthNumber is not return", readers[i].getBirthNumber(), result.getBirthNumber());
            assertEquals("Correct address is not return", readers[i].getAddress(), result.getAddress());
            assertEquals("Correct email is not return", readers[i].getEmail(), result.getEmail());
            assertEquals("Correct telephoneNumber is not return", readers[i].getTelephoneNumber(), result.getTelephoneNumber());
        }
    }
View Full Code Here

            //OK
        }
        createTestData();
        Reader[] readers = readerDAO.findAllReaders().toArray(new Reader[]{});
        for(int i=0;i<readers.length;i++){
            Reader result = readerDAO.findReaderByEmail(readers[i].getEmail());
            assertEquals("Readers are not equals", readers[i], result);
            assertEquals("Correct ID is not return", readers[i].getId(), result.getId());
            assertEquals("Correct first name is not return",readers[i].getFirstName(), result.getFirstName());
            assertEquals("Correct surname is not return", readers[i].getSurname(), result.getSurname());
            assertEquals("Correct birthNumber is not return", readers[i].getBirthNumber(), result.getBirthNumber());
            assertEquals("Correct address is not return", readers[i].getAddress(), result.getAddress());
            assertEquals("Correct email is not return", readers[i].getEmail(), result.getEmail());
            assertEquals("Correct telephoneNumber is not return", readers[i].getTelephoneNumber(), result.getTelephoneNumber());
        }
    }
View Full Code Here

            assertEquals("Correct telephoneNumber is not return", readers[i].getTelephoneNumber(), result.getTelephoneNumber());
        }
    }

    public void testUpdateReader() {
        Reader reader = addReader();
        persist(reader);
        reader.setFirstName(null);
        try {
            readerDAO.updateReader(reader);
            fail("FirstName is null, NullPointerException has not been thrown");
        } catch (IllegalArgumentException ex) {
            //OK
        }
        reader.setFirstName("");
        try {
            readerDAO.updateReader(reader);
            fail("FirstName is empty, IllegalArgumentException has not been thrown");
        } catch (IllegalArgumentException ex) {
            //OK
        }
        reader.setSurname(null);
        try {
            readerDAO.updateReader(reader);
            fail("Surname is null, NullPointerException has not been thrown");
        } catch (IllegalArgumentException ex) {
            //OK
        }
        reader.setSurname("");
        try {
            readerDAO.updateReader(reader);
            fail("Surname is empty, IllegalArgumentException has not been thrown");
        } catch (IllegalArgumentException ex) {
            //OK
        }
        reader.setBirthNumber(null);
        try {
            readerDAO.updateReader(reader);
            fail("Birth number is null, NullPointerException has not been thrown");
        } catch (IllegalArgumentException ex) {
            //OK
        }
        reader.setBirthNumber("");
        try {
            readerDAO.updateReader(reader);
            fail("Birth number is empty, IllegalArgumentException has not been thrown");
        } catch (IllegalArgumentException ex) {
            //OK
        }
        reader.setAddress(null);
        try {
            readerDAO.updateReader(reader);
            fail("Address is null, NullPointerException has not been thrown");
        } catch (IllegalArgumentException ex) {
            //OK
        }
        reader.setAddress("");
        try {
            readerDAO.updateReader(reader);
            fail("Address is empty, IllegalArgumentException has not been thrown");
        } catch (IllegalArgumentException ex) {
            //OK
        }
        reader.setEmail(null);
        try {
            readerDAO.updateReader(reader);
            fail("Email is null, NullPointerException has not been thrown");
        } catch (IllegalArgumentException ex) {
            //OK
        }
        reader.setEmail("");
        try {
            readerDAO.updateReader(reader);
            fail("Email is empty, IllegalArgumentException has not been thrown");
        } catch (IllegalArgumentException ex) {
            //OK
        }      
        reader.setFirstName("Marie");
        reader.setSurname("Nová");
        reader.setAddress("8859182456");
        reader.setBirthNumber("Praha 5");
        reader.setEmail("adresa@gmail.com");
        reader.setTelephoneNumber("+234455743");
        readerDAO.updateReader(reader);
        Reader reader2 = readerDAO.findReaderById(reader.getId());
        assertEquals("Readers are not equals", reader2, reader);
        assertEquals("Correct ID is not return", reader2.getId(), reader.getId());
        assertEquals("Correct first name is not return",reader2.getFirstName(), reader.getFirstName());
        assertEquals("Correct surname is not return", reader2.getSurname(), reader.getSurname());
        assertEquals("Correct birthNumber is not return", reader2.getBirthNumber(), reader.getBirthNumber());
        assertEquals("Correct address is not return", reader2.getAddress(), reader.getAddress());
        assertEquals("Correct email is not return", reader2.getEmail(), reader.getEmail());
        assertEquals("Correct telephoneNumber is not return", reader2.getTelephoneNumber(), reader.getTelephoneNumber());
    }
View Full Code Here

    private void createReaderData() {
        // ID start from 1 incremented by 1, because of in memory DB
        // ID 1
        EntityManager entityManager = entityManagerFactory.createEntityManager();
        entityManager.getTransaction().begin();
        entityManager.persist(new Reader("Emil", "Slovak", "8.9.1973", "Velke Cierne 23, SR",
                "e.slovak@gmail.com", "0949 123 542", "aaa"));
        // ID 2
        entityManager.persist(new Reader("Karel", "Novak", "7.11.1981", "Grohova 2, Brno, CR",
                "karel.novak@gmail.com", "735 945 248", "ccc"));
        // ID 3
        entityManager.persist(new Reader("Jack", "Black", "6.8.1972", "1234/1 5th Avenue, NY, USA",
                "jack.black@gmail.com", "482 451 354", "ddd"));
        entityManager.getTransaction().commit();
        entityManager.close();
    }
View Full Code Here

    }
  
    public void testInsertBorrowBookStateUpdate() {       
        long currentTime = System.currentTimeMillis();
        EntityManager entityManager = entityManagerFactory.createEntityManager();
        Reader reader = entityManager.find(Reader.class, 1l);
        entityManager.close();
       
        em.getTransaction().begin();
        borrowDAO.createBorrow(new Borrow(reader, prepareBorrowList(),
                new Date(currentTime), new Date(currentTime + 2592000000l)));
View Full Code Here

      
        List<Book> borrowList2 = new ArrayList<Book>();
        borrowList2.add(entityManager.find(Book.class, 3l));
        borrowList2.add(entityManager.find(Book.class, 4l));
       
        Reader reader1 = entityManager.find(Reader.class, 1l);
        Reader reader2 = entityManager.find(Reader.class, 2l);
        entityManager.close();
       
        // ID 1
        Borrow borrow1 = new Borrow(reader1, borrowList1,
                new Date(System.currentTimeMillis()), new Date(System.currentTimeMillis()));
View Full Code Here

TOP

Related Classes of cz.muni.fi.pa165.library.web_layer.adminPages.Reader.EditReader

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.