Search in sources :

Example 1 with MappingData

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;
}
Also used : ScanMapping(com.mercedesbenz.sechub.domain.scan.config.ScanMapping) ScanConfig(com.mercedesbenz.sechub.domain.scan.config.ScanConfig) MappingData(com.mercedesbenz.sechub.sharedkernel.mapping.MappingData) ScanMappingToScanConfigTransformer(com.mercedesbenz.sechub.domain.scan.config.ScanMappingToScanConfigTransformer)

Example 2 with MappingData

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

Example 3 with MappingData

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

Example 4 with MappingData

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;
}
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 5 with MappingData

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

Aggregations

MappingData (com.mercedesbenz.sechub.sharedkernel.mapping.MappingData)35 MappingEntry (com.mercedesbenz.sechub.sharedkernel.mapping.MappingEntry)21 Test (org.junit.Test)20 ArrayList (java.util.ArrayList)5 ScanMapping (com.mercedesbenz.sechub.domain.scan.config.ScanMapping)2 TestURLBuilder (com.mercedesbenz.sechub.test.TestURLBuilder)2 DeveloperAdministration (com.mercedesbenz.sechub.developertools.admin.DeveloperAdministration)1 CSVRow (com.mercedesbenz.sechub.developertools.admin.importer.CSVRow)1 SimpleCSVImporter (com.mercedesbenz.sechub.developertools.admin.importer.SimpleCSVImporter)1 NamePatternIdProvider (com.mercedesbenz.sechub.domain.scan.config.NamePatternIdProvider)1 NamePatternToIdEntry (com.mercedesbenz.sechub.domain.scan.config.NamePatternToIdEntry)1 ScanConfig (com.mercedesbenz.sechub.domain.scan.config.ScanConfig)1 ScanMappingConfiguration (com.mercedesbenz.sechub.domain.scan.config.ScanMappingConfiguration)1 ScanMappingToScanConfigTransformer (com.mercedesbenz.sechub.domain.scan.config.ScanMappingToScanConfigTransformer)1 ScanMappingToScanMappingConfigurationTransformer (com.mercedesbenz.sechub.domain.scan.config.ScanMappingToScanMappingConfigurationTransformer)1 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 TestExecutorConfig (com.mercedesbenz.sechub.test.executorconfig.TestExecutorConfig)1