use of easytests.core.models.UserModelInterface in project easy-tests by malinink.
the class UsersOptionsTest method testWithNoRelations.
@Test
public void testWithNoRelations() throws Exception {
this.withUserModel().withSubjectsModelsFounded();
final UserModelInterface userModelWithRelations = this.usersOptions.withRelations(this.userModel);
Assert.assertSame(userModel, userModelWithRelations);
verify(this.subjectsService, times(0)).findByUser(any(), any());
verify(this.userModel, times(0)).setSubjects(anyList());
}
use of easytests.core.models.UserModelInterface 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);
}
use of easytests.core.models.UserModelInterface in project easy-tests by malinink.
the class UsersServiceTest method testSaveUpdateEntityIdOnCreation.
@Test
public void testSaveUpdateEntityIdOnCreation() throws Exception {
final UserModelInterface userAdditionalModel = this.usersSupport.getModelAdditionalMock(0);
doAnswer(invocation -> {
final UserEntity userEntity = (UserEntity) invocation.getArguments()[0];
userEntity.setId(5);
return null;
}).when(this.usersMapper).insert(Mockito.any(UserEntity.class));
this.usersService.save(userAdditionalModel);
verify(userAdditionalModel, times(1)).setId(5);
}
use of easytests.core.models.UserModelInterface in project easy-tests by malinink.
the class UsersSupport method assertModelsListEquals.
public void assertModelsListEquals(List<UserModelInterface> expected, List<UserModelInterface> actual) {
Assert.assertEquals(expected.size(), actual.size());
Integer i = 0;
for (UserModelInterface userModel : expected) {
this.assertEquals(userModel, actual.get(i));
i++;
}
}
use of easytests.core.models.UserModelInterface in project easy-tests by malinink.
the class UsersSupport method getModelMock.
private UserModelInterface getModelMock(Integer id, String firstName, String lastName, String surname, String email, String password, Boolean isAdmin, Integer state) {
final UserModelInterface userModel = Mockito.mock(UserModelInterface.class);
Mockito.when(userModel.getId()).thenReturn(id);
Mockito.when(userModel.getFirstName()).thenReturn(firstName);
Mockito.when(userModel.getLastName()).thenReturn(lastName);
Mockito.when(userModel.getSurname()).thenReturn(surname);
Mockito.when(userModel.getEmail()).thenReturn(email);
Mockito.when(userModel.getPassword()).thenReturn(password);
Mockito.when(userModel.getIsAdmin()).thenReturn(isAdmin);
Mockito.when(userModel.getState()).thenReturn(state);
Mockito.when(userModel.getSubjects()).thenReturn(new ModelsListEmpty());
return userModel;
}
Aggregations