Ejemplo n.º 1
0
 @Test
 public void importCreatedShouldEmitSuccessfully() throws Exception {
   Owner owner = new Owner("Import guy");
   eventSinkImpl.emitImportCreated(owner);
   eventSinkImpl.sendEvents();
   verify(mockClientProducer).send(any(ClientMessage.class));
 }
Ejemplo n.º 2
0
 @Test
 public void rulesDeletedShouldEmitSuccessfully() throws Exception {
   Rules oldRules = new Rules(TestUtil.createRulesBlob(1));
   eventSinkImpl.emitRulesDeleted(oldRules);
   eventSinkImpl.sendEvents();
   verify(mockClientProducer).send(any(ClientMessage.class));
 }
Ejemplo n.º 3
0
 @Test
 public void emptyKeyShouldEmitSuccessfully() throws Exception {
   ActivationKey key = TestUtil.createActivationKey(new Owner("deadbeef"), null);
   eventSinkImpl.emitActivationKeyCreated(key);
   eventSinkImpl.sendEvents();
   verify(mockClientProducer).send(any(ClientMessage.class));
 }
Ejemplo n.º 4
0
 @Test
 public void exportCreatedShouldEmitSuccessfully() throws Exception {
   Consumer consumer = TestUtil.createConsumer();
   eventSinkImpl.emitExportCreated(consumer);
   eventSinkImpl.sendEvents();
   verify(mockClientProducer).send(any(ClientMessage.class));
 }
Ejemplo n.º 5
0
 @Test
 public void poolCreatedShouldEmitSuccessfully() throws Exception {
   Pool pool = TestUtil.createPool(o, TestUtil.createProduct(o));
   eventSinkImpl.emitPoolCreated(pool);
   eventSinkImpl.sendEvents();
   verify(mockClientProducer).send(any(ClientMessage.class));
 }
Ejemplo n.º 6
0
 @Test
 public void keyWithPoolsShouldEmitSuccessfully() throws Exception {
   ArrayList<Pool> pools = new ArrayList<Pool>();
   pools.add(TestUtil.createPool(o, TestUtil.createProduct(o)));
   pools.add(TestUtil.createPool(o, TestUtil.createProduct(o)));
   ActivationKey key = TestUtil.createActivationKey(new Owner("deadbeef"), pools);
   eventSinkImpl.emitActivationKeyCreated(key);
   eventSinkImpl.sendEvents();
   verify(mockClientProducer).send(any(ClientMessage.class));
 }
Ejemplo n.º 7
0
 @Test
 public void sendEventShouldSendMessageOnProperEventInput() throws Exception {
   final String content = "Simple String";
   doReturn(content).when(mapper).writeValueAsString(anyObject());
   ArgumentCaptor<ClientMessage> argumentCaptor = ArgumentCaptor.forClass(ClientMessage.class);
   eventSinkImpl.queueEvent(mock(Event.class));
   eventSinkImpl.sendEvents();
   verify(mockClientProducer).send(argumentCaptor.capture());
   assertEquals(content, argumentCaptor.getValue().getBodyBuffer().readString());
 }
Ejemplo n.º 8
0
  /**
   * @return
   * @throws Exception
   */
  private EventSinkImpl createEventSink(final ClientSessionFactory sessionFactory)
      throws Exception {
    EventSinkImpl sink =
        new EventSinkImpl(eventFilter, factory, mapper, new CandlepinCommonTestConfig()) {

          @Override
          protected ClientSessionFactory createClientSessionFactory() {
            return sessionFactory;
          }
        };
    sink.initialize();
    return sink;
  }
Ejemplo n.º 9
0
  @Test
  public void sendEventShouldNotFailWhenObjectMapperThrowsException() throws Exception {
    doThrow(new JsonGenerationException("Nothing serious!")).when(mapper).writeValueAsString(any());
    Event event = mock(Event.class);

    eventSinkImpl.queueEvent(event);
    verify(mockClientProducer, never()).send(any(ClientMessage.class));
  }
Ejemplo n.º 10
0
 @Test
 public void ownerCreatedShouldEmitSuccessfully() throws Exception {
   eventSinkImpl.emitOwnerCreated(o);
   eventSinkImpl.sendEvents();
   verify(mockClientProducer).send(any(ClientMessage.class));
 }