Search in sources :

Example 6 with Poll

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

the class PollServiceTestBase method findOne.

@Test
public void findOne() {
    create();
    for (int i = 0; i < ENTITY_COUNT; i++) {
        Poll originalEntity = orginalEntities.get(i);
        Poll foundEntity = entityService.findOne(originalEntity.getName());
        assertEntity(orginalEntities.get(i), foundEntity);
    }
// TODO how to test a non-existent entity?
}
Also used : Poll(org.survey.model.poll.Poll) Test(org.junit.Test)

Example 7 with Poll

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

the class PollServiceTestBase method exists.

@Test
public void exists() {
    create();
    for (int i = 0; i < ENTITY_COUNT; i++) {
        Poll entity = orginalEntities.get(i);
        entityService.exists(entity.getName());
    }
// TODO how to test if exists fails?
// Assert.assertFalse(entityRepository.exists((ID) new Object()));
}
Also used : Poll(org.survey.model.poll.Poll) Test(org.junit.Test)

Example 8 with Poll

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

the class PollServiceTestBase method delete.

@Test
public void delete() {
    create();
    for (int i = 0; i < ENTITY_COUNT; i++) {
        Poll entity = orginalEntities.get(i);
        entityService.delete(entity.getName());
        Assert.assertFalse(entityService.exists(entity.getName()));
    }
    Assert.assertEquals(0, entityService.count());
}
Also used : Poll(org.survey.model.poll.Poll) Test(org.junit.Test)

Example 9 with Poll

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

the class PollRepositoryTest method findAllByOwner.

@Test
public void findAllByOwner() {
    save();
    Poll originalPoll = orginalEntities.get(0);
    @SuppressWarnings("unchecked") List<Poll> polls = IteratorUtils.toList(pollRepository.findAllByOwner(originalPoll.getOwner()).iterator());
    Assert.assertEquals(ENTITY_COUNT, polls.size());
// Assert.assertEquals(0, entityComparator.compare(originalPoll, polls.get(0)));
}
Also used : Poll(org.survey.model.poll.Poll) Test(org.junit.Test) CrudRepositoryTest(org.survey.repository.CrudRepositoryTest)

Example 10 with Poll

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

the class PollRepositoryTest method findByName.

@Test
public void findByName() {
    save();
    Poll originalPoll = orginalEntities.get(0);
    Poll poll = (pollRepository.findByName(originalPoll.getName()));
    Assert.assertEquals(0, entityComparator.compare(originalPoll, poll));
}
Also used : Poll(org.survey.model.poll.Poll) Test(org.junit.Test) CrudRepositoryTest(org.survey.repository.CrudRepositoryTest)

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