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());
}
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);
}
}
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);
}
}
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";
}
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);
}
}
Aggregations