Search in sources :

Example 1 with PrincipalProvider

use of org.candlepin.guice.PrincipalProvider in project candlepin by candlepin.

the class EventFactoryTest method init.

@Before
public void init() throws Exception {
    principalProvider = mock(PrincipalProvider.class);
    Principal principal = mock(Principal.class);
    when(principalProvider.get()).thenReturn(principal);
    eventFactory = new EventFactory(principalProvider);
}
Also used : PrincipalProvider(org.candlepin.guice.PrincipalProvider) Principal(org.candlepin.auth.Principal) Before(org.junit.Before)

Example 2 with PrincipalProvider

use of org.candlepin.guice.PrincipalProvider in project candlepin by candlepin.

the class EventBuilderTest method init.

@Before
public void init() throws Exception {
    principalProvider = mock(PrincipalProvider.class);
    Principal principal = mock(Principal.class);
    factory = new EventFactory(principalProvider);
    when(principalProvider.get()).thenReturn(principal);
}
Also used : PrincipalProvider(org.candlepin.guice.PrincipalProvider) Principal(org.candlepin.auth.Principal) Before(org.junit.Before)

Example 3 with PrincipalProvider

use of org.candlepin.guice.PrincipalProvider in project candlepin by candlepin.

the class AMQPBusPublisherTest method onEvent.

@Test
public void onEvent() throws JMSException {
    PrincipalProvider pp = mock(PrincipalProvider.class);
    when(pp.get()).thenReturn(TestUtil.createPrincipal("admin", null, null));
    EventFactory factory = new EventFactory(pp);
    Consumer c = TestUtil.createConsumer();
    Event e = factory.consumerCreated(c);
    publisher.onEvent(e);
    verify(qpid).sendTextMessage(Mockito.eq(Target.CONSUMER), Mockito.eq(Type.CREATED), Mockito.contains("TestConsumer"));
}
Also used : PrincipalProvider(org.candlepin.guice.PrincipalProvider) Consumer(org.candlepin.model.Consumer) Test(org.junit.Test)

Example 4 with PrincipalProvider

use of org.candlepin.guice.PrincipalProvider in project candlepin by candlepin.

the class AMQPBusPublisherTest method testApply.

@Test
public void testApply() throws IOException {
    PrincipalProvider pp = mock(PrincipalProvider.class);
    when(pp.get()).thenReturn(TestUtil.createPrincipal("admin", null, null));
    EventFactory factory = new EventFactory(pp);
    Consumer c = TestUtil.createConsumer();
    Event e = factory.consumerCreated(c);
    String value = publisher.apply(e);
    Event e1 = mapper.readValue(value, Event.class);
    assertEquals(e.getType(), e1.getType());
    assertEquals(e.getTarget(), e1.getTarget());
}
Also used : PrincipalProvider(org.candlepin.guice.PrincipalProvider) Consumer(org.candlepin.model.Consumer) Test(org.junit.Test)

Aggregations

PrincipalProvider (org.candlepin.guice.PrincipalProvider)4 Principal (org.candlepin.auth.Principal)2 Consumer (org.candlepin.model.Consumer)2 Before (org.junit.Before)2 Test (org.junit.Test)2