Package cz.muni.fi.pa165.ddtroops.entities

Examples of cz.muni.fi.pa165.ddtroops.entities.Race


        assertTrue(squadS.getMembers().contains(leader));
    }

    @Test
    public void testRemoveMember(){
        Race race = getRace();
        Skill skill = getSkill();
        Hero leader = getHero(race, skill);

        squad = new Squad();
        squad.getMembers().add(leader);
View Full Code Here


    private RaceDAO raceDAO;

    @Test
    public void testCreateValid(){

        Race race = new Race();
        race.setName("Ogloj Chorchoj");
        race.setDescription("Velky cerv");
        race.setCharisma(Byte.MIN_VALUE);
        race.setConstitution(Byte.MIN_VALUE);
        race.setDexterity(Byte.MIN_VALUE);
        race.setIntelligence(Byte.MIN_VALUE);
        race.setStrength(Byte.MIN_VALUE);
        race.setWisdom(Byte.MIN_VALUE);

        raceDAO.create(race);
        assertNotNull(race.getId());
    }
View Full Code Here

    }

    @Test
    public void testCreateInvalid(){

        Race race = new Race();
        race.setName("Ogloj Chorchoj");
        race.setDescription("Velky cerv");

        try{
            raceDAO.create(race);
        }
        catch(Exception ex)
View Full Code Here

    @Test
    public void testGetById()
    {

        Race race = new Race();
        race.setName("Ogloj Chorchoj");
        race.setDescription("Velky cerv");
        race.setCharisma(Byte.MIN_VALUE);
        race.setConstitution(Byte.MIN_VALUE);
        race.setDexterity(Byte.MIN_VALUE);
        race.setIntelligence(Byte.MIN_VALUE);
        race.setStrength(Byte.MIN_VALUE);
        race.setWisdom(Byte.MIN_VALUE);

        raceDAO.create(race);
        assertEquals(race, raceDAO.getById(race.getId()));
    }
View Full Code Here

    @Test
    public void testUpdate()
    {

        Race race = new Race();
        race.setName("Ogloj");
        race.setDescription("Velky cerv");
        race.setCharisma(Byte.MIN_VALUE);
        race.setConstitution(Byte.MIN_VALUE);
        race.setDexterity(Byte.MIN_VALUE);
        race.setIntelligence(Byte.MIN_VALUE);
        race.setStrength(Byte.MIN_VALUE);
        race.setWisdom(Byte.MIN_VALUE);

        raceDAO.create(race);
        assertEquals("Ogloj", raceDAO.getById(race.getId()).getName());

        race.setName("Stupid Ogloj");
        raceDAO.update(race);
        assertEquals("Stupid Ogloj", raceDAO.getById(race.getId()).getName());
    }
View Full Code Here

    }

    @Test
    public void testGetAll()
    {
        Race race = new Race();
        race.setName("Ogloj");
        race.setDescription("Velky cerv");
        race.setCharisma(Byte.MIN_VALUE);
        race.setConstitution(Byte.MIN_VALUE);
        race.setDexterity(Byte.MIN_VALUE);
        race.setIntelligence(Byte.MIN_VALUE);
        race.setStrength(Byte.MIN_VALUE);
        race.setWisdom(Byte.MIN_VALUE);

        raceDAO.create(race);

        Race race2 = new Race();
        race2.setName("Ogloj");
        race2.setDescription("Velky cerv");
        race2.setCharisma(Byte.MIN_VALUE);
        race2.setConstitution(Byte.MIN_VALUE);
        race2.setDexterity(Byte.MIN_VALUE);
        race2.setIntelligence(Byte.MIN_VALUE);
        race2.setStrength(Byte.MIN_VALUE);
        race2.setWisdom(Byte.MIN_VALUE);

        raceDAO.create(race2);
        List<Race> races = raceDAO.getAll();
        assertTrue(races.contains(race)&&races.contains(race2));
    }
View Full Code Here

    private Hero createHero(){
        hero = new Hero();
        hero.setGender(Gender.MALE);
        hero.setBelief("atheist");
        hero.setProfession("miner");
        Race race = mock(Race.class);
        hero.setRace(race);
        User user = mock(User.class);
        hero.setUser(user);
        hero.setStrength(Byte.MIN_VALUE);
        hero.setDexterity(Byte.MIN_VALUE);
View Full Code Here

        verify(dao).getAll();
        verifyNoMoreInteractions(dao);
    }

    public Race getRace(){
        Race race = new Race();
        race.setName("SimpleRace");
        race.setDescription("Descript");
        race.setStrength(new Byte("61"));
        race.setDexterity(new Byte("61"));
        race.setConstitution(new Byte("15"));
        race.setIntelligence(new Byte("51"));
        race.setWisdom(new Byte("41"));
        race.setCharisma(new Byte("14"));
        return race;
    }
