Search in sources :

Example 31 with MappingData

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

the class ScanMappingToScanMappingConfigurationTransformerTest method two_mappings_containing_four_entries_transformed_to_config.

@Test
public void two_mappings_containing_four_entries_transformed_to_config() {
    /* prepare */
    MappingData data1 = createMappingData(new MappingEntry("x", "y", "z"), new MappingEntry("a", "b", "c"));
    ScanMapping mapping1 = createMapping("id1", data1);
    MappingData data2 = createMappingData(new MappingEntry("d", "e", null), new MappingEntry("f", "g", null));
    ScanMapping mapping2 = createMapping("id2", data2);
    when(converter.convert(any())).thenReturn(Arrays.asList(new NamePatternToIdEntry("pattern1", "replacement1"), new NamePatternToIdEntry("pattern2", "replacement2"))).thenReturn(Arrays.asList(new NamePatternToIdEntry("pattern3", "replacement3"), new NamePatternToIdEntry("pattern4", "replacement4")));
    List<ScanMapping> list = new ArrayList<>();
    list.add(mapping1);
    list.add(mapping2);
    /* execute */
    ScanMappingConfiguration result = transformerToTest.transform(list);
    /* test */
    assertNotNull(result);
    assertEquals(2, result.getNamePatternMappings().size());
    /* -- id:1-- */
    List<NamePatternToIdEntry> namePatternList1 = result.getNamePatternMappings().get("id1");
    assertEquals(2, namePatternList1.size());
    NamePatternToIdEntry first = namePatternList1.get(0);
    assertEquals("pattern1", first.getNamePattern());
    assertEquals("replacement1", first.getId());
    NamePatternToIdEntry second = namePatternList1.get(1);
    assertEquals("pattern2", second.getNamePattern());
    assertEquals("replacement2", second.getId());
    /* -- id:2-- */
    List<NamePatternToIdEntry> namePatternList2 = result.getNamePatternMappings().get("id2");
    assertEquals(2, namePatternList2.size());
    NamePatternToIdEntry first2 = namePatternList2.get(0);
    assertEquals("pattern3", first2.getNamePattern());
    assertEquals("replacement3", first2.getId());
    NamePatternToIdEntry second2 = namePatternList2.get(1);
    assertEquals("pattern4", second2.getNamePattern());
    assertEquals("replacement4", second2.getId());
}
Also used : MappingEntry(com.mercedesbenz.sechub.sharedkernel.mapping.MappingEntry) ArrayList(java.util.ArrayList) MappingData(com.mercedesbenz.sechub.sharedkernel.mapping.MappingData) Test(org.junit.Test)

Example 32 with MappingData

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

the class MappingScenario3IntTest method mapping_for_checkmarx_preset_template_cannot_be_changed_anoymous.

@Test
public void mapping_for_checkmarx_preset_template_cannot_be_changed_anoymous() throws IOException {
    /* prepare */
    MappingData mappingData1 = new MappingData();
    MappingEntry entry = new MappingEntry("scenario3_project1", "123456", "");
    mappingData1.getEntries().add(entry);
    /* @formatter:off */
    expectHttpFailure(() -> {
        /* execute */
        as(ANONYMOUS).updateMapping(MappingIdentifier.CHECKMARX_NEWPROJECT_PRESET_ID.getId(), mappingData1);
    }, HttpStatus.UNAUTHORIZED);
/* @formatter:on */
}
Also used : MappingEntry(com.mercedesbenz.sechub.sharedkernel.mapping.MappingEntry) MappingData(com.mercedesbenz.sechub.sharedkernel.mapping.MappingData) Test(org.junit.Test)

Example 33 with MappingData

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

the class MappingDataCSVSupportTest method from_csv_test_1_headline.

@Test
public void from_csv_test_1_headline() {
    /* prepare */
    MappingData expected = new MappingData();
    expected.getEntries().add(new MappingEntry("pattern1", "replacement1", "comment1"));
    expected.getEntries().add(new MappingEntry("pattern2", "replacement2", "comment2"));
    List<CSVRow> rows = new ArrayList<>();
    CSVRow headline = new CSVRow();
    headline.add("patterns");
    headline.add("replacements");
    headline.add("comments");
    CSVRow row1 = new CSVRow();
    row1.add("pattern1");
    row1.add("replacement1");
    row1.add("comment1");
    CSVRow row2 = new CSVRow();
    row2.add("pattern2");
    row2.add("replacement2");
    row2.add("comment2");
    rows.add(row1);
    rows.add(row2);
    /* execute */
    MappingData result = supportToTest.fromCSVRows(rows, 0);
    /* prepare */
    assertEquals(expected.toJSON(), result.toJSON());
}
Also used : MappingEntry(com.mercedesbenz.sechub.sharedkernel.mapping.MappingEntry) ArrayList(java.util.ArrayList) MappingData(com.mercedesbenz.sechub.sharedkernel.mapping.MappingData) Test(org.junit.Test)

