Search in sources :

Example 16 with SubjectEntity

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

the class SubjectsSupport method getEntityMock.

private SubjectEntity getEntityMock(Integer id, String name, String description, Integer userId) {
    final SubjectEntity subjectEntity = Mockito.mock(SubjectEntity.class);
    Mockito.when(subjectEntity.getId()).thenReturn(id);
    Mockito.when(subjectEntity.getName()).thenReturn(name);
    Mockito.when(subjectEntity.getDescription()).thenReturn(description);
    Mockito.when(subjectEntity.getUserId()).thenReturn(userId);
    return subjectEntity;
}
Also used : SubjectEntity(easytests.core.entities.SubjectEntity)

Example 17 with SubjectEntity

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

the class SubjectsMapperTest method testFindByUserId.

@Test
public void testFindByUserId() throws Exception {
    final List<SubjectEntity> subjectsFixtureEntities = new ArrayList<>();
    subjectsFixtureEntities.add(this.subjectsSupport.getEntityFixtureMock(0));
    subjectsFixtureEntities.add(this.subjectsSupport.getEntityFixtureMock(1));
    final List<SubjectEntity> subjectsFoundedEntities = this.subjectsMapper.findByUserId(2);
    Assert.assertEquals(2, subjectsFoundedEntities.size());
    Integer index = 0;
    for (SubjectEntity subjectEntity : subjectsFoundedEntities) {
        this.subjectsSupport.assertEquals(subjectsFixtureEntities.get(index), subjectEntity);
        index++;
    }
}
Also used : SubjectEntity(easytests.core.entities.SubjectEntity) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 18 with SubjectEntity

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

the class SubjectsServiceTest method testFindByUser.

@Test
public void testFindByUser() throws Exception {
    final Integer userId = 7;
    final UserModelInterface userModel = Mockito.mock(UserModelInterface.class);
    final SubjectEntity subjectEntityFirst = this.createSubjectEntityMock(3, "test3", "description3", userId);
    final SubjectEntity subjectEntitySecond = this.createSubjectEntityMock(12, "test12", "description12", userId);
    final List<SubjectEntity> subjectsEntities = new ArrayList<>();
    subjectsEntities.add(subjectEntityFirst);
    subjectsEntities.add(subjectEntitySecond);
    Mockito.when(userModel.getId()).thenReturn(userId);
    given(this.subjectsMapper.findByUserId(userId)).willReturn(subjectsEntities);
    final List<SubjectModelInterface> subjectsModels = new ArrayList<>();
    subjectsModels.add(this.mapSubjectModel(subjectEntityFirst));
    subjectsModels.add(this.mapSubjectModel(subjectEntitySecond));
    final List<SubjectModelInterface> foundedSubjectsModels = this.subjectsService.findByUser(userModel);
    verify(this.subjectsMapper).findByUserId(userId);
    Assert.assertEquals(subjectsModels, foundedSubjectsModels);
}
Also used : UserModelInterface(easytests.core.models.UserModelInterface) SubjectEntity(easytests.core.entities.SubjectEntity) ArrayList(java.util.ArrayList) SubjectModelInterface(easytests.core.models.SubjectModelInterface)

Example 19 with SubjectEntity

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

the class SubjectsMapperTest method testFind.

@Test
public void testFind() throws Exception {
    final SubjectEntity subject = this.subjectsMapper.find(1);
    Assert.assertEquals((long) 1, (long) subject.getId());
    Assert.assertEquals("test1", subject.getName());
    Assert.assertEquals("testdescription1", subject.getDescription());
}
Also used : SubjectEntity(easytests.core.entities.SubjectEntity) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

SubjectEntity (easytests.core.entities.SubjectEntity)19 SubjectModelInterface (easytests.core.models.SubjectModelInterface)7 Test (org.junit.Test)7 ArrayList (java.util.ArrayList)4 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)4 UserModelInterface (easytests.core.models.UserModelInterface)3 SubjectsOptionsInterface (easytests.core.options.SubjectsOptionsInterface)3 IssueStandardModelEmpty (easytests.core.models.empty.IssueStandardModelEmpty)1 ModelsListEmpty (easytests.core.models.empty.ModelsListEmpty)1 UserModelEmpty (easytests.core.models.empty.UserModelEmpty)1