Search in sources :

Example 26 with UserModelInterface

use of easytests.core.models.UserModelInterface 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 27 with UserModelInterface

use of easytests.core.models.UserModelInterface in project easy-tests by malinink.

the class UsersOptionsTest method testWithSubjectsRelations.

@Test
public void testWithSubjectsRelations() throws Exception {
    this.withUserModel().withSubjectsModelsFounded().withSubjects();
    final UserModelInterface userModelWithRelations = this.usersOptions.withRelations(this.userModel);
    Assert.assertSame(userModel, userModelWithRelations);
    verify(this.subjectsService, times(1)).findByUser(this.userModel, this.subjectsOptions);
    verify(this.userModel, times(1)).setSubjects(this.listCaptor.capture());
    Assert.assertSame(this.subjectsModels, this.listCaptor.getValue());
}
Also used : UserModelInterface(easytests.core.models.UserModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 28 with UserModelInterface

use of easytests.core.models.UserModelInterface in project easy-tests by malinink.

the class SubjectsServiceTest method testFindByUserAbsentList.

@Test
public void testFindByUserAbsentList() throws Exception {
    final UserModelInterface userModel = this.usersSupport.getModelFixtureMock(0);
    when(this.subjectsMapper.findByUserId(userModel.getId())).thenReturn(new ArrayList<>(0));
    final List<SubjectModelInterface> subjectsFoundedModels = this.subjectsService.findByUser(userModel);
    Assert.assertEquals(0, subjectsFoundedModels.size());
}
Also used : UserModelInterface(easytests.core.models.UserModelInterface) SubjectModelInterface(easytests.core.models.SubjectModelInterface)

Example 29 with UserModelInterface

use of easytests.core.models.UserModelInterface in project easy-tests by malinink.

the class UsersServiceTest method testDeleteUnidentifiedModelTrowsException.

@Test
public void testDeleteUnidentifiedModelTrowsException() throws Exception {
    final UserModelInterface userModel = this.usersSupport.getModelAdditionalMock(0);
    exception.expect(DeleteUnidentifiedModelException.class);
    this.usersService.delete(userModel);
}
Also used : UserModelInterface(easytests.core.models.UserModelInterface)

Example 30 with UserModelInterface

use of easytests.core.models.UserModelInterface in project easy-tests by malinink.

the class UsersServiceTest method testFindAbsentModel.

@Test
public void testFindAbsentModel() throws Exception {
    final Integer id = 10;
    final UserModelInterface userModel = this.usersService.find(id);
    Assert.assertEquals(null, userModel);
}
Also used : UserModelInterface(easytests.core.models.UserModelInterface) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test)

Aggregations

UserModelInterface (easytests.core.models.UserModelInterface)40 Test (org.junit.Test)11 SubjectModelInterface (easytests.core.models.SubjectModelInterface)9 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)9 UserEntity (easytests.core.entities.UserEntity)7 UsersOptionsInterface (easytests.core.options.UsersOptionsInterface)7 ArrayList (java.util.ArrayList)6 SubjectsServiceInterface (easytests.core.services.SubjectsServiceInterface)5 SubjectEntity (easytests.core.entities.SubjectEntity)3 UserModel (easytests.core.models.UserModel)3 UsersServiceInterface (easytests.core.services.UsersServiceInterface)2 InOrder (org.mockito.InOrder)2 UserModelDto (easytests.admin.dto.UserModelDto)1 IssueStandardModelInterface (easytests.core.models.IssueStandardModelInterface)1 SubjectModel (easytests.core.models.SubjectModel)1 ModelsListEmpty (easytests.core.models.empty.ModelsListEmpty)1 SubjectsOptionsInterface (easytests.core.options.SubjectsOptionsInterface)1 UsersOptions (easytests.core.options.UsersOptions)1 WebMvcTest (org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest)1