test_class.declarator: ngsiClient
test_class.modifier: @Mock(answer = Answers.RETURNS_MOCKS)
      public
test_class.original_string: @Mock(answer = Answers.RETURNS_MOCKS)
      public NgsiClient ngsiClient;
test_class.type: NgsiClient
test_class.var_name: ngsiClient
test_class.declarator: statement
test_class.modifier: @Mock
      public
test_class.original_string: @Mock
      public EPStatement statement;
test_class.type: EPStatement
test_class.var_name: statement
test_class.declarator: provider
test_class.modifier: @Mock
      public
test_class.original_string: @Mock
      public EPServiceProvider provider;
test_class.type: EPServiceProvider
test_class.var_name: provider
test_class.declarator: eventSinkListener
test_class.modifier: @Autowired
      @InjectMocks
      public
test_class.original_string: @Autowired
      @InjectMocks
      public EventSinkListener eventSinkListener;
test_class.type: EventSinkListener
test_class.var_name: eventSinkListener
test_class.declarator: broker
test_class.modifier: private
test_class.original_string: private Broker broker;
test_class.type: Broker
test_class.var_name: broker
test_class.file: cepheus-cep/src/test/java/com/orange/cepheus/cep/EventSinkListenerTest.java
test_class.identifier: EventSinkListenerTest
test_case.body: @Test
      public void noUpdateOnRemovedEventBeans() {
  
          when(statement.getText()).thenReturn("statement");
  
          // Trigger remove event update
          List<ContextAttribute> attributes = new LinkedList<>();
          attributes.add(new ContextAttribute("id", "string", null)); // null => when statement does not indicate id
          attributes.add(new ContextAttribute("avgTemp", "double", 10.25));
          EventBean[]beans = {buildEventBean("TempSensorAvg", attributes)};
          eventSinkListener.update(null, beans, statement, provider);
  
          verify(ngsiClient, never()).updateContext(any(), any(), any());
      }
