### Question:
ServiceModule extends BaseModule<ServiceModule, ServiceInfo> implements Validable { private void mergeServiceProperties(List<ServicePropertyInfo> other) { if (!other.isEmpty()) { List<ServicePropertyInfo> servicePropertyList = serviceInfo.getServicePropertyList(); List<ServicePropertyInfo> servicePropertiesToAdd = Lists.newArrayList(); Set<String> servicePropertyNames = Sets.newTreeSet( Iterables.transform(servicePropertyList, new Function<ServicePropertyInfo, String>() { @Nullable @Override public String apply(ServicePropertyInfo serviceProperty) { return serviceProperty.getName(); } }) ); for (ServicePropertyInfo otherServiceProperty : other) { if (!servicePropertyNames.contains(otherServiceProperty.getName())) servicePropertiesToAdd.add(otherServiceProperty); } List<ServicePropertyInfo> mergedServicePropertyList = ImmutableList.<ServicePropertyInfo>builder() .addAll(servicePropertyList) .addAll(servicePropertiesToAdd) .build(); serviceInfo.setServicePropertyList(mergedServicePropertyList); validateServiceInfo(); } } 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 testMergeServiceProperties() throws Exception { ServiceInfo serviceInfo = new ServiceInfo(); ServiceInfo parentServiceInfo = new ServiceInfo(); ServicePropertyInfo p1 = new ServicePropertyInfo(); p1.setName("P1"); p1.setValue("V1"); ServicePropertyInfo p2 = new ServicePropertyInfo(); p2.setName("P2"); p2.setValue("V2"); ServicePropertyInfo p2Override = new ServicePropertyInfo(); p2Override.setName("P2"); p2Override.setValue("V2_OVERRIDE"); ServicePropertyInfo p3 = new ServicePropertyInfo(); p3.setName("P3"); p3.setValue("V3"); List<ServicePropertyInfo> parentServicePropertyList = Lists.newArrayList(p1, p2); parentServiceInfo.setServicePropertyList(parentServicePropertyList); List<ServicePropertyInfo> servicePropertyList = Lists.newArrayList(p2Override, p3); serviceInfo.setServicePropertyList(servicePropertyList); ServiceModule serviceModule = resolveService(serviceInfo, parentServiceInfo); List<ServicePropertyInfo> expectedPropertyList = Lists.newArrayList(p1, p2Override, p3); Map<String, String> expectedServiceProperties = ImmutableMap.<String, String>builder() .put("P1", "V1") .put("P2", "V2_OVERRIDE") .put("P3", "V3") .put(ServiceInfo.DEFAULT_SERVICE_INSTALLABLE_PROPERTY) .put(ServiceInfo.DEFAULT_SERVICE_MANAGED_PROPERTY) .put(ServiceInfo.DEFAULT_SERVICE_MONITORED_PROPERTY) .build(); List<ServicePropertyInfo> actualPropertyList = serviceModule.getModuleInfo().getServicePropertyList(); assertTrue(actualPropertyList.containsAll(expectedPropertyList) && expectedPropertyList.containsAll(actualPropertyList)); assertEquals(expectedServiceProperties, serviceModule.getModuleInfo().getServiceProperties()); }