Search in sources :

Example 1 with MappingEntry

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());
}
Also used : MappingEntry(com.mercedesbenz.sechub.sharedkernel.mapping.MappingEntry) MappingData(com.mercedesbenz.sechub.sharedkernel.mapping.MappingData) Test(org.junit.Test)

Example 2 with MappingEntry

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;
}
Also used : MappingEntry(com.mercedesbenz.sechub.sharedkernel.mapping.MappingEntry) ProductExecutorConfigSetupCredentials(com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfigSetupCredentials) ProductExecutorConfigSetupJobParameter(com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfigSetupJobParameter) ArrayList(java.util.ArrayList) MappingData(com.mercedesbenz.sechub.sharedkernel.mapping.MappingData) ProductExecutorConfigSetup(com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfigSetup)

Example 3 with MappingEntry

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;
}
Also used : MappingEntry(com.mercedesbenz.sechub.sharedkernel.mapping.MappingEntry) Before(org.junit.Before)

Example 4 with MappingEntry

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());
}
Also used : MappingEntry(com.mercedesbenz.sechub.sharedkernel.mapping.MappingEntry) Test(org.junit.Test)

Example 5 with MappingEntry

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()));
}
Also used : MappingEntry(com.mercedesbenz.sechub.sharedkernel.mapping.MappingEntry)

Aggregations

MappingEntry (com.mercedesbenz.sechub.sharedkernel.mapping.MappingEntry)32 MappingData (com.mercedesbenz.sechub.sharedkernel.mapping.MappingData)21 Test (org.junit.Test)21 ArrayList (java.util.ArrayList)7 Before (org.junit.Before)2 ProductExecutorConfigSetup (com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfigSetup)1 ProductExecutorConfigSetupCredentials (com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfigSetupCredentials)1 ProductExecutorConfigSetupJobParameter (com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfigSetupJobParameter)1 ExecutionResult (com.mercedesbenz.sechub.integrationtest.internal.SecHubClientExecutor.ExecutionResult)1 TestURLBuilder (com.mercedesbenz.sechub.test.TestURLBuilder)1 UUID (java.util.UUID)1