Tabnine Logo
PolicyConfiguration$IncidentPreference.name
Code IndexAdd Tabnine to your IDE (free)

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

Best Java code snippets using com.ocadotechnology.newrelic.alertsconfigurator.configuration.PolicyConfiguration$IncidentPreference.name (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 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();
}
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();
}
com.ocadotechnology.newrelic.alertsconfigurator.configurationPolicyConfiguration$IncidentPreferencename

Popular methods of PolicyConfiguration$IncidentPreference

    Popular in Java

    • Reading from database using SQL prepared statement
    • setContentView (Activity)
    • scheduleAtFixedRate (Timer)
    • setScale (BigDecimal)
    • Component (java.awt)
      A component is an object having a graphical representation that can be displayed on the screen and t
    • Socket (java.net)
      Provides a client-side TCP socket.
    • SocketException (java.net)
      This SocketException may be thrown during socket creation or setting options, and is the superclass
    • MessageDigest (java.security)
      Uses a one-way hash function to turn an arbitrary number of bytes into a fixed-length byte sequence.
    • Timestamp (java.sql)
      A Java representation of the SQL TIMESTAMP type. It provides the capability of representing the SQL
    • CountDownLatch (java.util.concurrent)
      A synchronization aid that allows one or more threads to wait until a set of operations being perfor
    • From CI to AI: The AI layer in your organization
    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