ServicesHelper { protected Map<String, String> getConnectorAttributes(List<AttributeDefinition> attributeDefinitions, Map<String, String> attributesFromInput) { HashMap<String, String> attributeMap = new HashMap<String, String>(); for (AttributeDefinition attributeDefinition : attributeDefinitions) { String fieldName = attributeDefinition.getName().getString(Locale.getDefault()); String description = attributeDefinition.getDescription().getString(Locale.getDefault()); String defaultValue = attributeDefinition.getDefaultValue().getString(Locale.getDefault()); String userValue; if (attributesFromInput.containsKey(attributeDefinition.getId())) { userValue = attributesFromInput.get(attributeDefinition.getId()); } else { OutputStreamFormater.printTabbedValues(9, String.format("\n%s", fieldName), String.format("%s (%s)", description, defaultValue)); if (!attributeDefinition.getOptions().isEmpty()) { userValue = letUserChooseFromOption(attributeDefinition.getOptions()); } else { userValue = readUserInput(); } if ("".equals(userValue) || "\n".equals(userValue)) { userValue = defaultValue; } } attributeMap.put(fieldName, userValue); } return attributeMap; } ServicesHelper(); void init(); void listRunningServices(); List<DomainProvider> getDomainProvider(); List<String> getDomainProviderNames(); void deleteService(String id, boolean force); List<String> getRunningServiceIds(); void createService(String domainProviderName, boolean force, Map<String, String> attributes); void setOsgiUtilsService(DefaultOsgiUtilsService osgiUtilsService); BundleContext getBundleContext(); void setBundleContext(BundleContext bundleContext);  }
@Test public void testGetConnectorAttributes_shouldReturnConnectorAttributes() throws Exception { Map<String, String> attributes = new HashMap<String, String>(); attributes.put("attr1", "val1"); attributes.put("attr2", "val2"); AttributeDefinition atr1 = createAttributeMock("attr1", "1"); AttributeDefinition atr2 = createAttributeMock("attr2", "2"); List<AttributeDefinition> attributeDefinitions = new ArrayList<AttributeDefinition>(); attributeDefinitions.add(atr1); attributeDefinitions.add(atr2); Map<String, String> connectorAttributes = serviceHelper.getConnectorAttributes(attributeDefinitions, attributes); assertTrue(connectorAttributes.get("name1").equals("val1")); assertTrue(connectorAttributes.get("name2").equals("val2")); }