test_case.class_method_signature: EventSinkListenerTest.noUpdateOnRemovedEventBeans()
test_case.full_signature: @Test public void noUpdateOnRemovedEventBeans()
test_case.identifier: noUpdateOnRemovedEventBeans
test_case.invocations: thenReturn when getText add add buildEventBean update updateContext verify never any any any
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void noUpdateOnRemovedEventBeans()
focal_class.declarator: logger = LoggerFactory.getLogger(EventSinkListener.class)
focal_class.modifier: private static
focal_class.original_string: private static Logger logger = LoggerFactory.getLogger(EventSinkListener.class);
focal_class.type: Logger
focal_class.var_name: logger
focal_class.declarator: ngsiClient
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private NgsiClient ngsiClient;
focal_class.type: NgsiClient
focal_class.var_name: ngsiClient
focal_class.declarator: eventMapper
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private EventMapper eventMapper;
focal_class.type: EventMapper
focal_class.var_name: eventMapper
focal_class.declarator: configuration
focal_class.modifier: private
focal_class.original_string: private Configuration configuration;
focal_class.type: Configuration
focal_class.var_name: configuration
focal_class.declarator: outgoingEvents
focal_class.modifier: private
focal_class.original_string: private Map<String, EventTypeOut> outgoingEvents;
focal_class.type: Map<String, EventTypeOut>
focal_class.var_name: outgoingEvents
focal_class.file: cepheus-cep/src/main/java/com/orange/cepheus/cep/EventSinkListener.java
focal_class.identifier: EventSinkListener
focal_class.interfaces: implements StatementAwareUpdateListener
focal_class.class_method_signature: EventSinkListener.update(EventBean[] added, EventBean[] removed, EPStatement epStatement, EPServiceProvider epServiceProvider)
focal_class.full_signature: @Override public void update(EventBean[] added, EventBean[] removed, EPStatement epStatement, EPServiceProvider epServiceProvider)
focal_class.identifier: update
focal_class.modifiers: @Override public
focal_class.parameters: (EventBean[] added, EventBean[] removed, EPStatement epStatement, EPServiceProvider epServiceProvider)
focal_class.return: void
focal_class.signature: void update(EventBean[] added, EventBean[] removed, EPStatement epStatement, EPServiceProvider epServiceProvider)
focal_class.class_method_signature: EventSinkListener.setConfiguration(Configuration configuration)
focal_class.full_signature: public void setConfiguration(Configuration configuration)
focal_class.identifier: setConfiguration
focal_class.modifiers: public
focal_class.parameters: (Configuration configuration)
focal_class.return: void
focal_class.signature: void setConfiguration(Configuration configuration)
focal_class.class_method_signature: EventSinkListener.getEventTypeOut(String eventBeanType)
focal_class.full_signature: private EventTypeOut getEventTypeOut(String eventBeanType)
focal_class.identifier: getEventTypeOut
focal_class.modifiers: private
focal_class.parameters: (String eventBeanType)
focal_class.return: EventTypeOut
focal_class.signature: EventTypeOut getEventTypeOut(String eventBeanType)
focal_class.class_method_signature: EventSinkListener.buildUpdateContextRequest(EventBean eventBean, EventTypeOut eventTypeOut)
focal_class.full_signature: private UpdateContext buildUpdateContextRequest(EventBean eventBean, EventTypeOut eventTypeOut)
focal_class.identifier: buildUpdateContextRequest
focal_class.modifiers: private
focal_class.parameters: (EventBean eventBean, EventTypeOut eventTypeOut)
focal_class.return: UpdateContext
focal_class.signature: UpdateContext buildUpdateContextRequest(EventBean eventBean, EventTypeOut eventTypeOut)
focal_class.class_method_signature: EventSinkListener.getHeadersForBroker(Broker broker)
focal_class.full_signature: private HttpHeaders getHeadersForBroker(Broker broker)
focal_class.identifier: getHeadersForBroker
focal_class.modifiers: private
focal_class.parameters: (Broker broker)
focal_class.return: HttpHeaders
focal_class.signature: HttpHeaders getHeadersForBroker(Broker broker)
focal_method.body: @Override
      public void update(EventBean[] added, EventBean[] removed, EPStatement epStatement, EPServiceProvider epServiceProvider) {
  
          // ignore updates for removed events
          if (added == null) {
              return;
          }
  
          for (EventBean eventBean : added) {
  
              // Debug some information about the event
              if (logger.isInfoEnabled()) {
                  StringBuilder sb = new StringBuilder();
                  for (String propertyName : eventBean.getEventType().getPropertyNames()) {
                      sb.append(" / ").append(propertyName).append(':').append(eventBean.get(propertyName));
                  }
                  logger.info("EventOut: {}{} from {}", eventBean.getEventType().getName(), sb.toString(), epStatement.getText());
              }
  
              // Send updateContext requests to each broker
              final String type = eventBean.getEventType().getName();
              final EventTypeOut eventTypeOut = getEventTypeOut(type);
              if (eventTypeOut == null) {
                  logger.debug("EventTypeOut {} doesn't exist in Configuration, updateContext not sent", type);
              } else {
                  UpdateContext updateContext = buildUpdateContextRequest(eventBean, eventTypeOut);
                  if (updateContext != null) {
                      for (Broker broker : eventTypeOut.getBrokers()) {
                          assert broker != null;
                          HttpHeaders httpHeaders = getHeadersForBroker(broker);
                          ngsiClient.updateContext(broker.getUrl(), httpHeaders, updateContext).addCallback(
                                  updateContextResponse ->
                                      logger.debug("UpdateContext completed for {}", broker.getUrl()),
                                  throwable ->
                                      logger.warn("UpdateContext failed for {}", broker.getUrl(), throwable)
                          );
                      }
                  }
              }
          }
      }
focal_method.class_method_signature: EventSinkListener.update(EventBean[] added, EventBean[] removed, EPStatement epStatement, EPServiceProvider epServiceProvider)
focal_method.full_signature: @Override public void update(EventBean[] added, EventBean[] removed, EPStatement epStatement, EPServiceProvider epServiceProvider)
focal_method.identifier: update
focal_method.invocations: isInfoEnabled getPropertyNames getEventType append append append append get info getName getEventType toString getText getName getEventType getEventTypeOut debug buildUpdateContextRequest getBrokers getHeadersForBroker addCallback updateContext getUrl debug getUrl warn getUrl
focal_method.modifiers: @Override public
focal_method.parameters: (EventBean[] added, EventBean[] removed, EPStatement epStatement, EPServiceProvider epServiceProvider)
focal_method.return: void
focal_method.signature: void update(EventBean[] added, EventBean[] removed, EPStatement epStatement, EPServiceProvider epServiceProvider)