Search in sources :

Example 6 with TopicEntity

use of easytests.core.entities.TopicEntity in project easy-tests by malinink.

the class TopicsMapperTest method testFindBySubjectId.

@Test
public void testFindBySubjectId() throws Exception {
    final List<TopicEntity> topicsFixtureEntities = new ArrayList<>();
    topicsFixtureEntities.add(this.topicsSupport.getEntityFixtureMock(0));
    topicsFixtureEntities.add(this.topicsSupport.getEntityFixtureMock(1));
    final List<TopicEntity> topicsFoundedEntities = this.topicsMapper.findBySubjectId(2);
    Assert.assertEquals(topicsFixtureEntities.size(), topicsFoundedEntities.size());
    Integer index = 0;
    for (TopicEntity topicEntity : topicsFoundedEntities) {
        this.topicsSupport.assertEquals(topicsFixtureEntities.get(index), topicEntity);
        index++;
    }
}
Also used : TopicEntity(easytests.core.entities.TopicEntity) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 7 with TopicEntity

use of easytests.core.entities.TopicEntity in project easy-tests by malinink.

the class TopicsMapperTest method testFindAll.

@Test
public void testFindAll() throws Exception {
    final List<TopicEntity> topicsFoundedEntities = this.topicsMapper.findAll();
    Assert.assertEquals(3, topicsFoundedEntities.size());
    Integer index = 0;
    for (TopicEntity topicEntity : topicsFoundedEntities) {
        this.topicsSupport.assertEquals(this.topicsSupport.getEntityFixtureMock(index), topicEntity);
        index++;
    }
}
Also used : TopicEntity(easytests.core.entities.TopicEntity) Test(org.junit.Test)

Example 8 with TopicEntity

use of easytests.core.entities.TopicEntity in project easy-tests by malinink.

the class TopicsMapperTest method testInsert.

@Test
public void testInsert() throws Exception {
    final Integer id = this.topicsMapper.findAll().size() + 1;
    final String name = "FirstName";
    final Integer subjectId = 3;
    TopicEntity topicEntity = Mockito.mock(TopicEntity.class);
    Mockito.when(topicEntity.getName()).thenReturn(name);
    Mockito.when(topicEntity.getSubjectId()).thenReturn(subjectId);
    this.topicsMapper.insert(topicEntity);
    verify(topicEntity, times(1)).setId(id);
    topicEntity = this.topicsMapper.find(id);
    Assert.assertEquals(id, topicEntity.getId());
    Assert.assertEquals(name, topicEntity.getName());
    Assert.assertEquals(subjectId, topicEntity.getSubjectId());
}
Also used : TopicEntity(easytests.core.entities.TopicEntity) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 9 with TopicEntity

use of easytests.core.entities.TopicEntity in project easy-tests by malinink.

the class TopicsMapperTest method testFind.

@Test
public void testFind() throws Exception {
    final TopicEntity topicEntity = this.topicsMapper.find(1);
    Assert.assertEquals((Integer) 1, topicEntity.getId());
    Assert.assertEquals("Name1", topicEntity.getName());
    Assert.assertEquals((Integer) 2, topicEntity.getSubjectId());
}
Also used : TopicEntity(easytests.core.entities.TopicEntity) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 10 with TopicEntity

use of easytests.core.entities.TopicEntity in project easy-tests by malinink.

the class TopicsService method delete.

@Override
public void delete(TopicModelInterface topicModel) {
    final TopicEntity topicEntity = this.map(topicModel);
    if (topicEntity.getId() == null) {
        throw new DeleteUnidentifiedModelException();
    }
    this.topicsMapper.delete(topicEntity);
}
Also used : TopicEntity(easytests.core.entities.TopicEntity) DeleteUnidentifiedModelException(easytests.core.services.exceptions.DeleteUnidentifiedModelException)

Aggregations

TopicEntity (easytests.core.entities.TopicEntity)21 Test (org.junit.Test)15 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)12 TopicModelInterface (easytests.core.models.TopicModelInterface)8 SubjectModelInterface (easytests.core.models.SubjectModelInterface)4 TopicsOptionsInterface (easytests.core.options.TopicsOptionsInterface)4 ArrayList (java.util.ArrayList)4 List (java.util.List)2 DeleteUnidentifiedModelException (easytests.core.services.exceptions.DeleteUnidentifiedModelException)1