@Test public void testNormalizeNotCovered() throws Throwable { myLog.debug( "testing given fieldnames do not cover all configured mappings" ); TestUtils.addToEnvironment( myEnv, "inputcollector.thing.alternateName", "Screenname" ); myClassUnderTest.normalize( new ArrayList<>() ); }
public Map<String,String> normalize( Collection<String> aFieldnames ) throws SdiException { Map<String,String> configuredReplaceMap = new HashMap<String,String>(); for ( String key : PersonKey.getKeyNames() ) { String keyName = InputCollectorMappingProperties.KEY_PREFIX + key; String configuredMapping = myEnv.getProperty( keyName ); if ( !StringUtils.hasText( configuredMapping ) ) { continue; } configuredMapping = configuredMapping.trim(); myLog.debug( "Found input collector mapping: " + keyName + " -> " + configuredMapping ); configuredReplaceMap.put( configuredMapping, key ); } Map<String,String> result = new HashMap<>(); for ( String collectedFieldName : aFieldnames ) { String normalized = null; if ( configuredReplaceMap.containsKey( collectedFieldName ) ) { normalized = configuredReplaceMap.remove( collectedFieldName ); myLog.debug( "Normalizing collected fieldname " + collectedFieldName + " by " + normalized ); } else { if ( !PersonKey.getKeyNames().contains( collectedFieldName ) ) { throw new SdiException( "Given fieldname \"" + collectedFieldName + "\" not configured for " + "normalizing", SdiException.EXIT_CODE_CONFIG_ERROR ); } myLog.debug( "Given fieldname " + collectedFieldName + " already normalized" ); normalized = collectedFieldName; } result.put( collectedFieldName, normalized ); } if ( !configuredReplaceMap.isEmpty() ) { myLog.warn( "At least one configured input collector mapping not contained in" + " given input list: " + configuredReplaceMap.values() ); } myLog.debug( "Normalized field names: " + result ); return result; }
FieldnameNormalizer { public Map<String,String> normalize( Collection<String> aFieldnames ) throws SdiException { Map<String,String> configuredReplaceMap = new HashMap<String,String>(); for ( String key : PersonKey.getKeyNames() ) { String keyName = InputCollectorMappingProperties.KEY_PREFIX + key; String configuredMapping = myEnv.getProperty( keyName ); if ( !StringUtils.hasText( configuredMapping ) ) { continue; } configuredMapping = configuredMapping.trim(); myLog.debug( "Found input collector mapping: " + keyName + " -> " + configuredMapping ); configuredReplaceMap.put( configuredMapping, key ); } Map<String,String> result = new HashMap<>(); for ( String collectedFieldName : aFieldnames ) { String normalized = null; if ( configuredReplaceMap.containsKey( collectedFieldName ) ) { normalized = configuredReplaceMap.remove( collectedFieldName ); myLog.debug( "Normalizing collected fieldname " + collectedFieldName + " by " + normalized ); } else { if ( !PersonKey.getKeyNames().contains( collectedFieldName ) ) { throw new SdiException( "Given fieldname \"" + collectedFieldName + "\" not configured for " + "normalizing", SdiException.EXIT_CODE_CONFIG_ERROR ); } myLog.debug( "Given fieldname " + collectedFieldName + " already normalized" ); normalized = collectedFieldName; } result.put( collectedFieldName, normalized ); } if ( !configuredReplaceMap.isEmpty() ) { myLog.warn( "At least one configured input collector mapping not contained in" + " given input list: " + configuredReplaceMap.values() ); } myLog.debug( "Normalized field names: " + result ); return result; } }
FieldnameNormalizer { public Map<String,String> normalize( Collection<String> aFieldnames ) throws SdiException { Map<String,String> configuredReplaceMap = new HashMap<String,String>(); for ( String key : PersonKey.getKeyNames() ) { String keyName = InputCollectorMappingProperties.KEY_PREFIX + key; String configuredMapping = myEnv.getProperty( keyName ); if ( !StringUtils.hasText( configuredMapping ) ) { continue; } configuredMapping = configuredMapping.trim(); myLog.debug( "Found input collector mapping: " + keyName + " -> " + configuredMapping ); configuredReplaceMap.put( configuredMapping, key ); } Map<String,String> result = new HashMap<>(); for ( String collectedFieldName : aFieldnames ) { String normalized = null; if ( configuredReplaceMap.containsKey( collectedFieldName ) ) { normalized = configuredReplaceMap.remove( collectedFieldName ); myLog.debug( "Normalizing collected fieldname " + collectedFieldName + " by " + normalized ); } else { if ( !PersonKey.getKeyNames().contains( collectedFieldName ) ) { throw new SdiException( "Given fieldname \"" + collectedFieldName + "\" not configured for " + "normalizing", SdiException.EXIT_CODE_CONFIG_ERROR ); } myLog.debug( "Given fieldname " + collectedFieldName + " already normalized" ); normalized = collectedFieldName; } result.put( collectedFieldName, normalized ); } if ( !configuredReplaceMap.isEmpty() ) { myLog.warn( "At least one configured input collector mapping not contained in" + " given input list: " + configuredReplaceMap.values() ); } myLog.debug( "Normalized field names: " + result ); return result; }  }
FieldnameNormalizer { public Map<String,String> normalize( Collection<String> aFieldnames ) throws SdiException { Map<String,String> configuredReplaceMap = new HashMap<String,String>(); for ( String key : PersonKey.getKeyNames() ) { String keyName = InputCollectorMappingProperties.KEY_PREFIX + key; String configuredMapping = myEnv.getProperty( keyName ); if ( !StringUtils.hasText( configuredMapping ) ) { continue; } configuredMapping = configuredMapping.trim(); myLog.debug( "Found input collector mapping: " + keyName + " -> " + configuredMapping ); configuredReplaceMap.put( configuredMapping, key ); } Map<String,String> result = new HashMap<>(); for ( String collectedFieldName : aFieldnames ) { String normalized = null; if ( configuredReplaceMap.containsKey( collectedFieldName ) ) { normalized = configuredReplaceMap.remove( collectedFieldName ); myLog.debug( "Normalizing collected fieldname " + collectedFieldName + " by " + normalized ); } else { if ( !PersonKey.getKeyNames().contains( collectedFieldName ) ) { throw new SdiException( "Given fieldname \"" + collectedFieldName + "\" not configured for " + "normalizing", SdiException.EXIT_CODE_CONFIG_ERROR ); } myLog.debug( "Given fieldname " + collectedFieldName + " already normalized" ); normalized = collectedFieldName; } result.put( collectedFieldName, normalized ); } if ( !configuredReplaceMap.isEmpty() ) { myLog.warn( "At least one configured input collector mapping not contained in" + " given input list: " + configuredReplaceMap.values() ); } myLog.debug( "Normalized field names: " + result ); return result; }  Map<String,String> normalize( Collection<String> aFieldnames ); }
FieldnameNormalizer { public Map<String,String> normalize( Collection<String> aFieldnames ) throws SdiException { Map<String,String> configuredReplaceMap = new HashMap<String,String>(); for ( String key : PersonKey.getKeyNames() ) { String keyName = InputCollectorMappingProperties.KEY_PREFIX + key; String configuredMapping = myEnv.getProperty( keyName ); if ( !StringUtils.hasText( configuredMapping ) ) { continue; } configuredMapping = configuredMapping.trim(); myLog.debug( "Found input collector mapping: " + keyName + " -> " + configuredMapping ); configuredReplaceMap.put( configuredMapping, key ); } Map<String,String> result = new HashMap<>(); for ( String collectedFieldName : aFieldnames ) { String normalized = null; if ( configuredReplaceMap.containsKey( collectedFieldName ) ) { normalized = configuredReplaceMap.remove( collectedFieldName ); myLog.debug( "Normalizing collected fieldname " + collectedFieldName + " by " + normalized ); } else { if ( !PersonKey.getKeyNames().contains( collectedFieldName ) ) { throw new SdiException( "Given fieldname \"" + collectedFieldName + "\" not configured for " + "normalizing", SdiException.EXIT_CODE_CONFIG_ERROR ); } myLog.debug( "Given fieldname " + collectedFieldName + " already normalized" ); normalized = collectedFieldName; } result.put( collectedFieldName, normalized ); } if ( !configuredReplaceMap.isEmpty() ) { myLog.warn( "At least one configured input collector mapping not contained in" + " given input list: " + configuredReplaceMap.values() ); } myLog.debug( "Normalized field names: " + result ); return result; }  Map<String,String> normalize( Collection<String> aFieldnames );  }