Search in sources :

Example 21 with MappingData

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

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

the class SaveJSONAdapterDialogAction method execute.

@Override
protected void execute(ActionEvent e) throws Exception {
    DeveloperAdministration adm = getDialogUI().getContext().getAdministration();
    String url = adm.getUrlBuilder().buildUpdateMapping(getMappingUI().getMappingId());
    String json = getMappingUI().getJSON();
    // just check json correct
    MappingData data = MappingData.fromString(json);
    int size = data.getEntries().size();
    boolean confirmed = getDialogUI().getContext().getDialogUI().confirm("Do you really want to upload?\n\n" + size + " entries will be set!");
    if (!confirmed) {
        getDialogUI().getContext().getOutputUI().output(getClass().getSimpleName() + ":Canceled by user");
        return;
    }
    adm.getRestHelper().putJSON(url, json);
    getDialogUI().getContext().getOutputUI().output("Updated mapping:" + getMappingUI().getMappingId());
}
Also used : DeveloperAdministration(com.mercedesbenz.sechub.developertools.admin.DeveloperAdministration) MappingData(com.mercedesbenz.sechub.sharedkernel.mapping.MappingData)

Example 23 with MappingData

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

the class ScanMappingConfigurationTestJSONasNamePatternDialogAction method createScanConfig.

private ScanMappingConfiguration createScanConfig(String json, MappingIdentifier identifier) {
    MappingData mappingData = MappingData.fromString(json);
    ScanMapping mapping = new ScanMapping(identifier.getId());
    mapping.setData(mappingData.toJSON());
    ScanMappingConfiguration config = new ScanMappingToScanMappingConfigurationTransformer().transform(Collections.singletonList(mapping));
    return config;
}
Also used : ScanMapping(com.mercedesbenz.sechub.domain.scan.config.ScanMapping) MappingData(com.mercedesbenz.sechub.sharedkernel.mapping.MappingData) ScanMappingConfiguration(com.mercedesbenz.sechub.domain.scan.config.ScanMappingConfiguration) ScanMappingToScanMappingConfigurationTransformer(com.mercedesbenz.sechub.domain.scan.config.ScanMappingToScanMappingConfigurationTransformer)

Example 24 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_two_good_than_valid.

@Test
public void having_2_mapping_entries_calls_and_two_good_than_valid() {
    /* prepare */
    MappingData data = new MappingData();
    data.getEntries().add(entry1);
    data.getEntries().add(entry2);
    when(mappingEntryValidation.validate(any())).thenReturn(new ValidationResult());
    /* execute +test */
    assertTrue(validationToTest.validate(data).isValid());
}
Also used : MappingData(com.mercedesbenz.sechub.sharedkernel.mapping.MappingData) Test(org.junit.Test)

Example 25 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_entry2_bad_than_invalid.

@Test
public void having_2_mapping_entries_calls_and_entry2_bad_than_invalid() {
    /* prepare */
    MappingData data = new MappingData();
    data.getEntries().add(entry1);
    data.getEntries().add(entry2);
    ValidationResult result1 = new ValidationResult();
    ValidationResult result2 = new ValidationResult();
    result2.addError("error1");
    when(mappingEntryValidation.validate(entry1)).thenReturn(result1);
    when(mappingEntryValidation.validate(entry2)).thenReturn(result2);
    /* execute +test */
    assertFalse(validationToTest.validate(data).isValid());
}
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