@Test public void updatePresetIdWhenSetInAdapterConfig_preset_id_set_in_sechub() { long secHubPresetId = 39203; long checkmarxPresetId = 1; CheckmarxConfigBuilder builder = createBuilderWithMandatoryParamatersSet(); builder.setPresetIdForNewProjects(secHubPresetId); CheckmarxConfig config = builder.build(); CheckmarxSastScanSettings checkmarxScanSettings = new CheckmarxSastScanSettings(); checkmarxScanSettings.setPresetId(checkmarxPresetId); InternalUpdateContext updateContext = supportToTest.new InternalUpdateContext(); supportToTest.updatePresetIdWhenSetInAdapterConfig(config, checkmarxScanSettings, updateContext); assertThat(updateContext.isUpdateOfPresetIdNecessary(), is(true)); assertThat(updateContext.getPresetId(), is(secHubPresetId)); assertThat(updateContext.isUpdateNecessary(), is(true)); }
protected void updatePresetIdWhenSetInAdapterConfig(CheckmarxAdapterConfig config, CheckmarxSastScanSettings checkmarxScanSettings, InternalUpdateContext updateContext) { boolean updatePresetId = false; String projectId = config.getProjectId(); Long presetId = config.getPresetIdForNewProjectsOrNull(); if (presetId == null) { LOG.debug("No presetId defined, so keep default preset."); presetId = checkmarxScanSettings.getPresetId(); } else { LOG.debug("Wanted preset id {} for project {}", presetId, projectId); updatePresetId = true; } updateContext.setUpdatePresetId(updatePresetId); updateContext.setPresetId(presetId); }
CheckmarxProjectSupport { protected void updatePresetIdWhenSetInAdapterConfig(CheckmarxAdapterConfig config, CheckmarxSastScanSettings checkmarxScanSettings, InternalUpdateContext updateContext) { boolean updatePresetId = false; String projectId = config.getProjectId(); Long presetId = config.getPresetIdForNewProjectsOrNull(); if (presetId == null) { LOG.debug("No presetId defined, so keep default preset."); presetId = checkmarxScanSettings.getPresetId(); } else { LOG.debug("Wanted preset id {} for project {}", presetId, projectId); updatePresetId = true; } updateContext.setUpdatePresetId(updatePresetId); updateContext.setPresetId(presetId); } }
CheckmarxProjectSupport { protected void updatePresetIdWhenSetInAdapterConfig(CheckmarxAdapterConfig config, CheckmarxSastScanSettings checkmarxScanSettings, InternalUpdateContext updateContext) { boolean updatePresetId = false; String projectId = config.getProjectId(); Long presetId = config.getPresetIdForNewProjectsOrNull(); if (presetId == null) { LOG.debug("No presetId defined, so keep default preset."); presetId = checkmarxScanSettings.getPresetId(); } else { LOG.debug("Wanted preset id {} for project {}", presetId, projectId); updatePresetId = true; } updateContext.setUpdatePresetId(updatePresetId); updateContext.setPresetId(presetId); }  }
CheckmarxProjectSupport { protected void updatePresetIdWhenSetInAdapterConfig(CheckmarxAdapterConfig config, CheckmarxSastScanSettings checkmarxScanSettings, InternalUpdateContext updateContext) { boolean updatePresetId = false; String projectId = config.getProjectId(); Long presetId = config.getPresetIdForNewProjectsOrNull(); if (presetId == null) { LOG.debug("No presetId defined, so keep default preset."); presetId = checkmarxScanSettings.getPresetId(); } else { LOG.debug("Wanted preset id {} for project {}", presetId, projectId); updatePresetId = true; } updateContext.setUpdatePresetId(updatePresetId); updateContext.setPresetId(presetId); }  void ensureProjectExists(CheckmarxContext context); }
CheckmarxProjectSupport { protected void updatePresetIdWhenSetInAdapterConfig(CheckmarxAdapterConfig config, CheckmarxSastScanSettings checkmarxScanSettings, InternalUpdateContext updateContext) { boolean updatePresetId = false; String projectId = config.getProjectId(); Long presetId = config.getPresetIdForNewProjectsOrNull(); if (presetId == null) { LOG.debug("No presetId defined, so keep default preset."); presetId = checkmarxScanSettings.getPresetId(); } else { LOG.debug("Wanted preset id {} for project {}", presetId, projectId); updatePresetId = true; } updateContext.setUpdatePresetId(updatePresetId); updateContext.setPresetId(presetId); }  void ensureProjectExists(CheckmarxContext context);  }