Search in sources :

Example 16 with Poll

use of org.survey.model.poll.Poll in project survey by markoniemi.

the class PollServiceTestBase method tearDown.

@After
public void tearDown() throws SQLException {
    Poll[] users = entityService.findAll();
    if (users != null) {
        for (Poll pollToDelete : users) {
            entityService.delete(pollToDelete.getName());
        }
    }
    userService.delete(user.getUsername());
}
Also used : Poll(org.survey.model.poll.Poll) After(org.junit.After)

Example 17 with Poll

use of org.survey.model.poll.Poll in project survey by markoniemi.

the class PollServiceTestBase method update.

@Test
public void update() {
    create();
    for (int i = 0; i < ENTITY_COUNT; i++) {
        Poll foundEntity = entityService.findOne(savedEntities.get(i).getName());
        Poll updatedEntity = entityFactory.getUpdatedEntity(foundEntity);
        updatedEntity.setId(foundEntity.getId());
        entityService.update(updatedEntity);
        foundEntity = entityService.findOne(savedEntities.get(i).getName());
        assertEntity(updatedEntity, foundEntity);
    }
}
Also used : Poll(org.survey.model.poll.Poll) Test(org.junit.Test)

Example 18 with Poll

use of org.survey.model.poll.Poll in project survey by markoniemi.

the class PollServiceTestBase method create.

@Test
public void create() {
    orginalEntities = entityFactory.getEntities(ENTITY_COUNT);
    for (int i = 0; i < ENTITY_COUNT; i++) {
        Poll originalEntity = orginalEntities.get(i);
        Poll savedEntity = entityService.create(originalEntity);
        savedEntities.add(savedEntity);
        assertEntity(originalEntity, savedEntity);
    }
}
Also used : Poll(org.survey.model.poll.Poll) Test(org.junit.Test)

Example 19 with Poll

use of org.survey.model.poll.Poll in project survey by markoniemi.

the class EditPollBean method addPoll.

public String addPoll() {
    poll = new Poll();
    poll.setOwner(getCurrentUser());
    return "editPoll";
}
Also used : Poll(org.survey.model.poll.Poll)

Example 20 with Poll

use of org.survey.model.poll.Poll in project survey by markoniemi.

the class PollServiceImpl method findByOwner.

public Poll[] findByOwner(String username) {
    User user = userRepository.findByUsername(username);
    if (user == null) {
        return EMPTY_POLL_ARRAY;
    }
    Iterable<Poll> polls = pollRepository.findAllByOwner(user);
    // return empty list instead of null
    if (Iterables.isEmpty(polls)) {
        return EMPTY_POLL_ARRAY;
    } else {
        return Iterables.toArray(polls, Poll.class);
    }
}
Also used : User(org.survey.model.user.User) Poll(org.survey.model.poll.Poll)

Aggregations

Poll (org.survey.model.poll.Poll)21 Test (org.junit.Test)14 After (org.junit.After)2 Ignore (org.junit.Ignore)2 ModelAndView (org.springframework.web.servlet.ModelAndView)2 CrudRepositoryTest (org.survey.repository.CrudRepositoryTest)2 Before (org.junit.Before)1 ResultActions (org.springframework.test.web.servlet.ResultActions)1 MockHttpServletRequestBuilder (org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 Question (org.survey.model.poll.Question)1 QuestionType (org.survey.model.poll.QuestionType)1 User (org.survey.model.user.User)1