use of com.mercedesbenz.sechub.sharedkernel.mapping.MappingData in project sechub by mercedes-benz.
the class CreateExampleJSONAdapterDialogAction method execute.
@Override
protected void execute(ActionEvent e) throws Exception {
boolean confirmed = getDialogUI().getContext().getDialogUI().confirm("Do you really want to replace your JSON data in text area with example code?");
if (!confirmed) {
getDialogUI().getContext().getOutputUI().output("Canceled by user");
return;
}
String exampleFound = getMappingUI().getData().example;
if (exampleFound != null) {
getMappingUI().setJSON(exampleFound);
} else {
MappingData data = new MappingData();
data.getEntries().add(new MappingEntry("pattern1", "replacement1", "comment1"));
data.getEntries().add(new MappingEntry("pattern2", "replacement2", "comment2"));
getMappingUI().setJSON(data.toJSON());
}
}
use of com.mercedesbenz.sechub.sharedkernel.mapping.MappingData in project sechub by mercedes-benz.
the class SaveJSONAdapterDialogAction method execute.
@Override
protected void execute(ActionEvent e) throws Exception {
DeveloperAdministration adm = getDialogUI().getContext().getAdministration();
String url = adm.getUrlBuilder().buildUpdateMapping(getMappingUI().getMappingId());
String json = getMappingUI().getJSON();
// just check json correct
MappingData data = MappingData.fromString(json);
int size = data.getEntries().size();
boolean confirmed = getDialogUI().getContext().getDialogUI().confirm("Do you really want to upload?\n\n" + size + " entries will be set!");
if (!confirmed) {
getDialogUI().getContext().getOutputUI().output(getClass().getSimpleName() + ":Canceled by user");
return;
}
adm.getRestHelper().putJSON(url, json);
getDialogUI().getContext().getOutputUI().output("Updated mapping:" + getMappingUI().getMappingId());
}
use of com.mercedesbenz.sechub.sharedkernel.mapping.MappingData in project sechub by mercedes-benz.
the class ScanMappingConfigurationTestJSONasNamePatternDialogAction method createScanConfig.
private ScanMappingConfiguration createScanConfig(String json, MappingIdentifier identifier) {
MappingData mappingData = MappingData.fromString(json);
ScanMapping mapping = new ScanMapping(identifier.getId());
mapping.setData(mappingData.toJSON());
ScanMappingConfiguration config = new ScanMappingToScanMappingConfigurationTransformer().transform(Collections.singletonList(mapping));
return config;
}
use of com.mercedesbenz.sechub.sharedkernel.mapping.MappingData in project sechub by mercedes-benz.
the class MappingDataValidationImplTest method having_2_mapping_entries_calls_and_two_good_than_valid.
@Test
public void having_2_mapping_entries_calls_and_two_good_than_valid() {
/* prepare */
MappingData data = new MappingData();
data.getEntries().add(entry1);
data.getEntries().add(entry2);
when(mappingEntryValidation.validate(any())).thenReturn(new ValidationResult());
/* execute +test */
assertTrue(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_and_entry2_bad_than_invalid.
@Test
public void having_2_mapping_entries_calls_and_entry2_bad_than_invalid() {
/* prepare */
MappingData data = new MappingData();
data.getEntries().add(entry1);
data.getEntries().add(entry2);
ValidationResult result1 = new ValidationResult();
ValidationResult result2 = new ValidationResult();
result2.addError("error1");
when(mappingEntryValidation.validate(entry1)).thenReturn(result1);
when(mappingEntryValidation.validate(entry2)).thenReturn(result2);
/* execute +test */
assertFalse(validationToTest.validate(data).isValid());
}
Aggregations