use of easytests.core.models.UserModelInterface in project easy-tests by malinink.
the class ObjectsControllerTest method testViewReturnsData.
@Test
public void testViewReturnsData() throws Exception {
final UserModelInterface userModel = this.usersSupport.getModelFixtureMock(0);
when(this.usersOptionsBuilder.forAuth()).thenReturn(new UsersOptions());
when(this.usersService.find(any(Integer.class), any(UsersOptionsInterface.class))).thenReturn(userModel);
mvc.perform(get("/v1/objects/1/").contentType(MediaType.APPLICATION_JSON)).andExpect(status().isOk()).andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)).andReturn();
}
use of easytests.core.models.UserModelInterface in project easy-tests by malinink.
the class UsersOptionsTest method testSaveWithRelations.
@Test
public void testSaveWithRelations() throws Exception {
final UserModelInterface userModel = Mockito.mock(UserModelInterface.class);
final UsersOptionsInterface usersOptions = new UsersOptions();
final UsersServiceInterface usersService = Mockito.mock(UsersServiceInterface.class);
final SubjectsServiceInterface subjectsService = Mockito.mock(SubjectsServiceInterface.class);
final SubjectsOptionsInterface subjectsOptions = Mockito.mock(SubjectsOptionsInterface.class);
usersOptions.setUsersService(usersService);
usersOptions.setSubjectsService(subjectsService);
usersOptions.withSubjects(subjectsOptions);
final List<SubjectModelInterface> subjectsModels = new ArrayList<>();
subjectsModels.add(Mockito.mock(SubjectModelInterface.class));
given(userModel.getSubjects()).willReturn(subjectsModels);
final InOrder inOrder = Mockito.inOrder(subjectsService, usersService);
usersOptions.saveWithRelations(userModel);
inOrder.verify(usersService).save(userModel);
inOrder.verify(subjectsService).save(subjectsModels, subjectsOptions);
}
use of easytests.core.models.UserModelInterface in project easy-tests by malinink.
the class UsersOptionsTest method testWithRelationsOnNull.
@Test
public void testWithRelationsOnNull() throws Exception {
final UserModelInterface userModel = null;
final UsersOptionsInterface usersOptions = new UsersOptions();
final SubjectsServiceInterface subjectsService = Mockito.mock(SubjectsServiceInterface.class);
final SubjectsOptionsInterface subjectsOptions = Mockito.mock(SubjectsOptionsInterface.class);
usersOptions.setSubjectsService(subjectsService);
usersOptions.withSubjects(subjectsOptions);
final UserModelInterface userModelWithRelations = usersOptions.withRelations(userModel);
Assert.assertEquals(null, userModelWithRelations);
}
use of easytests.core.models.UserModelInterface 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.models.UserModelInterface 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);
}
Aggregations