Search in sources :

Example 1 with UserModelInterface

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());
}
Also used : UserModelInterface(easytests.core.models.UserModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 2 with UserModelInterface

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

Example 3 with UserModelInterface

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

Example 4 with UserModelInterface

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

Example 5 with UserModelInterface

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

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