View Full Code Here

    private List<BookTO> listSelectedBook = new ArrayList();

    public AddBorrow(final PageParameters parameters) {
        super(parameters);
        ReaderService readerService = (ReaderService) ApplicationContextProvider.getApplicationContext().getBean("readerService");
        final BookService bookService = (BookService) ApplicationContextProvider.getApplicationContext().getBean("bookService");

        borrow = new BorrowTO();

        Form<?> form;
        form = new Form("form") {
            @Override
            protected void onSubmit() {
                BorrowService borrowService = (BorrowService) ApplicationContextProvider.getApplicationContext().getBean("borrowService");
                if (borrow.getBorrowID() == null) {
                    borrow.setBorrowDate(new Date(System.currentTimeMillis()));
                    Calendar cal = Calendar.getInstance();
                    cal.setTime(new Date(System.currentTimeMillis()));
                    cal.add(Calendar.MONTH, 1); // add 1 month 
                    borrow.setExpirationDate(cal.getTime());
                    if (selectedBook != null) {
                        listSelectedBook.add(selectedBook);
                    }
                    if (selectedBook2 != null) {
                        listSelectedBook.add(selectedBook2);
                    }
                    if (selectedBook3 != null) {
                        listSelectedBook.add(selectedBook3);
                    }
                    if (selectedBook4 != null) {
                        listSelectedBook.add(selectedBook4);
                    }
                    if (selectedBook5 != null) {
                        listSelectedBook.add(selectedBook5);
                    }
                    if (selectedBook6 != null) {
                        listSelectedBook.add(selectedBook6);
                    }
                    for (int i = 0; i < listSelectedBook.size(); i++) {
                        for (int j = i + 1; j < listSelectedBook.size(); j++) {
                            if (listSelectedBook.get(i).equals(listSelectedBook.get(j))) {
                                listSelectedBook.remove(listSelectedBook.get(j));
                                j--;
                            }
                        }
                    }
                    borrow.setTitlesTO(listSelectedBook);
                    borrowService.createBorrow(borrow);
                }
                setResponsePage(ShowAllBorrow.class);
            }
        };
        add(form);

        List<ReaderTO> readers = readerService.findAllReaders();
        DropDownChoice choiceReaders = new DropDownChoice("reader", new PropertyModel(borrow, "readerTO"), readers);
        form.add(choiceReaders);

        List<BookTO> books = bookService.findAllAvailableBooks();

        DropDownChoice choiceBooks = new DropDownChoice("title", new PropertyModel(this, "selectedBook"), books);
        form.add(choiceBooks);
        DropDownChoice choiceBooks2 = new DropDownChoice("title2", new PropertyModel(this, "selectedBook2"), books);
        form.add(choiceBooks2);
View Full Code Here

    private static final List<State> STATES = Arrays.asList(State.values());
    private static final List<Genre> GENRES = Arrays.asList(Genre.values());
   
    public EditBook(final PageParameters parameters) {
  super(parameters);
        BookService bookService = (BookService) ApplicationContextProvider.getApplicationContext().getBean("bookService");
        StringValue bookId = parameters.get("bookId");
        if (bookId.isEmpty()) {
           book = new BookTO();
           add(new Label("titleMessage", new Model("Create book")));
        } else {
            book = bookService.findBookById(bookId.toLong());
            add(new Label("titleMessage", new Model("Edit book")));
        }
       
        Form<?> form = new Form("form") {
            @Override
            protected void onSubmit() {
                BookService bookService = (BookService) ApplicationContextProvider.getApplicationContext().getBean("bookService");
                if (book.getId() == null) {
                    book.setAvailability(Available.AVAILABLE);
                    bookService.createBook(book);
                } else {
                    bookService.updateBook(book);
                }
                setResponsePage(ShowAllBook.class);
            }
        };
        add(form);
View Full Code Here

TOP

Related Classes of cz.muni.fi.pa165.ddtroops.entities.Race

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.