@Override
  public void enableControllerService(final ControllerService service) {
    final ControllerServiceConfiguration configuration =
        context.getConfiguration(service.getIdentifier());
    if (configuration == null) {
      throw new IllegalArgumentException("Controller Service " + service + " is not known");
    }

    if (configuration.isEnabled()) {
      throw new IllegalStateException(
          "Cannot enable Controller Service " + service + " because it is not disabled");
    }

    try {
      final ConfigurationContext configContext =
          new MockConfigurationContext(service, configuration.getProperties(), context);
      ReflectionUtils.invokeMethodsWithAnnotation(OnEnabled.class, service, configContext);
    } catch (final InvocationTargetException ite) {
      ite.getCause().printStackTrace();
      Assert.fail("Failed to enable Controller Service " + service + " due to " + ite.getCause());
    } catch (final Exception e) {
      e.printStackTrace();
      Assert.fail("Failed to enable Controller Service " + service + " due to " + e);
    }

    configuration.setEnabled(true);
  }
  @Override
  public boolean isControllerServiceEnabled(final ControllerService service) {
    final ControllerServiceConfiguration configuration =
        context.getConfiguration(service.getIdentifier());
    if (configuration == null) {
      throw new IllegalArgumentException("Controller Service " + service + " is not known");
    }

    return configuration.isEnabled();
  }
  private ControllerServiceConfiguration getConfigToUpdate(final ControllerService service) {
    final ControllerServiceConfiguration configuration =
        context.getConfiguration(service.getIdentifier());
    if (configuration == null) {
      throw new IllegalArgumentException("Controller Service " + service + " is not known");
    }

    if (configuration.isEnabled()) {
      throw new IllegalStateException(
          "Controller service " + service + " cannot be modified because it is not disabled");
    }

    return configuration;
  }
  @Override
  public void disableControllerService(final ControllerService service) {
    final ControllerServiceConfiguration configuration =
        context.getConfiguration(service.getIdentifier());
    if (configuration == null) {
      throw new IllegalArgumentException("Controller Service " + service + " is not known");
    }

    if (!configuration.isEnabled()) {
      throw new IllegalStateException(
          "Controller service " + service + " cannot be disabled because it is not enabled");
    }

    try {
      ReflectionUtils.invokeMethodsWithAnnotation(OnDisabled.class, service);
    } catch (final Exception e) {
      e.printStackTrace();
      Assert.fail("Failed to disable Controller Service " + service + " due to " + e);
    }

    configuration.setEnabled(false);
  }