use of easytests.core.entities.SubjectEntity in project easy-tests by malinink.
the class SubjectsMapperTest method testUpdate.
@Test
public void testUpdate() throws Exception {
final Integer id = 2;
final String name = "updated";
final String description = "updated description";
SubjectEntity subject = this.subjectsMapper.find(id);
Assert.assertNotEquals(name, subject.getName());
Assert.assertNotEquals(description, subject.getDescription());
subject = Mockito.mock(SubjectEntity.class);
Mockito.when(subject.getId()).thenReturn(id);
Mockito.when(subject.getName()).thenReturn(name);
Mockito.when(subject.getDescription()).thenReturn(description);
this.subjectsMapper.update(subject);
final SubjectEntity readSubject = subjectsMapper.find(id);
Assert.assertEquals(name, readSubject.getName());
Assert.assertEquals(description, readSubject.getDescription());
}
use of easytests.core.entities.SubjectEntity in project easy-tests by malinink.
the class SubjectsMapperTest method testInsert.
@Test
public void testInsert() throws Exception {
final Integer id = this.subjectsMapper.findAll().size() + 1;
final Integer testUserId = 1;
final String testName = "test";
final String testDescription = "testSubject.description";
final SubjectEntity testSubject = Mockito.mock(SubjectEntity.class);
Mockito.when(testSubject.getId()).thenReturn(id);
Mockito.when(testSubject.getName()).thenReturn(testName);
Mockito.when(testSubject.getDescription()).thenReturn(testDescription);
Mockito.when(testSubject.getUserId()).thenReturn(testUserId);
subjectsMapper.insert(testSubject);
verify(testSubject, times(1)).setId(id);
final SubjectEntity readSubject = subjectsMapper.find(testSubject.getId());
Assert.assertNotNull(readSubject);
Assert.assertEquals(testUserId, readSubject.getUserId());
Assert.assertEquals(testName, readSubject.getName());
Assert.assertEquals(testDescription, readSubject.getDescription());
}
use of easytests.core.entities.SubjectEntity in project easy-tests by malinink.
the class SubjectsMapperTest method testDelete.
@Test
public void testDelete() throws Exception {
SubjectEntity subject = this.subjectsMapper.find(1);
Assert.assertNotNull(subject);
this.subjectsMapper.delete(subject);
subject = this.subjectsMapper.find(1);
Assert.assertNull(subject);
}
use of easytests.core.entities.SubjectEntity in project easy-tests by malinink.
the class SubjectsServiceTest method testSaveUpdateEntityIdOnCreation.
@Test
public void testSaveUpdateEntityIdOnCreation() throws Exception {
final Integer id = 5;
final SubjectModelInterface subjectModel = this.subjectsSupport.getModelAdditionalMock(0);
doAnswer(invocation -> {
final SubjectEntity subjectEntity = (SubjectEntity) invocation.getArguments()[0];
subjectEntity.setId(id);
return null;
}).when(this.subjectsMapper).insert(any());
this.subjectsService.save(subjectModel);
verify(subjectModel, times(1)).setId(id);
}
use of easytests.core.entities.SubjectEntity in project easy-tests by malinink.
the class SubjectsSupport method assertEntitiesListEquals.
public void assertEntitiesListEquals(List<SubjectEntity> expected, List<SubjectEntity> actual) {
Assert.assertEquals(expected.size(), actual.size());
Integer i = 0;
for (SubjectEntity subjectEntity : expected) {
this.assertEquals(subjectEntity, actual.get(i));
i++;
}
}
Aggregations