Search in sources :

Example 26 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_none_good_than_invalid.

@Test
public void having_2_mapping_entries_calls_and_none_good_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();
    result1.addError("error2");
    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)

Example 27 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_map_entry_validation_two_times.

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

Example 28 with MappingData

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

the class ImportCSVToJSONAdapterDialogAction method execute.

@Override
protected void execute(ActionEvent e) throws Exception {
    /* select */
    String defaultPath = ConfigurationSetup.SECHUB_MASS_OPERATION_PARENTDIRECTORY.getStringValue(System.getProperty("user.home"));
    String mappingId = getMappingUI().getMappingId();
    File defaultFile = new File(defaultPath, mappingId + ".csv");
    File file = getDialogUI().getContext().getDialogUI().selectFile(defaultFile.getAbsolutePath());
    if (file == null) {
        return;
    }
    if (!file.getName().equals(defaultFile.getName())) {
        boolean confirmed = getDialogUI().getContext().getDialogUI().confirm("File name not as expected - is mappingId:" + mappingId + " really saved inside " + file.getName() + " ?");
        if (!confirmed) {
            getDialogUI().getContext().getOutputUI().output("Canceled by user");
            return;
        }
    }
    /* import */
    SimpleCSVImporter importer = new SimpleCSVImporter();
    List<CSVRow> rows = importer.importCSVFile(file, 3, 1);
    /* convert */
    MappingData data = csvSupport.fromCSVRows(rows, 0);
    String json = data.toJSON();
    /* output beautified */
    getMappingUI().setJSON(JSONDeveloperHelper.INSTANCE.beatuifyJSON(json));
    /* inform */
    getDialogUI().getContext().getOutputUI().output("Imported from CSV file:" + file.getAbsolutePath());
}
Also used : MappingData(com.mercedesbenz.sechub.sharedkernel.mapping.MappingData) CSVRow(com.mercedesbenz.sechub.developertools.admin.importer.CSVRow) SimpleCSVImporter(com.mercedesbenz.sechub.developertools.admin.importer.SimpleCSVImporter) File(java.io.File)

Example 29 with MappingData

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

the class MappingDataToNamePatternToIdEntryConverterTest method one_mapping_containing_one_entry_transformed_to_config.

@Test
public void one_mapping_containing_one_entry_transformed_to_config() {
    /* prepare */
    MappingData mapping1 = createMapping(new MappingEntry("pattern1", "replacement1", "comment1"));
    /* execute */
    List<NamePatternToIdEntry> namePatternList = converterToTest.convert(mapping1);
    /* test */
    assertNotNull(namePatternList);
    assertEquals(1, namePatternList.size());
    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 30 with MappingData

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

the class ScanMappingToScanMappingConfigurationTransformerTest 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 */
    ScanMappingConfiguration 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)

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