Search in sources :

Example 1 with SubjectEntity

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

the class SubjectsServiceTest method testFindByUserPresentList.

@Test
public void testFindByUserPresentList() throws Exception {
    final UserModelInterface userModel = this.usersSupport.getModelFixtureMock(0);
    final List<SubjectEntity> subjectsEntities = this.getSubjectsFixturesEntities();
    when(this.subjectsMapper.findByUserId(userModel.getId())).thenReturn(subjectsEntities);
    final List<SubjectModelInterface> subjectsFoundedModels = this.subjectsService.findByUser(userModel);
    this.subjectsSupport.assertModelsListEquals(this.getSubjectsFixturesModels(), subjectsFoundedModels);
}
Also used : UserModelInterface(easytests.core.models.UserModelInterface) SubjectEntity(easytests.core.entities.SubjectEntity) SubjectModelInterface(easytests.core.models.SubjectModelInterface)

Example 2 with SubjectEntity

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

the class SubjectsMapperTest method testFindAll.

@Test
public void testFindAll() throws Exception {
    final List<SubjectEntity> subjectsFoundedEntities = this.subjectsMapper.findAll();
    Assert.assertEquals(3, subjectsFoundedEntities.size());
    Integer index = 0;
    for (SubjectEntity subjectEntity : subjectsFoundedEntities) {
        final SubjectEntity subjectFixtureEntity = this.subjectsSupport.getEntityFixtureMock(index);
        this.subjectsSupport.assertEquals(subjectFixtureEntity, subjectEntity);
        index++;
    }
}
Also used : SubjectEntity(easytests.core.entities.SubjectEntity) Test(org.junit.Test)

Example 3 with SubjectEntity

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

the class SubjectsServiceTest method testFindWithOptions.

@Test
public void testFindWithOptions() throws Exception {
    final Integer id = 1;
    final Integer userId = 1;
    final SubjectEntity subjectEntity = this.createSubjectEntityMock(4, "test3", "description3", userId);
    final SubjectModelInterface subjectModel = this.mapSubjectModel(subjectEntity);
    final SubjectsOptionsInterface subjectsOptions = Mockito.mock(SubjectsOptionsInterface.class);
    given(this.subjectsMapper.find(id)).willReturn(subjectEntity);
    given(subjectsOptions.withRelations(subjectModel)).willReturn(subjectModel);
    final SubjectModelInterface foundedSubjectModel = this.subjectsService.find(id, subjectsOptions);
    Assert.assertEquals(subjectModel, foundedSubjectModel);
    verify(subjectsOptions).withRelations(subjectModel);
}
Also used : SubjectEntity(easytests.core.entities.SubjectEntity) SubjectsOptionsInterface(easytests.core.options.SubjectsOptionsInterface) SubjectModelInterface(easytests.core.models.SubjectModelInterface)

Example 4 with SubjectEntity

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

the class SubjectsServiceTest method testFindAllWithOptions.

@Test
public void testFindAllWithOptions() throws Exception {
    final List<SubjectEntity> subjectsEntities = this.getSubjectsEntities();
    final List<SubjectModelInterface> subjectsModels = this.getUsersModels();
    final SubjectsOptionsInterface subjectsOptions = Mockito.mock(SubjectsOptionsInterface.class);
    given(this.subjectsMapper.findAll()).willReturn(subjectsEntities);
    given(subjectsOptions.withRelations(Mockito.anyList())).willReturn(subjectsModels);
    final List<SubjectModelInterface> foundedSubjectsModels = this.subjectsService.findAll(subjectsOptions);
    verify(subjectsOptions).withRelations(foundedSubjectsModels);
    Assert.assertEquals(subjectsModels, foundedSubjectsModels);
}
Also used : SubjectEntity(easytests.core.entities.SubjectEntity) SubjectsOptionsInterface(easytests.core.options.SubjectsOptionsInterface) SubjectModelInterface(easytests.core.models.SubjectModelInterface)

Example 5 with SubjectEntity

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

the class SubjectsServiceTest method testFindByUserWithOptions.

@Test
public void testFindByUserWithOptions() 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);
    given(userModel.getId()).willReturn(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 SubjectsOptionsInterface subjectOptions = Mockito.mock(SubjectsOptionsInterface.class);
    given(subjectOptions.withRelations(subjectsModels)).willReturn(subjectsModels);
    final List<SubjectModelInterface> foundedSubjectsModels = this.subjectsService.findByUser(userModel, subjectOptions);
    verify(this.subjectsMapper).findByUserId(userId);
    verify(subjectOptions).withRelations(subjectsModels);
    Assert.assertEquals(subjectsModels, foundedSubjectsModels);
}
Also used : UserModelInterface(easytests.core.models.UserModelInterface) SubjectEntity(easytests.core.entities.SubjectEntity) ArrayList(java.util.ArrayList) SubjectsOptionsInterface(easytests.core.options.SubjectsOptionsInterface) SubjectModelInterface(easytests.core.models.SubjectModelInterface)

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