MAProductionType extends HadoopProductionType { static MAConfig.VariableMapping[] parseVariableMappings(String variableMappingsString) { if ( StringUtils.isNullOrEmpty(variableMappingsString)) { return null; } String[] mappings = variableMappingsString.split(","); List<MAConfig.VariableMapping> mappingList = new ArrayList<>(mappings.length); for (String mapping : mappings) { String[] refSat = mapping.split("="); if (refSat.length == 2) { String ref = refSat[0].trim(); String sat = refSat[1].trim(); if (!ref.isEmpty() && !sat.isEmpty()) { mappingList.add(new MAConfig.VariableMapping(ref, sat)); } } } if (mappingList.isEmpty()) { return null; } return mappingList.toArray(new MAConfig.VariableMapping[mappingList.size()]); } MAProductionType(FileSystemService fileSystemService, HadoopProcessingService processingService,
                     StagingService stagingService); @Override Production createProduction(ProductionRequest productionRequest);  }
@Test public void testParseVariableMappings() throws Exception { assertNull(MAProductionType.parseVariableMappings(null)); assertNull(MAProductionType.parseVariableMappings("")); assertNull(MAProductionType.parseVariableMappings("ref")); assertNull(MAProductionType.parseVariableMappings("ref=")); assertNull(MAProductionType.parseVariableMappings("ref1,ref2")); MAConfig.VariableMapping[] mappings = MAProductionType.parseVariableMappings("r1=s1"); assertNotNull(mappings); assertEquals(1, mappings.length); assertEquals("r1", mappings[0].getReference()); assertEquals("s1", mappings[0].getSatellite()); mappings = MAProductionType.parseVariableMappings("r1=s1,r2=s2"); assertNotNull(mappings); assertEquals(2, mappings.length); assertEquals("r1", mappings[0].getReference()); assertEquals("s1", mappings[0].getSatellite()); assertEquals("r2", mappings[1].getReference()); assertEquals("s2", mappings[1].getSatellite()); }