test_class.declarator: metric = new MetricRegistry()
test_class.modifier: @Spy
      private
test_class.original_string: @Spy
      private MetricRegistry metric = new MetricRegistry();
test_class.type: MetricRegistry
test_class.var_name: metric
test_class.declarator: service = new HTTPMsgService(metric)
test_class.modifier: @InjectMocks
      private
test_class.original_string: @InjectMocks
      private HTTPMsgService service = new HTTPMsgService(metric);
test_class.type: HTTPMsgService
test_class.var_name: service
test_class.file: antenna/src/test/java/com/oneops/antenna/senders/generic/HTTPMsgServiceTest.java
test_class.identifier: HTTPMsgServiceTest
test_case.body: @Test
      public void testEmailNotification() {
          URLSubscriber sub = new URLSubscriber();
          sub.setUserName("admin");
          sub.setUrl("http://localhost:8018/");
          sub.setPassword("****");
          NotificationMessage n = new NotificationMessage();
          n.setSeverity(info);
          n.setNsPath("/testing/rel0402/testmon/bom/tom/1");
          n.setCmsId(20401024);
          n.setSubject("TEST :ci:artifact-app-3529131-1; Procedure ci_repair complete");
          n.setSource("procedure");
          n.setTimestamp(1405569317585l);
          n.setType(ci);
          n.setText("Assembly: rel0402; Environment: testmon; ci:artifact-app-3529131-1; " +
                  "Procedure ci_repair complete!");
          assertFalse(service.postMessage(n, sub));
      }
test_case.class_method_signature: HTTPMsgServiceTest.testEmailNotification()
test_case.full_signature: @Test public void testEmailNotification()
test_case.identifier: testEmailNotification
test_case.invocations: setUserName setUrl setPassword setSeverity setNsPath setCmsId setSubject setSource setTimestamp setType setText assertFalse postMessage
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testEmailNotification()
focal_class.declarator: logger = Logger.getLogger(HTTPMsgService.class)
focal_class.modifier: private static
focal_class.original_string: private static Logger logger = Logger.getLogger(HTTPMsgService.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: metrics
focal_class.modifier: private final
focal_class.original_string: private final MetricRegistry metrics;
focal_class.type: MetricRegistry
focal_class.var_name: metrics
focal_class.declarator: http
focal_class.modifier: private
focal_class.original_string: private Meter http;
focal_class.type: Meter
focal_class.var_name: http
focal_class.declarator: httpErr
focal_class.modifier: private
focal_class.original_string: private Meter httpErr;
focal_class.type: Meter
focal_class.var_name: httpErr
focal_class.declarator: hpom
focal_class.modifier: private
focal_class.original_string: private Meter hpom;
focal_class.type: Meter
focal_class.var_name: hpom
focal_class.declarator: hpomErr
focal_class.modifier: private
focal_class.original_string: private Meter hpomErr;
focal_class.type: Meter
focal_class.var_name: hpomErr
focal_class.file: antenna/src/main/java/com/oneops/antenna/senders/generic/HTTPMsgService.java
focal_class.identifier: HTTPMsgService
focal_class.interfaces: implements NotificationSender
focal_class.class_method_signature: HTTPMsgService.HTTPMsgService(MetricRegistry metrics)
focal_class.full_signature: @Autowired public  HTTPMsgService(MetricRegistry metrics)
focal_class.identifier: HTTPMsgService
focal_class.modifiers: @Autowired public
focal_class.parameters: (MetricRegistry metrics)
focal_class.signature:  HTTPMsgService(MetricRegistry metrics)
focal_class.class_method_signature: HTTPMsgService.init()
focal_class.full_signature: @PostConstruct public void init()
focal_class.identifier: init
focal_class.modifiers: @PostConstruct public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void init()
focal_class.class_method_signature: HTTPMsgService.postMessage(NotificationMessage msg, BasicSubscriber sub)
focal_class.full_signature: @Override public boolean postMessage(NotificationMessage msg, BasicSubscriber sub)
focal_class.identifier: postMessage
focal_class.modifiers: @Override public
focal_class.parameters: (NotificationMessage msg, BasicSubscriber sub)
focal_class.return: boolean
focal_class.signature: boolean postMessage(NotificationMessage msg, BasicSubscriber sub)
focal_class.class_method_signature: HTTPMsgService.countOK(boolean isHpom)
focal_class.full_signature: private void countOK(boolean isHpom)
focal_class.identifier: countOK
focal_class.modifiers: private
focal_class.parameters: (boolean isHpom)
focal_class.return: void
focal_class.signature: void countOK(boolean isHpom)
focal_class.class_method_signature: HTTPMsgService.countErr(boolean isHpom)
focal_class.full_signature: private void countErr(boolean isHpom)
focal_class.identifier: countErr
focal_class.modifiers: private
focal_class.parameters: (boolean isHpom)
focal_class.return: void
focal_class.signature: void countErr(boolean isHpom)
focal_method.body: @Override
      public boolean postMessage(NotificationMessage msg, BasicSubscriber sub) {
          URLSubscriber urlSub = (URLSubscriber) sub;
          boolean isHpom = urlSub.hasHpomXfmr();
  
          CloseableHttpClient httpClient = HttpClients.createDefault();
  
          HttpPost req = new HttpPost(urlSub.getUrl());
          req.setEntity(new StringEntity(gson.toJson(msg), ContentType.APPLICATION_JSON));
  
          int timeout = urlSub.getTimeout();
          req.setConfig(RequestConfig.custom().setSocketTimeout(timeout > 0 ? timeout : 2000).build());
          String userName = urlSub.getUserName();
          if (userName != null && StringUtils.isNotEmpty(userName) && StringUtils.isNotEmpty(urlSub.getPassword()) ) {
              String auth = userName + ":" + urlSub.getPassword();
              req.addHeader(HttpHeaders.AUTHORIZATION, "Basic " + new String(Base64.encodeBase64(auth.getBytes())));
          }
  
          try (CloseableHttpResponse res = httpClient.execute(req)) {
              if (res.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
                  countOK(isHpom);
                  return true;
              } else {
                  logger.warn(isHpom ? "HPOM" : "HTTP" + " message post response code: "
                          + res.getStatusLine().getStatusCode()
                          + " for URL sink: "
                          + urlSub.getName());
              }
          } catch (IOException ex) {
              logger.error(isHpom ? "HPOM" : "HTTP" + " message post failed." + ex.getMessage());
          }
  
          countErr(isHpom);
          return false;
      }
focal_method.class_method_signature: HTTPMsgService.postMessage(NotificationMessage msg, BasicSubscriber sub)
focal_method.full_signature: @Override public boolean postMessage(NotificationMessage msg, BasicSubscriber sub)
focal_method.identifier: postMessage
focal_method.invocations: hasHpomXfmr createDefault getUrl setEntity toJson getTimeout setConfig build setSocketTimeout custom getUserName isNotEmpty isNotEmpty getPassword getPassword addHeader encodeBase64 getBytes execute getStatusCode getStatusLine countOK warn getStatusCode getStatusLine getName error getMessage countErr
focal_method.modifiers: @Override public
focal_method.parameters: (NotificationMessage msg, BasicSubscriber sub)
focal_method.return: boolean
focal_method.signature: boolean postMessage(NotificationMessage msg, BasicSubscriber sub)