Example 34 with MappingData

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

the class ScanMappingToScanConfigTransformerTest method two_mappings_containing_four_entries_transformed_to_config.

@Test
public void two_mappings_containing_four_entries_transformed_to_config() {
    /* prepare */
    MappingData data1 = createMappingData(new MappingEntry("x", "y", "z"), new MappingEntry("a", "b", "c"));
    ScanMapping mapping1 = createMapping("id1", data1);
    MappingData data2 = createMappingData(new MappingEntry("d", "e", null), new MappingEntry("f", "g", null));
    ScanMapping mapping2 = createMapping("id2", data2);
    when(converter.convert(any())).thenReturn(Arrays.asList(new NamePatternToIdEntry("pattern1", "replacement1"), new NamePatternToIdEntry("pattern2", "replacement2"))).thenReturn(Arrays.asList(new NamePatternToIdEntry("pattern3", "replacement3"), new NamePatternToIdEntry("pattern4", "replacement4")));
    List<ScanMapping> list = new ArrayList<>();
    list.add(mapping1);
    list.add(mapping2);
    /* execute */
    ScanConfig result = transformerToTest.transform(list);
    /* test */
    assertNotNull(result);
    assertEquals(2, result.getNamePatternMappings().size());
    /* -- id:1-- */
    List<NamePatternToIdEntry> namePatternList1 = result.getNamePatternMappings().get("id1");
    assertEquals(2, namePatternList1.size());
    NamePatternToIdEntry first = namePatternList1.get(0);
    assertEquals("pattern1", first.getNamePattern());
    assertEquals("replacement1", first.getId());
    NamePatternToIdEntry second = namePatternList1.get(1);
    assertEquals("pattern2", second.getNamePattern());
    assertEquals("replacement2", second.getId());
    /* -- id:2-- */
    List<NamePatternToIdEntry> namePatternList2 = result.getNamePatternMappings().get("id2");
    assertEquals(2, namePatternList2.size());
    NamePatternToIdEntry first2 = namePatternList2.get(0);
    assertEquals("pattern3", first2.getNamePattern());
    assertEquals("replacement3", first2.getId());
    NamePatternToIdEntry second2 = namePatternList2.get(1);
    assertEquals("pattern4", second2.getNamePattern());
    assertEquals("replacement4", second2.getId());
}
Also used : MappingEntry(com.mercedesbenz.sechub.sharedkernel.mapping.MappingEntry) ArrayList(java.util.ArrayList) MappingData(com.mercedesbenz.sechub.sharedkernel.mapping.MappingData) Test(org.junit.Test)

Example 35 with MappingData

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

the class ScanMappingToScanConfigTransformerTest method one_mapping_containing_two_entries_transformed_to_config.

@Test
public void one_mapping_containing_two_entries_transformed_to_config() {
    /* prepare */
    MappingData data = createMappingData(new MappingEntry("x", "y", "z"), new MappingEntry("a", "b", "c"));
    ScanMapping mapping1 = createMapping("id1", data);
    when(converter.convert(any())).thenReturn(Arrays.asList(new NamePatternToIdEntry("pattern1", "replacement1"), new NamePatternToIdEntry("pattern2", "replacement2")));
    /* execute */
    ScanConfig result = transformerToTest.transform(Collections.singletonList(mapping1));
    /* test */
    assertNotNull(result);
    assertEquals(1, result.getNamePatternMappings().size());
    List<NamePatternToIdEntry> namePatternList = result.getNamePatternMappings().get("id1");
    assertEquals(2, namePatternList.size());
    NamePatternToIdEntry first = namePatternList.get(0);
    assertEquals("pattern1", first.getNamePattern());
    assertEquals("replacement1", first.getId());
    NamePatternToIdEntry second = namePatternList.get(1);
    assertEquals("pattern2", second.getNamePattern());
    assertEquals("replacement2", second.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