use of easytests.core.options.UsersOptionsInterface in project easy-tests by malinink.
the class UsersServiceTest method testFindByEmailWithOptions.
@Test
public void testFindByEmailWithOptions() throws Exception {
final String email = "new.email@gmail.com";
final UserEntity userEntity = Entities.createUserEntityMock(1, "NewFirstName", "NewLastName1", "NewSurname1", email, "newhash1", false, 3);
final UserModelInterface userModel = this.mapUserModel(userEntity);
final UsersOptionsInterface usersOptions = Mockito.mock(UsersOptionsInterface.class);
given(this.usersMapper.findByEmail(email)).willReturn(userEntity);
given(usersOptions.withRelations(userModel)).willReturn(userModel);
final UserModelInterface foundedUserModel = this.usersService.findByEmail(email, usersOptions);
Assert.assertEquals(userModel, foundedUserModel);
verify(usersOptions).withRelations(userModel);
}
use of easytests.core.options.UsersOptionsInterface in project easy-tests by malinink.
the class UsersServiceTest method testFindWithOptions.
@Test
public void testFindWithOptions() throws Exception {
final Integer id = 1;
final UserEntity userEntity = Entities.createUserEntityMock(id, "NewFirstName", "NewLastName1", "NewSurname1", "new.email@gmail.com", "newhash1", false, 3);
final UserModelInterface userModel = this.mapUserModel(userEntity);
final UsersOptionsInterface usersOptions = Mockito.mock(UsersOptionsInterface.class);
given(this.usersMapper.find(id)).willReturn(userEntity);
given(usersOptions.withRelations(userModel)).willReturn(userModel);
final UserModelInterface foundedUserModel = this.usersService.find(id, usersOptions);
Assert.assertEquals(userModel, foundedUserModel);
verify(usersOptions).withRelations(userModel);
}
use of easytests.core.options.UsersOptionsInterface in project easy-tests by malinink.
the class UsersServiceTest method testDeleteWithOptions.
@Test
public void testDeleteWithOptions() throws Exception {
final UserModelInterface userModel = Models.createUserModel(1, "FirstName", "LastName", "Surname", "email@gmail.com", "hash", true, 1);
final UsersOptionsInterface usersOptions = Mockito.mock(UsersOptionsInterface.class);
this.usersService.delete(userModel, usersOptions);
verify(usersOptions).deleteWithRelations(userModel);
}
use of easytests.core.options.UsersOptionsInterface in project easy-tests by malinink.
the class UsersController method delete.
@PostMapping("delete/{userId}/")
public String delete(@PathVariable Integer userId) {
this.getUserModel(userId);
final UsersOptionsInterface usersOptions = this.usersOptionsBuilder.forDelete();
final UserModelInterface userModel = this.usersService.find(userId, usersOptions);
this.usersService.delete(userModel, usersOptions);
return "redirect:/admin/users/";
}
use of easytests.core.options.UsersOptionsInterface in project easy-tests by malinink.
the class UsersOptionsBuilderTest method testForDelete.
@Test
public void testForDelete() throws Exception {
final SubjectsOptionsInterface subjectsOptions = new SubjectsOptions();
given(this.subjectsOptionsBuilder.forDelete()).willReturn(subjectsOptions);
final UsersOptionsInterface usersOptions = this.usersOptionsBuilder.forDelete();
Assert.assertEquals(new UsersOptions().withSubjects(subjectsOptions), usersOptions);
}
Aggregations