test_class.declarator: EXISTING = "existing"
test_class.modifier: private static final
test_class.original_string: private static final String EXISTING = "existing";
test_class.type: String
test_class.var_name: EXISTING
test_class.declarator: NOTIFY = "notify"
test_class.modifier: private static final
test_class.original_string: private static final String NOTIFY = "notify";
test_class.type: String
test_class.var_name: NOTIFY
test_class.declarator: CLOSE = "close"
test_class.modifier: private static final
test_class.original_string: private static final String CLOSE = "close";
test_class.type: String
test_class.var_name: CLOSE
test_class.declarator: NEW = "new"
test_class.modifier: private static final
test_class.original_string: private static final String NEW = "new";
test_class.type: String
test_class.var_name: NEW
test_class.declarator: OPEN = "open"
test_class.modifier: private static final
test_class.original_string: private static final String OPEN = "open";
test_class.type: String
test_class.var_name: OPEN
test_class.declarator: UNHEALTHY = "unhealthy"
test_class.modifier: private static final
test_class.original_string: private static final String UNHEALTHY = "unhealthy";
test_class.type: String
test_class.var_name: UNHEALTHY
test_class.declarator: evtUtil = mock(EventUtil.class)
test_class.modifier: private
test_class.original_string: private EventUtil evtUtil = mock(EventUtil.class);
test_class.type: EventUtil
test_class.var_name: evtUtil
test_class.declarator: opsEventListener = new OpsEventListener()
test_class.modifier: private
test_class.original_string: private OpsEventListener opsEventListener = new OpsEventListener();
test_class.type: OpsEventListener
test_class.var_name: opsEventListener
test_class.declarator: gson = new Gson()
test_class.original_string: Gson gson = new Gson();
test_class.type: Gson
test_class.var_name: gson
test_class.declarator: bsp = mock(BadStateProcessor.class)
test_class.original_string: BadStateProcessor bsp = mock(BadStateProcessor.class);
test_class.type: BadStateProcessor
test_class.var_name: bsp
test_class.declarator: epp = mock(EnvPropsProcessor.class)
test_class.original_string: EnvPropsProcessor epp = mock(EnvPropsProcessor.class);
test_class.type: EnvPropsProcessor
test_class.var_name: epp
test_class.declarator: notifier = mock(Notifications.class)
test_class.original_string: Notifications notifier = mock(Notifications.class);
test_class.type: Notifications
test_class.var_name: notifier
test_class.declarator: stateDao = mock(OpsCiStateDao.class)
test_class.original_string: OpsCiStateDao stateDao = mock(OpsCiStateDao.class);
test_class.type: OpsCiStateDao
test_class.var_name: stateDao
test_class.declarator: ciOpsProcessor = mock(CiOpsProcessor.class)
test_class.original_string: CiOpsProcessor ciOpsProcessor = mock(CiOpsProcessor.class);
test_class.type: CiOpsProcessor
test_class.var_name: ciOpsProcessor
test_class.file: opamp/src/test/java/com/oneops/opamp/jms/OpsEventListenerTest.java
test_class.identifier: OpsEventListenerTest
test_case.body: @Test
      public void testOnMessage()
      {
  
          String eventJson = makeJson(UNHEALTHY, "oldstate");
          String eventJson1 = makeJson(NOTIFY, "oldstate");
          String eventJson2 = makeJson("overutilized", "oldstate");
  
          String eventJson3 = makeJson("underutilized", "oldstate");
          String eventJson4 = makeJson("good", UNHEALTHY);
  
          String eventJson5 = makeJson("good", NOTIFY);
  
          TextMessage message = mock(TextMessage.class);
          evtUtil.setGson(new Gson());
          try
          {
              when(message.getStringProperty("type")).thenReturn("ci-change-state");
          }
          catch (JMSException e)
          {
              e.printStackTrace();
          }
  
          try
          {
              when(message.getText()).thenReturn(eventJson);
          }
          catch (JMSException e)
          {
              e.printStackTrace();
          }
  
          try
          {
              when(message.getText()).thenReturn(eventJson1);
          }
          catch (JMSException e)
          {
              e.printStackTrace();
          }
  
          opsEventListener.onMessage(message);
  
          try
          {
              when(message.getText()).thenReturn(eventJson2);
          }
          catch (JMSException e)
          {
              e.printStackTrace();
          }
          opsEventListener.onMessage(message);
          try
          {
              when(message.getText()).thenReturn(eventJson3);
          }
          catch (JMSException e)
          {
              e.printStackTrace();
          }
          opsEventListener.onMessage(message);
          try
          {
              when(message.getText()).thenReturn(eventJson4);
          }
          catch (JMSException e)
          {
              e.printStackTrace();
          }
          opsEventListener.onMessage(message);
          try
          {
              when(message.getText()).thenReturn(eventJson5);
          }
          catch (JMSException e)
          {
              e.printStackTrace();
          }
          opsEventListener.onMessage(message);
      }
