congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
PolicyConfiguration$IncidentPreference
Code IndexAdd Tabnine to your IDE (free)

How to use
PolicyConfiguration$IncidentPreference
in
com.ocadotechnology.newrelic.alertsconfigurator.configuration

Best Java code snippets using com.ocadotechnology.newrelic.alertsconfigurator.configuration.PolicyConfiguration$IncidentPreference (Showing top 4 results out of 315)

origin: ocadotechnology/newrelic-alerts-configurator

  void sync(@NonNull PolicyConfiguration config) {
    LOG.info("Synchronizing policy {}...", config.getPolicyName());

    AlertsPolicy alertsPolicyFromConfig = AlertsPolicy.builder()
      .name(config.getPolicyName())
      .incidentPreference(config.getIncidentPreference().name())
      .build();

    Optional<AlertsPolicy> policy = api.getAlertsPoliciesApi().getByName(config.getPolicyName());

    if (policy.isPresent()) {
      AlertsPolicy oldPolicy = policy.get();
      if (!StringUtils.equals(alertsPolicyFromConfig.getIncidentPreference(), oldPolicy.getIncidentPreference())) {
        api.getAlertsPoliciesApi().delete(oldPolicy.getId());
        api.getAlertsPoliciesApi().create(alertsPolicyFromConfig);
        LOG.info(format("Policy %s updated", config.getPolicyName()));
      }
    } else {
      api.getAlertsPoliciesApi().create(alertsPolicyFromConfig);
      LOG.info("Policy {} created", config.getPolicyName());
    }
    LOG.info("Policy {} synchronized", config.getPolicyName());
  }
}
origin: ocadotechnology/newrelic-alerts-configurator

@Test
public void shouldDeleteAndCreateNewPolicy_whenPolicyUpdated() {
  // given
  when(alertsPoliciesApiMock.getByName(POLICY_NAME)).thenReturn(Optional.of(ALERT_POLICY_DIFFERENT));
  AlertsPolicy expectedPolicy = AlertsPolicy.builder().name(POLICY_NAME).incidentPreference(INCIDENT_PREFERENCE.name()).build();
  // when
  testee.sync(CONFIGURATION);
  // then
  InOrder order = inOrder(alertsPoliciesApiMock);
  order.verify(alertsPoliciesApiMock).getByName(POLICY_NAME);
  order.verify(alertsPoliciesApiMock).delete(ALERT_POLICY_DIFFERENT.getId());
  order.verify(alertsPoliciesApiMock).create(expectedPolicy);
  order.verifyNoMoreInteractions();
}
origin: ocadotechnology/newrelic-alerts-configurator

private static AlertsPolicy createAlertPolicy(int id, PolicyConfiguration.IncidentPreference incidentPreference) {
  return AlertsPolicy.builder().id(id).name(POLICY_NAME).incidentPreference(incidentPreference.name()).build();
}
origin: ocadotechnology/newrelic-alerts-configurator

@Test
public void shouldCreateNewPolicy_whenPolicyDoesNotExist() {
  // given
  when(alertsPoliciesApiMock.getByName(POLICY_NAME)).thenReturn(Optional.empty());
  AlertsPolicy expectedPolicy = AlertsPolicy.builder().name(POLICY_NAME).incidentPreference(INCIDENT_PREFERENCE.name()).build();
  // when
  testee.sync(CONFIGURATION);
  // then
  InOrder order = inOrder(alertsPoliciesApiMock);
  order.verify(alertsPoliciesApiMock).getByName(POLICY_NAME);
  order.verify(alertsPoliciesApiMock).create(expectedPolicy);
  order.verifyNoMoreInteractions();
}
com.ocadotechnology.newrelic.alertsconfigurator.configurationPolicyConfiguration$IncidentPreference

Most used methods

  • name

Popular in Java

  • Creating JSON documents from java classes using gson
  • onRequestPermissionsResult (Fragment)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • getApplicationContext (Context)
  • Kernel (java.awt.image)
  • BufferedWriter (java.io)
    Wraps an existing Writer and buffers the output. Expensive interaction with the underlying reader is
  • Proxy (java.net)
    This class represents proxy server settings. A created instance of Proxy stores a type and an addres
  • Locale (java.util)
    Locale represents a language/country/variant combination. Locales are used to alter the presentatio
  • JButton (javax.swing)
  • Logger (org.slf4j)
    The org.slf4j.Logger interface is the main user entry point of SLF4J API. It is expected that loggin
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now