use of com.mercedesbenz.sechub.sharedkernel.mapping.MappingEntry 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.MappingEntry 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.MappingEntry in project sechub by mercedes-benz.
the class MappingDataValidationImplTest method before.
@Before
public void before() {
validationToTest = new MappingDataValidationImpl();
mappingEntryValidation = mock(MappingEntryValidation.class);
entry1 = new MappingEntry("pattern1", "replace1", "comment1");
entry2 = new MappingEntry("pattern2", "replace2", "comment2");
validationToTest.mappingEntryValidation = mappingEntryValidation;
}
use of com.mercedesbenz.sechub.sharedkernel.mapping.MappingEntry in project sechub by mercedes-benz.
the class MappingEntryValidationImplTest method all_null_means_wrong.
@Test
public void all_null_means_wrong() {
assertFalse(validationToTest.validate(new MappingEntry(null, null, null)).isValid());
assertFalse(validationToTest.validate(new MappingEntry()).isValid());
}
use of com.mercedesbenz.sechub.sharedkernel.mapping.MappingEntry in project sechub by mercedes-benz.
the class MappingEntryValidationImpl method validate.
@Override
protected void validate(ValidationContext<MappingEntry> context) {
validateNotNull(context);
if (context.isInValid()) {
return;
}
MappingEntry mappingEntry = context.objectToValidate;
context.result.addErrors(patternValidation.validate(mappingEntry.getPattern()));
context.result.addErrors(replaceValidation.validate(mappingEntry.getReplacement()));
context.result.addErrors(commentValidation.validate(mappingEntry.getComment()));
}
Aggregations