@Test public void updateEngineCondfigurationIdWhenSecHubAndCheckmarxDiffer_different_engine_configuration_id() { String engineConfigurationName = "test-configuration"; long engineConfigurationId = 5L; List<CheckmarxEngineConfiguration> engineConfigurations = new LinkedList<>(); CheckmarxEngineConfiguration defaultConfiguration = new CheckmarxEngineConfiguration(); defaultConfiguration.setId(1L); defaultConfiguration.setName("Default Configuration"); CheckmarxEngineConfiguration testConfiguration = new CheckmarxEngineConfiguration(); testConfiguration.setId(engineConfigurationId); testConfiguration.setName(engineConfigurationName); engineConfigurations.add(defaultConfiguration); engineConfigurations.add(testConfiguration); CheckmarxConfigBuilder builder = createBuilderWithMandatoryParamatersSet(); builder.setEngineConfigurationName(engineConfigurationName); CheckmarxConfig config = builder.build(); CheckmarxSastScanSettings checkmarxScanSettings = new CheckmarxSastScanSettings(); checkmarxScanSettings.setEngineConfigurationId(defaultConfiguration.getId()); InternalUpdateContext updateContext = supportToTest.new InternalUpdateContext(); supportToTest.updateEngineCondfigurationIdWhenSecHubAndCheckmarxDiffer(config, engineConfigurations, checkmarxScanSettings, updateContext); assertThat(updateContext.isUpdateOfEngineConfigurationNecessary(), is(true)); assertThat(updateContext.getEngineConfigurationId(), is(engineConfigurationId)); assertThat(updateContext.isUpdateNecessary(), is(true)); }
protected void updateEngineCondfigurationIdWhenSecHubAndCheckmarxDiffer(CheckmarxAdapterConfig config, List<CheckmarxEngineConfiguration> engineConfigurations, CheckmarxSastScanSettings checkmarxScanSettings, InternalUpdateContext updateContext) { boolean updateEngineConfiguration = false; String sechubEngineConfigurationName = config.getEngineConfigurationName(); String projectId = config.getProjectId(); long engineConfigurationId = checkmarxScanSettings.getEngineConfigurationId(); LOG.debug("SecHub engine configuration name {}", sechubEngineConfigurationName); CheckmarxEngineConfiguration sechubEngineConfiguration = findEngineConfigurationByName(sechubEngineConfigurationName, engineConfigurations); if (sechubEngineConfiguration == null) { LOG.warn("[ALERT] ILLEGAL_STATE CHECKMARX_ADAPTER no engine configuration available!"); } else { LOG.debug("Found SecHub engine configuration {}", sechubEngineConfiguration.toString()); if (sechubEngineConfiguration.getId() != engineConfigurationId) { LOG.debug("SecHub engine configuration id {} and Checkmarx engine configuration id {} are different.", sechubEngineConfiguration.getId(), engineConfigurationId); LOG.debug("Wanted engine configuration id {} for project {}", sechubEngineConfiguration.getId(), projectId); engineConfigurationId = sechubEngineConfiguration.getId(); updateEngineConfiguration = true; } else { LOG.debug("Engine configuration id is already set to {} for project", sechubEngineConfigurationName, projectId); } } updateContext.setUpdateEngineConfiguration(updateEngineConfiguration); updateContext.setEngineConfigurationId(engineConfigurationId); }
CheckmarxProjectSupport { protected void updateEngineCondfigurationIdWhenSecHubAndCheckmarxDiffer(CheckmarxAdapterConfig config, List<CheckmarxEngineConfiguration> engineConfigurations, CheckmarxSastScanSettings checkmarxScanSettings, InternalUpdateContext updateContext) { boolean updateEngineConfiguration = false; String sechubEngineConfigurationName = config.getEngineConfigurationName(); String projectId = config.getProjectId(); long engineConfigurationId = checkmarxScanSettings.getEngineConfigurationId(); LOG.debug("SecHub engine configuration name {}", sechubEngineConfigurationName); CheckmarxEngineConfiguration sechubEngineConfiguration = findEngineConfigurationByName(sechubEngineConfigurationName, engineConfigurations); if (sechubEngineConfiguration == null) { LOG.warn("[ALERT] ILLEGAL_STATE CHECKMARX_ADAPTER no engine configuration available!"); } else { LOG.debug("Found SecHub engine configuration {}", sechubEngineConfiguration.toString()); if (sechubEngineConfiguration.getId() != engineConfigurationId) { LOG.debug("SecHub engine configuration id {} and Checkmarx engine configuration id {} are different.", sechubEngineConfiguration.getId(), engineConfigurationId); LOG.debug("Wanted engine configuration id {} for project {}", sechubEngineConfiguration.getId(), projectId); engineConfigurationId = sechubEngineConfiguration.getId(); updateEngineConfiguration = true; } else { LOG.debug("Engine configuration id is already set to {} for project", sechubEngineConfigurationName, projectId); } } updateContext.setUpdateEngineConfiguration(updateEngineConfiguration); updateContext.setEngineConfigurationId(engineConfigurationId); } }
CheckmarxProjectSupport { protected void updateEngineCondfigurationIdWhenSecHubAndCheckmarxDiffer(CheckmarxAdapterConfig config, List<CheckmarxEngineConfiguration> engineConfigurations, CheckmarxSastScanSettings checkmarxScanSettings, InternalUpdateContext updateContext) { boolean updateEngineConfiguration = false; String sechubEngineConfigurationName = config.getEngineConfigurationName(); String projectId = config.getProjectId(); long engineConfigurationId = checkmarxScanSettings.getEngineConfigurationId(); LOG.debug("SecHub engine configuration name {}", sechubEngineConfigurationName); CheckmarxEngineConfiguration sechubEngineConfiguration = findEngineConfigurationByName(sechubEngineConfigurationName, engineConfigurations); if (sechubEngineConfiguration == null) { LOG.warn("[ALERT] ILLEGAL_STATE CHECKMARX_ADAPTER no engine configuration available!"); } else { LOG.debug("Found SecHub engine configuration {}", sechubEngineConfiguration.toString()); if (sechubEngineConfiguration.getId() != engineConfigurationId) { LOG.debug("SecHub engine configuration id {} and Checkmarx engine configuration id {} are different.", sechubEngineConfiguration.getId(), engineConfigurationId); LOG.debug("Wanted engine configuration id {} for project {}", sechubEngineConfiguration.getId(), projectId); engineConfigurationId = sechubEngineConfiguration.getId(); updateEngineConfiguration = true; } else { LOG.debug("Engine configuration id is already set to {} for project", sechubEngineConfigurationName, projectId); } } updateContext.setUpdateEngineConfiguration(updateEngineConfiguration); updateContext.setEngineConfigurationId(engineConfigurationId); }  }
CheckmarxProjectSupport { protected void updateEngineCondfigurationIdWhenSecHubAndCheckmarxDiffer(CheckmarxAdapterConfig config, List<CheckmarxEngineConfiguration> engineConfigurations, CheckmarxSastScanSettings checkmarxScanSettings, InternalUpdateContext updateContext) { boolean updateEngineConfiguration = false; String sechubEngineConfigurationName = config.getEngineConfigurationName(); String projectId = config.getProjectId(); long engineConfigurationId = checkmarxScanSettings.getEngineConfigurationId(); LOG.debug("SecHub engine configuration name {}", sechubEngineConfigurationName); CheckmarxEngineConfiguration sechubEngineConfiguration = findEngineConfigurationByName(sechubEngineConfigurationName, engineConfigurations); if (sechubEngineConfiguration == null) { LOG.warn("[ALERT] ILLEGAL_STATE CHECKMARX_ADAPTER no engine configuration available!"); } else { LOG.debug("Found SecHub engine configuration {}", sechubEngineConfiguration.toString()); if (sechubEngineConfiguration.getId() != engineConfigurationId) { LOG.debug("SecHub engine configuration id {} and Checkmarx engine configuration id {} are different.", sechubEngineConfiguration.getId(), engineConfigurationId); LOG.debug("Wanted engine configuration id {} for project {}", sechubEngineConfiguration.getId(), projectId); engineConfigurationId = sechubEngineConfiguration.getId(); updateEngineConfiguration = true; } else { LOG.debug("Engine configuration id is already set to {} for project", sechubEngineConfigurationName, projectId); } } updateContext.setUpdateEngineConfiguration(updateEngineConfiguration); updateContext.setEngineConfigurationId(engineConfigurationId); }  void ensureProjectExists(CheckmarxContext context); }
CheckmarxProjectSupport { protected void updateEngineCondfigurationIdWhenSecHubAndCheckmarxDiffer(CheckmarxAdapterConfig config, List<CheckmarxEngineConfiguration> engineConfigurations, CheckmarxSastScanSettings checkmarxScanSettings, InternalUpdateContext updateContext) { boolean updateEngineConfiguration = false; String sechubEngineConfigurationName = config.getEngineConfigurationName(); String projectId = config.getProjectId(); long engineConfigurationId = checkmarxScanSettings.getEngineConfigurationId(); LOG.debug("SecHub engine configuration name {}", sechubEngineConfigurationName); CheckmarxEngineConfiguration sechubEngineConfiguration = findEngineConfigurationByName(sechubEngineConfigurationName, engineConfigurations); if (sechubEngineConfiguration == null) { LOG.warn("[ALERT] ILLEGAL_STATE CHECKMARX_ADAPTER no engine configuration available!"); } else { LOG.debug("Found SecHub engine configuration {}", sechubEngineConfiguration.toString()); if (sechubEngineConfiguration.getId() != engineConfigurationId) { LOG.debug("SecHub engine configuration id {} and Checkmarx engine configuration id {} are different.", sechubEngineConfiguration.getId(), engineConfigurationId); LOG.debug("Wanted engine configuration id {} for project {}", sechubEngineConfiguration.getId(), projectId); engineConfigurationId = sechubEngineConfiguration.getId(); updateEngineConfiguration = true; } else { LOG.debug("Engine configuration id is already set to {} for project", sechubEngineConfigurationName, projectId); } } updateContext.setUpdateEngineConfiguration(updateEngineConfiguration); updateContext.setEngineConfigurationId(engineConfigurationId); }  void ensureProjectExists(CheckmarxContext context);  }