private ServiceModule createServiceModule(
      ServiceInfo serviceInfo, Collection<ConfigurationModule> configurations) {
    String serviceName = serviceInfo.getName();

    if (serviceInfo.getName() == null) {
      serviceInfo.setName("service1");
    }

    return createServiceModule(serviceInfo, configurations, createStackContext(serviceName, true));
  }
  @Test
  public void testServiceCheckRegistered() throws Exception {
    ServiceInfo info = new ServiceInfo();
    info.setName("service1");
    info.setCommandScript(createNiceMock(CommandScriptDefinition.class));

    StackContext context = createStackContext(info.getName(), true);
    ServiceModule service =
        createServiceModule(info, Collections.<ConfigurationModule>emptySet(), context);
    service.finalizeModule();

    verify(context);
  }
  private ServiceModule createServiceModule(
      ServiceInfo serviceInfo,
      Collection<ConfigurationModule> configurations,
      StackContext context) {

    if (serviceInfo.getName() == null) {
      serviceInfo.setName("service1");
    }

    ConfigurationDirectory configDirectory = createConfigurationDirectory(configurations);
    ServiceDirectory serviceDirectory =
        createServiceDirectory(serviceInfo.getConfigDir(), configDirectory);

    return createServiceModule(context, serviceInfo, serviceDirectory);
  }
  private ServiceModule createServiceModule(ServiceInfo serviceInfo) {
    String configType = "type1";

    if (serviceInfo.getName() == null) {
      serviceInfo.setName("service1");
    }

    StackContext context = createStackContext(serviceInfo.getName(), true);
    // no config props
    ConfigurationInfo configInfo =
        createConfigurationInfo(
            Collections.<PropertyInfo>emptyList(), Collections.<String, String>emptyMap());

    ConfigurationModule module = createConfigurationModule(configType, configInfo);
    ConfigurationDirectory configDirectory =
        createConfigurationDirectory(Collections.singletonList(module));
    ServiceDirectory serviceDirectory =
        createServiceDirectory(serviceInfo.getConfigDir(), configDirectory);

    return createServiceModule(context, serviceInfo, serviceDirectory);
  }