test_case.class_method_signature: OpsEventListenerTest.testOnMessage()
test_case.full_signature: @Test public void testOnMessage()
test_case.identifier: testOnMessage
test_case.invocations: makeJson makeJson makeJson makeJson makeJson makeJson mock setGson thenReturn when getStringProperty printStackTrace thenReturn when getText printStackTrace thenReturn when getText printStackTrace onMessage thenReturn when getText printStackTrace onMessage thenReturn when getText printStackTrace onMessage thenReturn when getText printStackTrace onMessage thenReturn when getText printStackTrace onMessage
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testOnMessage()
focal_class.declarator: logger = Logger.getLogger(OpsEventListener.class)
focal_class.modifier: private static
focal_class.original_string: private static Logger logger = Logger.getLogger(OpsEventListener.class);
focal_class.type: Logger
focal_class.var_name: logger
focal_class.declarator: gson
focal_class.modifier: private
focal_class.original_string: private Gson gson;
focal_class.type: Gson
focal_class.var_name: gson
focal_class.declarator: notifier
focal_class.modifier: private
focal_class.original_string: private Notifications notifier;
focal_class.type: Notifications
focal_class.var_name: notifier
focal_class.declarator: bsProcessor
focal_class.modifier: private
focal_class.original_string: private BadStateProcessor bsProcessor;
focal_class.type: BadStateProcessor
focal_class.var_name: bsProcessor
focal_class.declarator: fsProcessor
focal_class.modifier: private
focal_class.original_string: private FlexStateProcessor fsProcessor;
focal_class.type: FlexStateProcessor
focal_class.var_name: fsProcessor
focal_class.declarator: envProcessor
focal_class.modifier: private
focal_class.original_string: private EnvPropsProcessor envProcessor;
focal_class.type: EnvPropsProcessor
focal_class.var_name: envProcessor
focal_class.declarator: opsCiStateDao
focal_class.modifier: private
focal_class.original_string: private OpsCiStateDao opsCiStateDao;
focal_class.type: OpsCiStateDao
focal_class.var_name: opsCiStateDao
focal_class.declarator: eventUtil
focal_class.modifier: private
focal_class.original_string: private EventUtil eventUtil;
focal_class.type: EventUtil
focal_class.var_name: eventUtil
focal_class.declarator: ciOpsProcessor
focal_class.modifier: private
focal_class.original_string: private CiOpsProcessor ciOpsProcessor;
focal_class.type: CiOpsProcessor
focal_class.var_name: ciOpsProcessor
focal_class.file: opamp/src/main/java/com/oneops/opamp/jms/OpsEventListener.java
focal_class.identifier: OpsEventListener
focal_class.interfaces: implements MessageListener
focal_class.class_method_signature: OpsEventListener.setFsProcessor(FlexStateProcessor fsProcessor)
focal_class.full_signature: public void setFsProcessor(FlexStateProcessor fsProcessor)
focal_class.identifier: setFsProcessor
focal_class.modifiers: public
focal_class.parameters: (FlexStateProcessor fsProcessor)
focal_class.return: void
focal_class.signature: void setFsProcessor(FlexStateProcessor fsProcessor)
focal_class.class_method_signature: OpsEventListener.setBsProcessor(BadStateProcessor bsProcessor)
focal_class.full_signature: public void setBsProcessor(BadStateProcessor bsProcessor)
focal_class.identifier: setBsProcessor
focal_class.modifiers: public
focal_class.parameters: (BadStateProcessor bsProcessor)
focal_class.return: void
focal_class.signature: void setBsProcessor(BadStateProcessor bsProcessor)
focal_class.class_method_signature: OpsEventListener.setEnvProcessor(EnvPropsProcessor envProcessor)
focal_class.full_signature: public void setEnvProcessor(EnvPropsProcessor envProcessor)
focal_class.identifier: setEnvProcessor
focal_class.modifiers: public
focal_class.parameters: (EnvPropsProcessor envProcessor)
focal_class.return: void
focal_class.signature: void setEnvProcessor(EnvPropsProcessor envProcessor)
focal_class.class_method_signature: OpsEventListener.getOpsCiStateDao()
focal_class.full_signature: public OpsCiStateDao getOpsCiStateDao()
focal_class.identifier: getOpsCiStateDao
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: OpsCiStateDao
focal_class.signature: OpsCiStateDao getOpsCiStateDao()
focal_class.class_method_signature: OpsEventListener.setOpsCiStateDao(OpsCiStateDao opsCiStateDao)
focal_class.full_signature: public void setOpsCiStateDao(OpsCiStateDao opsCiStateDao)
focal_class.identifier: setOpsCiStateDao
focal_class.modifiers: public
focal_class.parameters: (OpsCiStateDao opsCiStateDao)
focal_class.return: void
focal_class.signature: void setOpsCiStateDao(OpsCiStateDao opsCiStateDao)
focal_class.class_method_signature: OpsEventListener.setNotifier(Notifications notifier)
focal_class.full_signature: public void setNotifier(Notifications notifier)
focal_class.identifier: setNotifier
focal_class.modifiers: public
focal_class.parameters: (Notifications notifier)
focal_class.return: void
focal_class.signature: void setNotifier(Notifications notifier)
focal_class.class_method_signature: OpsEventListener.setGson(Gson gson)
focal_class.full_signature: public void setGson(Gson gson)
focal_class.identifier: setGson
focal_class.modifiers: public
focal_class.parameters: (Gson gson)
focal_class.return: void
focal_class.signature: void setGson(Gson gson)
focal_class.class_method_signature: OpsEventListener.onMessage(Message msg)
focal_class.full_signature: public void onMessage(Message msg)
focal_class.identifier: onMessage
focal_class.modifiers: public
focal_class.parameters: (Message msg)
focal_class.return: void
focal_class.signature: void onMessage(Message msg)
focal_class.class_method_signature: OpsEventListener.getEventUtil()
focal_class.full_signature: public EventUtil getEventUtil()
focal_class.identifier: getEventUtil
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: EventUtil
focal_class.signature: EventUtil getEventUtil()
focal_class.class_method_signature: OpsEventListener.setEventUtil(EventUtil eventUtil)
focal_class.full_signature: public void setEventUtil(EventUtil eventUtil)
focal_class.identifier: setEventUtil
focal_class.modifiers: public
focal_class.parameters: (EventUtil eventUtil)
focal_class.return: void
focal_class.signature: void setEventUtil(EventUtil eventUtil)
focal_class.class_method_signature: OpsEventListener.getCiOpsProcessor()
focal_class.full_signature: public CiOpsProcessor getCiOpsProcessor()
focal_class.identifier: getCiOpsProcessor
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: CiOpsProcessor
focal_class.signature: CiOpsProcessor getCiOpsProcessor()
focal_class.class_method_signature: OpsEventListener.setCiOpsProcessor(CiOpsProcessor ciOpsProcessor)
focal_class.full_signature: public void setCiOpsProcessor(CiOpsProcessor ciOpsProcessor)
focal_class.identifier: setCiOpsProcessor
focal_class.modifiers: public
focal_class.parameters: (CiOpsProcessor ciOpsProcessor)
focal_class.return: void
focal_class.signature: void setCiOpsProcessor(CiOpsProcessor ciOpsProcessor)
focal_method.body: public void onMessage(Message msg) {
      try {
  
        logger.debug(msg);
  
        if (!envProcessor.isOpAmpSuspended() && (msg instanceof TextMessage)) {
          envProcessor.refreshMdCache();
          try {
            String type = msg.getStringProperty("type");
  
            if ("ci-change-state".equals(type)) {
              CiChangeStateEvent event = gson
                  .fromJson(((TextMessage) msg).getText(), CiChangeStateEvent.class);
  
              eventUtil.addCloudName(event, envProcessor.fetchDeployedToRelations(event.getCiId()));
  
              OpsBaseEvent opsEvent = eventUtil.getOpsEvent(event);
              long manifestId = opsEvent.getManifestId();
              List<Long> manifestIds = new ArrayList<>();
              manifestIds.add(manifestId);
              Map<String, Integer> counters = ciOpsProcessor.getManifestStates(manifestIds)
                  .get(manifestId);
              if (counters != null) {
                logger.info("component level state counters for bom cid " + event.getCiId() + ": "
                    + counters);
                event.setComponentStatesCounters(counters);
              } else {
                logger.warn("state counters found null for " + event.getCiId());
              }
  
              boolean isNewState =
                  (event.getNewState() != null) && (!event.getNewState().equals(event.getOldState()));
  
              //Changed to pass the ChangeEvent context event
              if (event.getPayLoad() != null && event.getNewState().equals(event.getOldState())
                  && opsEvent.getState().equalsIgnoreCase("close")) {
                //this is the situation when one threshold got cleared but
                //the ci state didn't changed b/c of other threshold is still violated
                //we just need to send the notification.
                logger.info(
                    "sendingOpsCloseEventNotification for cid: " + event.getCiId() + " " + opsEvent
                        .getSource() + " status " + opsEvent.getStatus() + " ostate:"
                        + event.getOldState() + " nstate: " + event.getNewState());
                notifier.sendOpsEventNotification(event);
              } else if ("unhealthy".equals(event.getNewState())) {
                if (opsEvent != null && opsEvent.getType() != null
                    && "heartbeat".equals(opsEvent.getType())
                    && envProcessor.isHeartbeatAlarmSuspended()) {
                  logger.warn("Heartbeat alarms suppressed. "
                      + "No notifications/auto-repair/auto-replace will be performed for missing heartbeats");
                } else {
                  bsProcessor.processUnhealthyState(event);
                }
              } else if ("overutilized".equals(event.getNewState())) {
                fsProcessor.processOverutilized(event, isNewState);
              } else if ("underutilized".equals(event.getNewState())) {
                fsProcessor.processUnderutilized(event, isNewState, event.getTimestamp());
              } else if (event.getPayLoad() != null && "notify".equals(event.getNewState())
                  && eventUtil.shouldNotify(event, opsEvent)) {
                //skip the notification in case payload is null
                notifier.sendOpsEventNotification(event);
              } else if ("defunct".equals(event.getNewState())) {
                bsProcessor.processDefunctState(event);
              } else if ("good".equals(event.getNewState()) && "unhealthy"
                  .equals(event.getOldState())) {
                logger.info(
                    "sending good notification for cid: " + event.getCiId() + " " + (opsEvent != null
                        ? opsEvent.getSource() : "") + " status " + (opsEvent != null ? opsEvent
                        .getStatus() : "") + " ostate:"
                        + event.getOldState() + " nstate: " + event.getNewState());
                bsProcessor.processGoodState(event);
              } else if (event.getPayLoad() != null && "good".equals(event.getNewState())
                  && "notify"
                  .equals(event.getOldState())) {//skip the notification in case payload is null
                logger.info("sending recoverynotification for cid: " + event.getCiId() + " " + (
                    opsEvent != null ? opsEvent.getSource() : "") + " status " + (opsEvent != null
                    ? opsEvent.getStatus() : "") + " ostate:"
                    + event.getOldState() + " nstate: " + event.getNewState());
                notifier.sendOpsEventNotification(event);
              }
            }
          } catch (OpsException opse) {
            logger.error("OpsException in onMessage", opse);
          } catch (OpampException e) {
            logger.error("The message could not be processed " + msg);
            logger.error("OpampException in onMessage", e);
          }
        }
        msg.acknowledge();
      } catch (JMSException e) {
        logger.error("Exception occured while proccesing the message" + msg, e);
      }
    }
focal_method.class_method_signature: OpsEventListener.onMessage(Message msg)
focal_method.full_signature: public void onMessage(Message msg)
focal_method.identifier: onMessage
focal_method.invocations: debug isOpAmpSuspended refreshMdCache getStringProperty equals fromJson getText addCloudName fetchDeployedToRelations getCiId getOpsEvent getManifestId add get getManifestStates info getCiId setComponentStatesCounters warn getCiId getNewState equals getNewState getOldState getPayLoad equals getNewState getOldState equalsIgnoreCase getState info getCiId getSource getStatus getOldState getNewState sendOpsEventNotification equals getNewState getType equals getType isHeartbeatAlarmSuspended warn processUnhealthyState equals getNewState processOverutilized equals getNewState processUnderutilized getTimestamp getPayLoad equals getNewState shouldNotify sendOpsEventNotification equals getNewState processDefunctState equals getNewState equals getOldState info getCiId getSource getStatus getOldState getNewState processGoodState getPayLoad equals getNewState equals getOldState info getCiId getSource getStatus getOldState getNewState sendOpsEventNotification error error error acknowledge error
focal_method.modifiers: public
focal_method.parameters: (Message msg)
focal_method.return: void
focal_method.signature: void onMessage(Message msg)