use of jetbrains.buildServer.requirements.Requirement in project teamcity-powershell by JetBrains.
the class PowerShellRunTypeTest method testGenerateAnyBitnessRequirement_NoMinVersion.
@Test
@TestFor(issues = "TW-44808")
public void testGenerateAnyBitnessRequirement_NoMinVersion() {
final Map<String, String> input = createDummyParameters(null);
final Collection<Requirement> requirements = runType.getRunnerSpecificRequirements(input);
assertEquals(1, requirements.size());
final Requirement r = requirements.iterator().next();
assertEquals("Exists=>(powershell_Core_x86|powershell_Core_x64|powershell_Desktop_x86|powershell_Desktop_x64)", r.getPropertyName());
assertNull(r.getPropertyValue());
assertEquals(RequirementType.EXISTS, r.getType());
}
use of jetbrains.buildServer.requirements.Requirement in project teamcity-powershell by JetBrains.
the class PowerShellRunTypeTest method testAnyEditionSpecificBitness.
@Test(dataProvider = "bitnessProvider")
public void testAnyEditionSpecificBitness(@NotNull final PowerShellBitness bitness) {
final Map<String, String> input = createDummyParameters(bitness);
final Collection<Requirement> requirements = runType.getRunnerSpecificRequirements(input);
assertEquals(1, requirements.size());
final Requirement r = requirements.iterator().next();
assertEquals("Exists=>(powershell_Core_" + bitness.getValue() + "|powershell_Desktop_" + bitness.getValue() + ")", r.getPropertyName());
assertEquals(RequirementType.EXISTS, r.getType());
}
use of jetbrains.buildServer.requirements.Requirement in project teamcity-powershell by JetBrains.
the class PowerShellRunTypeTest method testGenerateAnyBitnessRequirement_WithMinVersion.
@Test(dataProvider = "versionProvider")
@TestFor(issues = "TW-44808")
public void testGenerateAnyBitnessRequirement_WithMinVersion(@Nullable final String version) {
final Map<String, String> input = createDummyParameters(null);
if (version != null) {
input.put(PowerShellConstants.RUNNER_MIN_VERSION, version);
}
final Collection<Requirement> requirements = runType.getRunnerSpecificRequirements(input);
assertEquals(1, requirements.size());
final Requirement r = requirements.iterator().next();
assertEquals("Exists=>(powershell_Core_x86|powershell_Core_x64|powershell_Desktop_x86|powershell_Desktop_x64)", r.getPropertyName());
assertEquals(version, r.getPropertyValue());
if (version != null) {
assertEquals(RequirementType.VER_NO_LESS_THAN, r.getType());
}
}
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-rest by JetBrains.
the class BuildTypeRequestTest method testUpdatingAgentRequirements.
@Test
public void testUpdatingAgentRequirements() {
BuildTypeImpl buildType1 = registerBuildType("buildType1", "projectName");
buildType1.addRequirement(new Requirement("prop1", null, RequirementType.EXISTS));
String disabledId = "id2";
buildType1.addRequirement(new Requirement(disabledId, "prop2", null, RequirementType.EXISTS));
buildType1.setEnabled(disabledId, false);
buildType1.addRequirement(new Requirement("prop3", null, RequirementType.EXISTS));
final String btLocator = "id:" + buildType1.getExternalId();
assertEquals(3, myBuildTypeRequest.getAgentRequirements(btLocator, "$long,agent-requirement($long)").propEntities.size());
{
PropEntityAgentRequirement submitted = new PropEntityAgentRequirement();
submitted.type = "not-exists";
submitted.disabled = true;
submitted.properties = new Properties();
submitted.properties.properties = Arrays.asList(new Property(new SimpleParameter("property-name", "aaa"), false, Fields.LONG, myFixture));
String newId = myBuildTypeRequest.addAgentRequirement(btLocator, "$long", submitted).id;
assertEquals(4, myBuildTypeRequest.getAgentRequirements(btLocator, "$long,agent-requirement($long)").propEntities.size());
assertTrue(myBuildTypeRequest.getAgentRequirements(btLocator, "$long,agent-requirement($long)").propEntities.get(3).disabled);
myBuildTypeRequest.deleteAgentRequirement(btLocator, newId);
assertEquals(3, myBuildTypeRequest.getAgentRequirements(btLocator, "$long,agent-requirement($long)").propEntities.size());
}
{
PropEntitiesAgentRequirement submitted = new PropEntitiesAgentRequirement();
PropEntityAgentRequirement submitted1 = new PropEntityAgentRequirement();
submitted1.type = "agentRequirementType1";
PropEntityAgentRequirement submitted2 = new PropEntityAgentRequirement();
submitted2.type = "agentRequirementType1";
submitted.propEntities = Arrays.asList(submitted1, submitted2);
checkException(BadRequestException.class, new Runnable() {
public void run() {
myBuildTypeRequest.replaceAgentRequirements(btLocator, "$long", // error will be reported: BadRequestException: No name is specified. Make sure 'property-name' property is present and has not empty value
submitted);
}
}, null);
assertEquals(3, myBuildTypeRequest.getAgentRequirements(btLocator, "$long,agent-requirement($long)").propEntities.size());
assertEquals(3, buildType1.getRequirements().size());
assertFalse(buildType1.isEnabled(disabledId));
}
{
PropEntityAgentRequirement submitted = new PropEntityAgentRequirement();
submitted.type = "agentRequirementType1";
checkException(BadRequestException.class, new Runnable() {
public void run() {
myBuildTypeRequest.addAgentRequirement(btLocator, "$long", submitted);
}
}, null);
assertEquals(3, myBuildTypeRequest.getAgentRequirements(btLocator, "$long,agent-requirement($long)").propEntities.size());
assertEquals(3, buildType1.getRequirements().size());
assertFalse(buildType1.isEnabled(disabledId));
}
myBuildTypeRequest.replaceAgentRequirements(btLocator, "$long", new PropEntitiesAgentRequirement());
assertEquals(0, buildType1.getRequirements().size());
}
Aggregations