Search in sources :

Example 1 with UsersOptionsInterface

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);
}
Also used : UserModelInterface(easytests.core.models.UserModelInterface) UsersOptionsInterface(easytests.core.options.UsersOptionsInterface) UserEntity(easytests.core.entities.UserEntity)

Example 2 with UsersOptionsInterface

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);
}
Also used : UserModelInterface(easytests.core.models.UserModelInterface) UsersOptionsInterface(easytests.core.options.UsersOptionsInterface) UserEntity(easytests.core.entities.UserEntity)

Example 3 with UsersOptionsInterface

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);
}
Also used : UserModelInterface(easytests.core.models.UserModelInterface) UsersOptionsInterface(easytests.core.options.UsersOptionsInterface)

Example 4 with UsersOptionsInterface

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/";
}
Also used : UserModelInterface(easytests.core.models.UserModelInterface) UsersOptionsInterface(easytests.core.options.UsersOptionsInterface)

Example 5 with UsersOptionsInterface

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);
}
Also used : SubjectsOptions(easytests.core.options.SubjectsOptions) UsersOptions(easytests.core.options.UsersOptions) UsersOptionsInterface(easytests.core.options.UsersOptionsInterface) SubjectsOptionsInterface(easytests.core.options.SubjectsOptionsInterface) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test)

Aggregations

UsersOptionsInterface (easytests.core.options.UsersOptionsInterface)8 UserModelInterface (easytests.core.models.UserModelInterface)6 UserEntity (easytests.core.entities.UserEntity)3 UsersOptions (easytests.core.options.UsersOptions)2 Test (org.junit.Test)2 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)2 SubjectsOptions (easytests.core.options.SubjectsOptions)1 SubjectsOptionsInterface (easytests.core.options.SubjectsOptionsInterface)1