ConnectorFile { public ChangeSet getChanges(File file) { ImmutableMap<String, String> newPropertyMap = readProperties(file); MapDifference<String, String> changedAttributes = Maps.difference(attributes, getAttributesFromMap(newPropertyMap)); MapDifference<String, Object> changedProperties = Maps.difference(properties, getPropertiesFromMap(newPropertyMap)); return new ChangeSet(newPropertyMap.get("domainType"), newPropertyMap.get("connectorType"), changedAttributes, changedProperties); } ConnectorFile(File connectorFile); ChangeSet getChanges(File file); void update(File file); Properties toProperties(); static Boolean isRootService(File connectorFile); String getName(); String getDomainType(); String getConnectorType(); ImmutableMap<String, String> getAttributes(); ImmutableMap<String, Object> getProperties();  }
@Test public void testUpdateAddNewProperty_shouldShowChangedValueInResult() throws Exception { FileUtils.writeLines(connectorFile, Arrays.asList("domainType=d", "connectorType=c", "property.foo=bar,42")); ConnectorFile fileObject = new ConnectorFile(connectorFile); FileUtils.writeLines(connectorFile, Arrays.asList("property.foo=bar,42", "property.test=xxx")); ChangeSet update = fileObject.getChanges(connectorFile); update.getChangedProperties().entriesOnlyOnRight().containsKey("test"); }
@Test public void testChangeProperty_shouldShowChangedValueInResult() throws Exception { FileUtils.writeLines(connectorFile, Arrays.asList("domainType=d", "connectorType=c", "property.foo=bar")); ConnectorFile fileObject = new ConnectorFile(connectorFile); FileUtils.writeLines(connectorFile, Arrays.asList("domainType=d", "connectorType=c", "property.foo=bar,42")); ChangeSet update = fileObject.getChanges(connectorFile); update.getChangedProperties().entriesOnlyOnRight().containsKey("test"); }