use of com.mercedesbenz.sechub.sharedkernel.mapping.MappingData in project sechub by mercedes-benz.
the class ScanConfigTestJSONasNamePatternDialogAction method createScanConfig.
private ScanConfig createScanConfig(String json, MappingIdentifier identifier) {
MappingData mappingData = MappingData.fromString(json);
ScanMapping mapping = new ScanMapping(identifier.getId());
mapping.setData(mappingData.toJSON());
ScanConfig config = new ScanMappingToScanConfigTransformer().transform(Collections.singletonList(mapping));
return config;
}
use of com.mercedesbenz.sechub.sharedkernel.mapping.MappingData in project sechub by mercedes-benz.
the class ScanMappingToScanConfigTransformerTest 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 */
ScanConfig 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());
}
use of com.mercedesbenz.sechub.sharedkernel.mapping.MappingData in project sechub by mercedes-benz.
the class ScanMappingToScanConfigTransformer method transform.
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(), converter.convert(data));
}
return config;
}
use of com.mercedesbenz.sechub.sharedkernel.mapping.MappingData in project sechub by mercedes-benz.
the class CheckmarxProductExecutorMockTest method createCheckmarxSetupWithAllMandotoryPartsSet.
private ProductExecutorConfigSetup createCheckmarxSetupWithAllMandotoryPartsSet() {
ProductExecutorConfigSetup setup = mock(ProductExecutorConfigSetup.class);
ProductExecutorConfigSetupCredentials credentials = mock(ProductExecutorConfigSetupCredentials.class);
when(setup.getCredentials()).thenReturn(credentials);
when(credentials.getUser()).thenReturn("user");
when(credentials.getPassword()).thenReturn("pwd");
List<ProductExecutorConfigSetupJobParameter> jobParameters = new ArrayList<>();
MappingData data = new MappingData();
data.getEntries().add(new MappingEntry(".*", "teamId1", ""));
jobParameters.add(new ProductExecutorConfigSetupJobParameter(MappingIdentifier.CHECKMARX_NEWPROJECT_TEAM_ID.getId(), data.toJSON()));
when(setup.getJobParameters()).thenReturn(jobParameters);
return setup;
}
use of com.mercedesbenz.sechub.sharedkernel.mapping.MappingData in project sechub by mercedes-benz.
the class MappingDataValidationImplTest method having_2_mapping_entries_calls_and_entry1_bad_than_invalid.
@Test
public void having_2_mapping_entries_calls_and_entry1_bad_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();
when(mappingEntryValidation.validate(entry1)).thenReturn(result1);
when(mappingEntryValidation.validate(entry2)).thenReturn(result2);
/* execute */
boolean valid = validationToTest.validate(data).isValid();
/* test */
assertFalse(valid);
}
Aggregations