@Override public List<ValidationProblem> validate(@NotNull TaskValidationContext taskValidationContext, @NotNull TaskProperties taskProperties) { List<ValidationProblem> result = new ArrayList<>(); final TestParserTaskProperties testParserTaskProperties = Narrow.downTo(taskProperties, TestParserTaskProperties.class); if (testParserTaskProperties != null) { if (StringUtils.isEmpty(getResultPath(testParserTaskProperties))) { result.add(new ValidationProblem(NUNIT_PARSER_CONTEXT, "Result path is mandatory")); } } return result; } }
@NotNull @Override public final Map<String, String> toTaskConfiguration(@NotNull TaskContainer taskContainer, @NotNull TaskProperties taskProperties) { final P typedTaskProperties = Narrow.downTo(taskProperties, propertiesClass); Preconditions.checkState(typedTaskProperties != null, "Don't know how to import task properties of type: " + taskProperties.getClass().getName()); final Map<String, String> config = new HashMap<>(); config.put(AbstractNodeRequiringTaskConfigurator.NODE_RUNTIME, typedTaskProperties.getNodeExecutable()); config.put(TaskConfigConstants.CFG_ENVIRONMENT_VARIABLES, typedTaskProperties.getEnvironmentVariables()); config.put(TaskConfigConstants.CFG_WORKING_SUBDIRECTORY, typedTaskProperties.getWorkingSubdirectory()); config.putAll(toTaskConfiguration(typedTaskProperties)); return config; }
@Override public Map<String, String> toTaskConfiguration(@NotNull TaskContainer taskContainer, final TaskProperties taskProperties) { final TestParserTaskProperties testParserTaskProperties = Narrow.downTo(taskProperties, TestParserTaskProperties.class); if (testParserTaskProperties != null) { final Map<String, String> cfg = new HashMap<>(); if (testParserTaskProperties.getResultDirectories() != null) { cfg.put(NUnitCollectorTaskType.TEST_DIRECTORY, getResultPath(testParserTaskProperties)); } cfg.put(TaskConfigConstants.CFG_TEST_OUTDATED_RESULTS_FILE, Boolean.toString(testParserTaskProperties.getPickUpTestResultsCreatedOutsideOfThisBuild())); return cfg; } throw new IllegalStateException("Don't know how to import task properties of type: " + taskProperties.getClass().getName()); }
@NotNull @Override public String importNotificationRecipient(NotificationRecipientProperties recipient) { final HipChatRecipientProperties hipChatRecipient = Narrow.downTo(recipient, HipChatRecipientProperties.class); if (hipChatRecipient != null) { return hipChatRecipient.getApiToken() + '|' + String.valueOf(hipChatRecipient.isNotifyUsers()) + '|' + hipChatRecipient.getRoom(); } throw new IllegalStateException("Don't know how to import notification type class: " + recipient.getClass().getName()); }
@Override @NotNull public Map<String, String> toTaskConfiguration(@NotNull TaskContainer taskContainer, @NotNull final TaskProperties taskProperties) { final MsBuildTaskProperties msBuildTaskProperties = Narrow.downTo(taskProperties, MsBuildTaskProperties.class); if (msBuildTaskProperties == null) { throw new IllegalStateException("Unsupported import task of type: " + taskProperties.getClass().getName()); } final Map<String, String> cfg = new HashMap<>(); cfg.put(MsBuildConfig.LABEL, msBuildTaskProperties.getExecutable()); cfg.put(MsBuildConfig.SOLUTION, msBuildTaskProperties.getProjectFile()); cfg.put(MsBuildConfig.OPTIONS, msBuildTaskProperties.getOptions()); cfg.put(MsBuildConfig.ENVIRONMENT, msBuildTaskProperties.getEnvironmentVariables()); cfg.put(TaskConfigConstants.CFG_WORKING_SUBDIRECTORY, msBuildTaskProperties.getWorkingSubdirectory()); return cfg; }
@Override public List<ValidationProblem> validate(@NotNull TaskValidationContext taskValidationContext, @NotNull TaskProperties taskProperties) { final List<ValidationProblem> result = new ArrayList<>(); final MsBuildTaskProperties properties = Narrow.downTo(taskProperties, MsBuildTaskProperties.class); if (properties == null) { return result; } final String executableLabel = properties.getExecutable(); if (StringUtils.isEmpty(executableLabel)) { result.add(new ValidationProblem(CONTEXT, "Executable can't be empty")); } else { executableLabelValidator.validateExecutableLabelExists(CONTEXT, executableLabel, MsBuildConfig.MSBUILD_EXECUTABLE_LABEL) .ifPresent(result::add); } return result; } }
@Override public List<ValidationProblem> validate(@NotNull TaskValidationContext taskValidationContext, @NotNull TaskProperties taskProperties) { List<ValidationProblem> result = new ArrayList<>(); final NUnitRunnerTaskProperties properties = Narrow.downTo(taskProperties, NUnitRunnerTaskProperties.class); if (properties != null) { final String capabilityPrefix = getCapabilityShortKey(properties.getNUnitVersion()); final List<String> labels = uiConfigSupport.getExecutableLabels(capabilityPrefix); final String label = properties.getExecutable(); if (labels == null || !labels.contains(label)) { result.add(new ValidationProblem(NUNIT_PARSER_CONTEXT, String.format("Can't find executable by label: '%s'. Available values: %s", label, labels))); } } return result; }
@Override public final List<ValidationProblem> validate(@NotNull TaskValidationContext taskValidationContext, @NotNull TaskProperties taskProperties) { final List<ValidationProblem> validationProblems = new ArrayList<>(); final P typedTaskProperties = Narrow.downTo(taskProperties, propertiesClass); if (typedTaskProperties != null) { final String nodeExecutable = typedTaskProperties.getNodeExecutable(); if (StringUtils.isEmpty(nodeExecutable)) { validationProblems.add(new ValidationProblem(getValidationContext(), "Node.js executable can't be empty")); } else { final List<String> executableLabels = uiConfigSupport.getExecutableLabels(NodeCapabilityDefaultsHelper.NODE_CAPABILITY_KEY); if (executableLabels.stream().noneMatch(label -> label.equals(nodeExecutable))) { final String errorMessage = String.format("Can't find Node.js executable by label: '%s'. Available values: %s", nodeExecutable, executableLabels); validationProblems.add(new ValidationProblem(getValidationContext(), errorMessage)); } } validationProblems.addAll(validate(typedTaskProperties)); } return validationProblems; } }
@Override public Map<String, String> toTaskConfiguration(@NotNull TaskContainer taskContainer, final TaskProperties taskProperties) { final NUnitRunnerTaskProperties properties = Narrow.downTo(taskProperties, NUnitRunnerTaskProperties.class); if (properties != null) { final Map<String, String> cfg = new HashMap<>(); final NUnitRunnerTask.NUnitVersion nUnitVersion = properties.getNUnitVersion(); cfg.put(NUnitRunnerTaskType.CAPABILITY_KEY, getCapabilityKey(properties.getExecutable(), nUnitVersion)); cfg.put(NUnitRunnerTaskType.TEST_FILES, properties.getNUnitTestFiles()); cfg.put(NUnitRunnerTaskType.RESULTS_FILE, properties.getResultFilename()); if (!properties.getTestsToRun().isEmpty()) { cfg.put(NUnitRunnerTaskType.TESTS_TO_RUN, properties.getTestsToRun().stream().collect(joining(","))); } if (!properties.getTestCategoriesToInclude().isEmpty()) { cfg.put(NUnitRunnerTaskType.INCLUDED_TEST_CATEGORIES, properties.getTestCategoriesToInclude().stream().collect(joining(","))); } if (!properties.getTestCategoriesToExclude().isEmpty()) { cfg.put(NUnitRunnerTaskType.EXCLUDED_TEST_CATEGORIES, properties.getTestCategoriesToExclude().stream().collect(joining(","))); } if (StringUtils.isNotBlank(properties.getCommandLineOptions())) { cfg.put(NUnitRunnerTaskType.COMMAND_OPTIONS, properties.getCommandLineOptions()); } if (StringUtils.isNotBlank(properties.getEnvironmentVariables())) { cfg.put(NUnitRunnerTaskType.ENVIRONMENT, properties.getEnvironmentVariables()); } return cfg; } throw new IllegalStateException("Don't know how to import task properties of type: " + taskProperties.getClass().getName()); }