use of org.candlepin.service.UserServiceAdapter in project candlepin by candlepin.
the class DefaultUserServiceAdapterTest method findByLogin.
@Test
public void findByLogin() {
User u = mock(User.class);
UserCurator curator = mock(UserCurator.class);
RoleCurator roleCurator = mock(RoleCurator.class);
UserServiceAdapter dusa = new DefaultUserServiceAdapter(curator, roleCurator);
when(curator.findByLogin(anyString())).thenReturn(u);
User foo = dusa.findByLogin("foo");
assertNotNull(foo);
assertEquals(foo, u);
}
use of org.candlepin.service.UserServiceAdapter in project candlepin by candlepin.
the class ConsumerResourceTest method testNullPerson.
@Test(expected = NotFoundException.class)
public void testNullPerson() {
Owner owner = this.createOwner();
ConsumerType ctype = this.mockConsumerType(new ConsumerType(ConsumerTypeEnum.PERSON));
ConsumerTypeDTO ctypeDto = this.translator.translate(ctype, ConsumerTypeDTO.class);
Consumer consumer = this.createConsumer(owner, ctype);
ConsumerDTO consumerDto = this.translator.translate(consumer, ConsumerDTO.class);
UserServiceAdapter usa = mock(UserServiceAdapter.class);
UserPrincipal up = mock(UserPrincipal.class);
when(up.canAccess(eq(owner), eq(SubResource.CONSUMERS), eq(Access.CREATE))).thenReturn(true);
// usa.findByLogin() will return null by default no need for a when
ConsumerResource cr = new ConsumerResource(mockConsumerCurator, mockConsumerTypeCurator, null, null, null, null, null, null, i18n, null, null, null, null, usa, null, null, mockOwnerCurator, null, null, null, null, null, null, this.config, null, null, null, consumerBindUtil, null, null, this.factValidator, null, consumerEnricher, migrationProvider, translator);
cr.create(consumerDto, up, null, owner.getKey(), null, true);
}
Aggregations