### Question:
ServiceModule extends BaseModule<ServiceModule, ServiceInfo> implements Validable { @Override public void finalizeModule() { finalizeChildModules(configurationModules.values()); finalizeChildModules(componentModules.values()); finalizeConfiguration(); if(serviceInfo.getCommandScript() != null && ! isDeleted()) { stackContext.registerServiceCheck(getId()); } } ServiceModule(StackContext stackContext, ServiceInfo serviceInfo, ServiceDirectory serviceDirectory);  ServiceModule(
      StackContext stackContext, ServiceInfo serviceInfo, ServiceDirectory serviceDirectory, boolean isCommonService); @Override ServiceInfo getModuleInfo(); @Override void resolve(
      ServiceModule parentModule, Map<String, StackModule> allStacks, Map<String, ServiceModule> commonServices, Map<String, ExtensionModule> extensions); void resolveExplicit(
      ServiceModule parentModule, Map<String, StackModule> allStacks, Map<String, ServiceModule> commonServices, Map<String, ExtensionModule> extensions); void resolveInternal(
      ServiceModule parentModule, Map<String, StackModule> allStacks, Map<String, ServiceModule> commonServices,
      Map<String, ExtensionModule> extensions, boolean resolveExplicit); void resolveCommonService(Map<String, StackModule> allStacks, Map<String, ServiceModule> commonServices, Map<String, ExtensionModule> extensions); @Override boolean isDeleted(); @Override String getId(); @Override void finalizeModule(); @Override boolean isValid(); @Override void setValid(boolean valid); @Override void addError(String error); @Override Collection<String> getErrors(); ServiceDirectory getServiceDirectory(); @Override void addErrors(Collection<String> errors); boolean hasConfigs(); @Override String toString();  }### Answer:
@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.emptySet(), context); service.finalizeModule(); verify(context); }
@Test public void testServiceCheckNotRegisteredForDeletedService() throws Exception { ServiceInfo info = new ServiceInfo(); info.setName("service1"); info.setCommandScript(createNiceMock(CommandScriptDefinition.class)); info.setDeleted(true); StackContext context = createStackContext(info.getName(), false); ServiceModule service = createServiceModule(info, Collections.emptySet(), context); service.finalizeModule(); verify(context); }