@Test public void two_mappings_containing_four_entries_transformed_to_config() { ScanMapping mapping1 = createMapping("id1",new MappingEntry("pattern1","replacement1","comment1"),new MappingEntry("pattern2","replacement2","comment2")); ScanMapping mapping2 = createMapping("id2",new MappingEntry("pattern3","replacement3",null),new MappingEntry("pattern4","replacement4",null)); List<ScanMapping> list = new ArrayList<>(); list.add(mapping1); list.add(mapping2); ScanConfig result = transformerToTest.transform(list); assertNotNull(result); assertEquals(2, result.getNamePatternMappings().size()); List<NamePatternToIdEntry> namePatternList1 = result.getNamePatternMappings().get("id1"); assertEquals(2,namePatternList1.size()); NamePatternToIdEntry first = namePatternList1.get(0); assertEquals("pattern1", first.getNamePattern()); assertEquals("replacement1", first.getId()); NamePatternToIdEntry second = namePatternList1.get(1); assertEquals("pattern2", second.getNamePattern()); assertEquals("replacement2", second.getId()); List<NamePatternToIdEntry> namePatternList2 = result.getNamePatternMappings().get("id2"); assertEquals(2,namePatternList2.size()); NamePatternToIdEntry first2 = namePatternList2.get(0); assertEquals("pattern3", first2.getNamePattern()); assertEquals("replacement3", first2.getId()); NamePatternToIdEntry second2 = namePatternList2.get(1); assertEquals("pattern4", second2.getNamePattern()); assertEquals("replacement4", second2.getId()); }
public ScanConfig transform(List<ScanMapping> mappings) { ScanConfig config = new ScanConfig(); if (mappings==null || mappings.size()==0) { return config; } for (ScanMapping mapping: mappings) { MappingData data = MappingData.fromString(mapping.getData()); config.getNamePatternMappings().put(mapping.getId(), convert(data)); } return config; }
ScanMappingToScanConfigTransformer { public ScanConfig transform(List<ScanMapping> mappings) { ScanConfig config = new ScanConfig(); if (mappings==null || mappings.size()==0) { return config; } for (ScanMapping mapping: mappings) { MappingData data = MappingData.fromString(mapping.getData()); config.getNamePatternMappings().put(mapping.getId(), convert(data)); } return config; } }
ScanMappingToScanConfigTransformer { public ScanConfig transform(List<ScanMapping> mappings) { ScanConfig config = new ScanConfig(); if (mappings==null || mappings.size()==0) { return config; } for (ScanMapping mapping: mappings) { MappingData data = MappingData.fromString(mapping.getData()); config.getNamePatternMappings().put(mapping.getId(), convert(data)); } return config; }  }
ScanMappingToScanConfigTransformer { public ScanConfig transform(List<ScanMapping> mappings) { ScanConfig config = new ScanConfig(); if (mappings==null || mappings.size()==0) { return config; } for (ScanMapping mapping: mappings) { MappingData data = MappingData.fromString(mapping.getData()); config.getNamePatternMappings().put(mapping.getId(), convert(data)); } return config; }  ScanConfig transform(List<ScanMapping> mappings); }
ScanMappingToScanConfigTransformer { public ScanConfig transform(List<ScanMapping> mappings) { ScanConfig config = new ScanConfig(); if (mappings==null || mappings.size()==0) { return config; } for (ScanMapping mapping: mappings) { MappingData data = MappingData.fromString(mapping.getData()); config.getNamePatternMappings().put(mapping.getId(), convert(data)); } return config; }  ScanConfig transform(List<ScanMapping> mappings);  }