### Question:
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);  }### Answer:
@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)); }
@Test public void updatePresetIdWhenSetInAdapterConfig_presetId_sechub_not_set__no_update_necessary() { long presetId = 443940; CheckmarxConfigBuilder builder = createBuilderWithMandatoryParamatersSet(); builder.setPresetIdForNewProjects(null); CheckmarxConfig config = builder.build(); CheckmarxSastScanSettings checkmarxScanSettings = new CheckmarxSastScanSettings(); checkmarxScanSettings.setPresetId(presetId); InternalUpdateContext updateContext = supportToTest.new InternalUpdateContext(); supportToTest.updatePresetIdWhenSetInAdapterConfig(config, checkmarxScanSettings, updateContext); assertThat(updateContext.isUpdateOfPresetIdNecessary(), is(false)); assertThat(updateContext.getPresetId(), is(presetId)); assertThat(updateContext.isUpdateNecessary(), is(false)); }