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

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


    public ShowBorrowReader(final PageParameters parameters) {
  super(parameters);
        BorrowService borrowService = (BorrowService) ApplicationContextProvider.getApplicationContext().getBean("borrowService");
        RepeatingView repeating = new RepeatingView("repeating");
        SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
        AuthenticatedSession session = ((AuthenticatedSession)Session.get());
        for (BorrowTO borrow : borrowService.findBorrowsByReader(session.getReader())) {
            for (BookTO book: borrow.getTitlesTO()){
                AbstractItem item = new AbstractItem(repeating.newChildId());
                item.add(new Label("title", book.getTitle()));     
                item.add(new Label("author", book.getAuthor()));
                item.add(new Label("borrowdate", dateFormat.format(borrow.getBorrowDate())));
View Full Code Here


            if (list.contains(book)){
                Link link = new Link("edit"){
                      @Override
                      public void onClick() {
                          ReservationService reservationService = (ReservationService) ApplicationContextProvider.getApplicationContext().getBean("reservationService");
                          AuthenticatedSession session = ((AuthenticatedSession)Session.get());
                          ReaderTO reader = session.getReader();
                          BookTO book2 = bookService.findBookById(book.getId());
                          java.util.Date date = new java.util.Date();
                          if (reader != null && book != null){
                              ReservationTO reservation = new ReservationTO(reader, book2,new Timestamp(date.getTime()));
                              reservationService.insertReservation(reservation);
View Full Code Here

       
        RepeatingView repeating = new RepeatingView("repeating");
        add(repeating);
        ReservationService reservationService = (ReservationService) ApplicationContextProvider.getApplicationContext().getBean("reservationService");
        SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
        AuthenticatedSession session = ((AuthenticatedSession)Session.get());
        List<ReservationTO> list = reservationService.findReservationsByReader(session.getReader());
        if(list != null){
            for (ReservationTO reservation : list) {
                AbstractItem item = new AbstractItem(repeating.newChildId());
                PageParameters pageParameters = new PageParameters();
                item.add(new BookmarkablePageLink<Void>("delete", ShowAllReservation.class, pageParameters));
View Full Code Here

        if (session.getUser()!=null){
            add(new Label("user",session.getUser()));
            add(new Label("login",new Model("")));
           add(new BookmarkablePageLink<>("logout", Logout.class));
           if (session.getCheckAdmin()){
                add(new MenuAdminPanel("menuPanel"));
            }else {
                add(new MenuReaderPanel("menuPanel"));
            }
        }else {
            add(new Label("user",""));
View Full Code Here

            add(new Label("login",new Model("")));
           add(new BookmarkablePageLink<>("logout", Logout.class));
           if (session.getCheckAdmin()){
                add(new MenuAdminPanel("menuPanel"));
            }else {
                add(new MenuReaderPanel("menuPanel"));
            }
        }else {
            add(new Label("user",""));
            add(new BookmarkablePageLink<>("login", Login.class));
            add(new Label("logout",new Model("")));
View Full Code Here

            fail("exception should be thrown");
        } catch (IllegalArgumentException ex) {
            // ok
        }
       
        Tyre t = createTyre(19D, "P Zero", "235/40ZR19", "Pirelli", BigDecimal.valueOf(450));
        TyreTO tto = mapper.map(t, TyreTO.class);
        try {
            service.update(tto);
            fail("exception should be thrown");
        } catch (IllegalArgumentException ex) {
View Full Code Here

        }
    }
   
    @Test
    public void testCreate() {
        final Tyre tyre = createTyre(19D, "P Zero", "235/40ZR19", "Pirelli", BigDecimal.valueOf(420));
        TyreTO tto = mapper.map(tyre, TyreTO.class);
       
        service.create(tto);
        verify(dao).create(argThat(new BaseMatcher<Tyre>() {

            @Override
            public boolean matches(Object item) {
                if (!(item instanceof Tyre)) {
                    return false;
                }
                final Tyre t = (Tyre) item;
                if (!Objects.equals(t.getDiameter(), tyre.getDiameter())) {
                    return false;
                }
                if (!Objects.equals(t.getName(), tyre.getName())) {
                    return false;
                }
                if (!Objects.equals(t.getPrice(), tyre.getPrice())) {
                    return false;
                }
                if (!Objects.equals(t.getType(), tyre.getType())) {
                    return false;
                }
                if (!Objects.equals(t.getVendor(), tyre.getVendor())) {
                    return false;
                }
               
                return true;
            }
View Full Code Here

        }));
    }

    @Test
    public void testGet() {
        Tyre tyre = createTyre(19D, "P Zero", "235/40ZR19", "Pirelli", BigDecimal.valueOf(420));
        tyre.setId(4L);
        TyreTO tto = mapper.map(tyre, TyreTO.class);       
       
        when(dao.get(4L)).thenReturn(tyre);
        TyreTO tyreTO = service.get(4L);
        assertEquals(tyreTO, tto);
View Full Code Here

        assertEquals(tyreTO, tto);
    }
   
    @Test
    public void testUpdate() {
        Tyre tyre = createTyre(19D, "P Zero", "235/40ZR19", "Pirelli", BigDecimal.valueOf(420));
        tyre.setId(2L);
        TyreTO tto = mapper.map(tyre, TyreTO.class);
       
        service.update(tto);
        verify(dao).update(tyre);       
    }
View Full Code Here

        verify(dao).update(tyre);       
    }
   
    @Test
    public void testRemove() {
        Tyre tyre = createTyre(19D, "P Zero", "235/40ZR19", "Pirelli", BigDecimal.valueOf(420));
        tyre.setId(2L);
        TyreTO tto = mapper.map(tyre, TyreTO.class);
       
        service.remove(tto);
        verify(dao).remove(tyre);       
    }
View Full Code Here

TOP

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

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.