use of com.mercedesbenz.sechub.sharedkernel.mapping.MappingData in project sechub by mercedes-benz.
the class MappingDataValidationImplTest method having_2_mapping_entries_calls_and_none_good_than_invalid.
@Test
public void having_2_mapping_entries_calls_and_none_good_than_invalid() {
/* prepare */
MappingData data = new MappingData();
data.getEntries().add(entry1);
data.getEntries().add(entry2);
ValidationResult result1 = new ValidationResult();
result1.addError("error1");
ValidationResult result2 = new ValidationResult();
result1.addError("error2");
when(mappingEntryValidation.validate(entry1)).thenReturn(result1);
when(mappingEntryValidation.validate(entry2)).thenReturn(result2);
/* execute +test */
assertFalse(validationToTest.validate(data).isValid());
}
use of com.mercedesbenz.sechub.sharedkernel.mapping.MappingData in project sechub by mercedes-benz.
the class MappingDataValidationImplTest method having_2_mapping_entries_calls_map_entry_validation_two_times.
@Test
public void having_2_mapping_entries_calls_map_entry_validation_two_times() {
/* prepare */
MappingData data = new MappingData();
data.getEntries().add(entry1);
data.getEntries().add(entry2);
when(mappingEntryValidation.validate(any())).thenReturn(new ValidationResult());
/* execute */
validationToTest.validate(data);
/* test */
verify(mappingEntryValidation).validate(entry1);
verify(mappingEntryValidation).validate(entry2);
}
use of com.mercedesbenz.sechub.sharedkernel.mapping.MappingData in project sechub by mercedes-benz.
the class ImportCSVToJSONAdapterDialogAction method execute.
@Override
protected void execute(ActionEvent e) throws Exception {
/* select */
String defaultPath = ConfigurationSetup.SECHUB_MASS_OPERATION_PARENTDIRECTORY.getStringValue(System.getProperty("user.home"));
String mappingId = getMappingUI().getMappingId();
File defaultFile = new File(defaultPath, mappingId + ".csv");
File file = getDialogUI().getContext().getDialogUI().selectFile(defaultFile.getAbsolutePath());
if (file == null) {
return;
}
if (!file.getName().equals(defaultFile.getName())) {
boolean confirmed = getDialogUI().getContext().getDialogUI().confirm("File name not as expected - is mappingId:" + mappingId + " really saved inside " + file.getName() + " ?");
if (!confirmed) {
getDialogUI().getContext().getOutputUI().output("Canceled by user");
return;
}
}
/* import */
SimpleCSVImporter importer = new SimpleCSVImporter();
List<CSVRow> rows = importer.importCSVFile(file, 3, 1);
/* convert */
MappingData data = csvSupport.fromCSVRows(rows, 0);
String json = data.toJSON();
/* output beautified */
getMappingUI().setJSON(JSONDeveloperHelper.INSTANCE.beatuifyJSON(json));
/* inform */
getDialogUI().getContext().getOutputUI().output("Imported from CSV file:" + file.getAbsolutePath());
}
use of com.mercedesbenz.sechub.sharedkernel.mapping.MappingData in project sechub by mercedes-benz.
the class MappingDataToNamePatternToIdEntryConverterTest method one_mapping_containing_one_entry_transformed_to_config.
@Test
public void one_mapping_containing_one_entry_transformed_to_config() {
/* prepare */
MappingData mapping1 = createMapping(new MappingEntry("pattern1", "replacement1", "comment1"));
/* execute */
List<NamePatternToIdEntry> namePatternList = converterToTest.convert(mapping1);
/* test */
assertNotNull(namePatternList);
assertEquals(1, namePatternList.size());
assertEquals(1, namePatternList.size());
NamePatternToIdEntry first = namePatternList.get(0);
assertEquals("pattern1", first.getNamePattern());
assertEquals("replacement1", first.getId());
}
use of com.mercedesbenz.sechub.sharedkernel.mapping.MappingData in project sechub by mercedes-benz.
the class ScanMappingToScanMappingConfigurationTransformerTest method one_mapping_containing_one_entry_transformed_to_config.
@Test
public void one_mapping_containing_one_entry_transformed_to_config() {
/* prepare */
MappingData data = createMappingData(new MappingEntry("x", "y", "z"));
ScanMapping mapping1 = createMapping("id1", data);
when(converter.convert(any())).thenReturn(Arrays.asList(new NamePatternToIdEntry("pattern1", "replacement1")));
/* execute */
ScanMappingConfiguration result = transformerToTest.transform(Collections.singletonList(mapping1));
/* test */
assertNotNull(result);
assertEquals(1, result.getNamePatternMappings().size());
List<NamePatternToIdEntry> namePatternList = result.getNamePatternMappings().get("id1");
assertEquals(1, namePatternList.size());
NamePatternToIdEntry first = namePatternList.get(0);
assertEquals("pattern1", first.getNamePattern());
assertEquals("replacement1", first.getId());
}
Aggregations