use of com.mercedesbenz.sechub.sharedkernel.mapping.MappingEntry in project sechub by mercedes-benz.
the class MappingDataValidationImpl method validate.
@Override
protected void validate(ValidationContext<MappingData> context) {
validateNotNull(context);
MappingData data = context.objectToValidate;
for (MappingEntry entry : data.getEntries()) {
ValidationResult result = mappingEntryValidation.validate(entry);
if (result.isValid()) {
continue;
}
addErrorMessage(context, result.getErrorDescription());
}
}
use of com.mercedesbenz.sechub.sharedkernel.mapping.MappingEntry in project sechub by mercedes-benz.
the class MappingDataCSVSupportTest method to_csv_test.
@Test
public void to_csv_test() {
MappingData data = new MappingData();
data.getEntries().add(new MappingEntry("pattern1", "replacement1", "comment1"));
data.getEntries().add(new MappingEntry("pattern2", "replacement2", "comment2"));
/* execute */
List<CSVRow> result = supportToTest.toCSVRows(data);
/* test */
// always with headlines
assertEquals(3, result.size());
int row = 0;
CSVRow headline = result.get(row++);
CSVRow row1 = result.get(row++);
CSVRow row2 = result.get(row++);
int col = 0;
assertEquals(3, headline.columns.size());
assertEquals(3, row1.columns.size());
assertEquals(3, row2.columns.size());
assertEquals("Pattern", headline.columns.get(col).cell);
assertEquals("pattern1", row1.columns.get(col).cell);
assertEquals("pattern2", row2.columns.get(col++).cell);
assertEquals("Replacement", headline.columns.get(col).cell);
assertEquals("replacement1", row1.columns.get(col).cell);
assertEquals("replacement2", row2.columns.get(col++).cell);
assertEquals("Comment", headline.columns.get(col).cell);
assertEquals("comment1", row1.columns.get(col).cell);
assertEquals("comment2", row2.columns.get(col).cell);
}
use of com.mercedesbenz.sechub.sharedkernel.mapping.MappingEntry in project sechub by mercedes-benz.
the class MappingDataCSVSupportTest method from_csv_test_no_headline.
@Test
public void from_csv_test_no_headline() {
/* prepare */
MappingData expected = new MappingData();
expected.getEntries().add(new MappingEntry("pattern1", "replacement1", "comment1"));
expected.getEntries().add(new MappingEntry("pattern2", "replacement2", "comment2"));
List<CSVRow> rows = new ArrayList<>();
CSVRow row1 = new CSVRow();
row1.add("pattern1");
row1.add("replacement1");
row1.add("comment1");
CSVRow row2 = new CSVRow();
row2.add("pattern2");
row2.add("replacement2");
row2.add("comment2");
rows.add(row1);
rows.add(row2);
/* execute */
MappingData result = supportToTest.fromCSVRows(rows, 0);
/* prepare */
assertEquals(expected.toJSON(), result.toJSON());
}
use of com.mercedesbenz.sechub.sharedkernel.mapping.MappingEntry in project sechub by mercedes-benz.
the class MappingScenario1IntTest method update_mapping_is_possible.
@Test
public void update_mapping_is_possible() {
/* prepare */
MappingData mappingData = new MappingData();
MappingEntry entry = new MappingEntry("pattern1", "replacement1", System.currentTimeMillis() + "");
mappingData.getEntries().add(entry);
/* execute */
as(SUPER_ADMIN).updateMapping(TEST_UPDATE_MAPPING_ID, mappingData);
/* test */
assertUser(SUPER_ADMIN).canGetMapping(TEST_UPDATE_MAPPING_ID).contains(entry);
}
use of com.mercedesbenz.sechub.sharedkernel.mapping.MappingEntry in project sechub by mercedes-benz.
the class TestAPI method waitForScanConfigRefresh.
/**
* Changes a value inside scan config and wait until this value has been
* reloaded
*/
public static void waitForScanConfigRefresh() {
LOG.debug("start wait for scan config refresh");
String newValue = "" + System.nanoTime();
MappingEntry entry = new MappingEntry("value", newValue, "just for integrationtest refresh");
/* direct change necessary - to avoid filtering if this special entry */
changeScanMappingDirectly(INTEGRATIONTEST_CHECK_SCANCONFIG_REFRESH_PROVIDERID, entry);
String id = null;
while (id == null || !(id.equals(newValue))) {
LOG.info("Waiting for scan config refresh");
waitMilliSeconds(1000);
id = getIdForNameByNamePatternProvider(INTEGRATIONTEST_CHECK_SCANCONFIG_REFRESH_PROVIDERID, "value");
}
}
Aggregations