Search in sources :

Example 16 with MappingEntry

use of com.mercedesbenz.sechub.sharedkernel.mapping.MappingEntry 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 MappingEntry

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

the class MappingDataToNamePatternToIdEntryConverter method convert.

public List<NamePatternToIdEntry> convert(MappingData data) {
    List<NamePatternToIdEntry> list = new ArrayList<>();
    if (data == null) {
        return list;
    }
    for (MappingEntry mappingEntry : data.getEntries()) {
        NamePatternToIdEntry namePattternToIdEntry = new NamePatternToIdEntry(mappingEntry.getPattern(), mappingEntry.getReplacement());
        list.add(namePattternToIdEntry);
    }
    return list;
}
Also used : MappingEntry(com.mercedesbenz.sechub.sharedkernel.mapping.MappingEntry) ArrayList(java.util.ArrayList)

Example 18 with MappingEntry

use of com.mercedesbenz.sechub.sharedkernel.mapping.MappingEntry 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)

Example 19 with MappingEntry

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

the class CreateExampleJSONAdapterDialogAction method execute.

@Override
protected void execute(ActionEvent e) throws Exception {
    boolean confirmed = getDialogUI().getContext().getDialogUI().confirm("Do you really want to replace your JSON data in text area with example code?");
    if (!confirmed) {
        getDialogUI().getContext().getOutputUI().output("Canceled by user");
        return;
    }
    String exampleFound = getMappingUI().getData().example;
    if (exampleFound != null) {
        getMappingUI().setJSON(exampleFound);
    } else {
        MappingData data = new MappingData();
        data.getEntries().add(new MappingEntry("pattern1", "replacement1", "comment1"));
        data.getEntries().add(new MappingEntry("pattern2", "replacement2", "comment2"));
        getMappingUI().setJSON(data.toJSON());
    }
}
Also used : MappingEntry(com.mercedesbenz.sechub.sharedkernel.mapping.MappingEntry) MappingData(com.mercedesbenz.sechub.sharedkernel.mapping.MappingData)

Example 20 with MappingEntry

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

the class MappingEntryValidationImplTest method check_80_chars_limit_for_id.

@Test
public void check_80_chars_limit_for_id() {
    assertTrue(validationToTest.validate(new MappingEntry(CONST_80_CHARS, "", "")).isValid());
    assertFalse(validationToTest.validate(new MappingEntry(CONST_80_CHARS + "1", "", "")).isValid());
}
Also used : MappingEntry(com.mercedesbenz.sechub.sharedkernel.mapping.MappingEntry) Test(org.junit.Test)

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