Search in sources :

Example 16 with MappingData

use of com.mercedesbenz.sechub.sharedkernel.mapping.MappingData in project sechub by mercedes-benz.

the class TestAPI method changeScanMappingDirectly.

/**
 * Changes scan mapping DIRECTLY ! Means without administration domain, but
 * directly in scan domain - interesting for testing only,
 *
 * @param json
 */
public static void changeScanMappingDirectly(String mappingId, MappingEntry... entries) {
    MappingData data = new MappingData();
    for (MappingEntry entry : entries) {
        data.getEntries().add(entry);
    }
    TestURLBuilder urlBuilder = IntegrationTestContext.get().getUrlBuilder();
    String url = urlBuilder.buildIntegrationTestChangeMappingDirectlyURL(mappingId);
    IntegrationTestContext.get().getRestHelper(ANONYMOUS).putJSON(url, data.toJSON());
}
Also used : MappingEntry(com.mercedesbenz.sechub.sharedkernel.mapping.MappingEntry) TestURLBuilder(com.mercedesbenz.sechub.test.TestURLBuilder) MappingData(com.mercedesbenz.sechub.sharedkernel.mapping.MappingData)

Example 17 with MappingData

use of com.mercedesbenz.sechub.sharedkernel.mapping.MappingData in project sechub by mercedes-benz.

the class TestAPI method fetchMappingDataDirectlyOrNull.

public static MappingData fetchMappingDataDirectlyOrNull(String mappingId) {
    TestURLBuilder urlBuilder = IntegrationTestContext.get().getUrlBuilder();
    String url = urlBuilder.buildIntegrationTestFetchMappingDirectlyURL(mappingId);
    String result = IntegrationTestContext.get().getRestHelper(ANONYMOUS).getJSON(url);
    if (result == null) {
        return null;
    }
    MappingData data = MappingData.fromString(result);
    return data;
}
Also used : TestURLBuilder(com.mercedesbenz.sechub.test.TestURLBuilder) MappingData(com.mercedesbenz.sechub.sharedkernel.mapping.MappingData)

Example 18 with MappingData

use of com.mercedesbenz.sechub.sharedkernel.mapping.MappingData in project sechub by mercedes-benz.

the class NamePatternIdProviderFactory method createProvider.

public NamePatternIdProvider createProvider(String id, String parameterValue) {
    NamePatternIdProvider provider;
    MappingData mappingData = MappingData.fromString(parameterValue);
    List<NamePatternToIdEntry> entries = converter.convert(mappingData);
    provider = new NamePatternIdProvider(id);
    for (NamePatternToIdEntry entry : entries) {
        provider.add(entry);
    }
    return provider;
}
Also used : NamePatternToIdEntry(com.mercedesbenz.sechub.domain.scan.config.NamePatternToIdEntry) NamePatternIdProvider(com.mercedesbenz.sechub.domain.scan.config.NamePatternIdProvider) MappingData(com.mercedesbenz.sechub.sharedkernel.mapping.MappingData)

Example 19 with MappingData

use of com.mercedesbenz.sechub.sharedkernel.mapping.MappingData in project sechub by mercedes-benz.

the class ScanMappingToScanMappingConfigurationTransformer method transform.

public ScanMappingConfiguration transform(List<ScanMapping> mappings) {
    ScanMappingConfiguration config = new ScanMappingConfiguration();
    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 20 with MappingData

use of com.mercedesbenz.sechub.sharedkernel.mapping.MappingData in project sechub by mercedes-benz.

the class MappingDataCSVSupport method fromCSVRows.

public MappingData fromCSVRows(List<CSVRow> rows, int headlines) {
    MappingData data = new MappingData();
    if (rows.size() <= headlines) {
        throw new IllegalStateException("Row count must be > headline count:" + headlines);
    }
    int count = 0;
    for (CSVRow row : rows) {
        count++;
        if (count <= headlines) {
            /* ignore headline */
            continue;
        }
        if (row.columns.size() != 3) {
            throw new IllegalStateException("column count must be 3, but is:" + row.columns.size());
        }
        int col = 0;
        String pattern = row.columns.get(col++).cell;
        String replacement = row.columns.get(col++).cell;
        String comment = row.columns.get(col++).cell;
        data.getEntries().add(new MappingEntry(pattern, replacement, comment));
    }
    return data;
}
Also used : MappingEntry(com.mercedesbenz.sechub.sharedkernel.mapping.MappingEntry) MappingData(com.mercedesbenz.sechub.sharedkernel.mapping.MappingData)

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