use of jetbrains.buildServer.requirements.Requirement in project teamcity-powershell by JetBrains.
the class PowerShellRunTypeTest method shouldUseInternalValueAsPArtOfRequirement.
@Test(dataProvider = "bitnessProvider")
public void shouldUseInternalValueAsPArtOfRequirement(@NotNull final PowerShellBitness bit) {
final Collection<Requirement> requirements = runType.getRunnerSpecificRequirements(createDummyParameters(bit));
assertEquals(1, requirements.size());
final Requirement req = requirements.iterator().next();
assertEquals("Exists=>(powershell_Core_" + bit.getValue() + "|powershell_Desktop_" + bit.getValue() + ")", req.getPropertyName());
}
use of jetbrains.buildServer.requirements.Requirement in project teamcity-powershell by JetBrains.
the class PowerShellRunTypeTest method shouldProviderSemanticVersionRestriction.
@Test(dataProvider = "bitnessAndVersionProvider")
@TestFor(issues = "TW-33570")
public void shouldProviderSemanticVersionRestriction(@NotNull final PowerShellBitness bitness, @Nullable final String version) {
final Map<String, String> parameters = createDummyParameters(bitness);
if (version != null) {
parameters.put(PowerShellConstants.RUNNER_MIN_VERSION, version);
}
final Collection<Requirement> requirements = runType.getRunnerSpecificRequirements(parameters);
assertEquals(1, requirements.size());
final Requirement req = requirements.iterator().next();
assertEquals("Exists=>(powershell_Core_" + bitness.getValue() + "|powershell_Desktop_" + bitness.getValue() + ")", req.getPropertyName());
if (version == null) {
assertEquals(RequirementType.EXISTS, req.getType());
} else {
assertEquals(RequirementType.VER_NO_LESS_THAN, req.getType());
assertEquals(version, req.getPropertyValue());
}
}
use of jetbrains.buildServer.requirements.Requirement in project teamcity-powershell by JetBrains.
the class PowerShellRunTypeTest method testSingleMatchingRequirement.
/**
* Tests we provide single property requirement without {@code Exists} qualifier in case of fixed bitness and edition
*/
@Test(dataProvider = "versionProvider")
public void testSingleMatchingRequirement(@Nullable final String version) {
for (PowerShellBitness bitness : PowerShellBitness.values()) {
for (PowerShellEdition edition : PowerShellEdition.values()) {
final Map<String, String> parameters = createDummyParameters(bitness);
if (version != null) {
parameters.put(PowerShellConstants.RUNNER_MIN_VERSION, version);
}
parameters.put(PowerShellConstants.RUNNER_EDITION, edition.getValue());
final Collection<Requirement> requirements = runType.getRunnerSpecificRequirements(parameters);
assertEquals(1, requirements.size());
final Requirement req = requirements.iterator().next();
assertEquals("powershell_" + edition.getValue() + "_" + bitness.getValue(), req.getPropertyName());
if (version == null) {
assertEquals(RequirementType.EXISTS, req.getType());
} else {
assertEquals(RequirementType.VER_NO_LESS_THAN, req.getType());
assertEquals(version, req.getPropertyValue());
}
}
}
}
use of jetbrains.buildServer.requirements.Requirement in project teamcity-powershell by JetBrains.
the class PowerShellRunTypeTest method testAnyBitnessSpecificEdition.
@Test(dataProvider = "editionProvider")
public void testAnyBitnessSpecificEdition(@NotNull final PowerShellEdition edition) {
final Map<String, String> input = createDummyParameters(null);
input.put(PowerShellConstants.RUNNER_EDITION, edition.getValue());
final Collection<Requirement> requirements = runType.getRunnerSpecificRequirements(input);
assertEquals(1, requirements.size());
final Requirement r = requirements.iterator().next();
assertEquals("Exists=>(powershell_" + edition.getValue() + "_x86|powershell_" + edition.getValue() + "_x64)", r.getPropertyName());
assertEquals(RequirementType.EXISTS, r.getType());
}
use of jetbrains.buildServer.requirements.Requirement in project teamcity-powershell by JetBrains.
the class PowerShellRunType method getRunnerSpecificRequirements.
@NotNull
@Override
public List<Requirement> getRunnerSpecificRequirements(@NotNull final Map<String, String> runParameters) {
final List<Requirement> result = new ArrayList<>();
final String minVersion = getMinimalVersion(runParameters);
final PowerShellBitness bit = getBitness(runParameters);
final PowerShellEdition edition = getEdition(runParameters);
// filter editions
final List<PowerShellEdition> editions = new ArrayList<>();
if (edition == null) {
// for all editions
editions.addAll(Arrays.asList(PowerShellEdition.values()));
} else {
editions.add(edition);
}
final List<PowerShellBitness> bits = new ArrayList<>();
if (bit == null) {
bits.addAll(Arrays.asList(PowerShellBitness.values()));
} else {
bits.add(bit);
}
List<String> keys = new ArrayList<>();
for (PowerShellEdition e : editions) {
for (PowerShellBitness b : bits) {
keys.add(generateGeneralKey(e, b));
}
}
if (minVersion == null) {
// EXISTS requirement type, as we have no specific version set
result.add(new Requirement(getRequirementPropertyName(keys), null, RequirementType.EXISTS));
} else {
// VER_NO_LESS_THAN requirement type, as minimal version is set
result.add(new Requirement(getRequirementPropertyName(keys), minVersion, RequirementType.VER_NO_LESS_THAN));
}
return result;
}
Aggregations