Search in sources :

Example 1 with Requirement

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());
}
Also used : Requirement(jetbrains.buildServer.requirements.Requirement) Test(org.testng.annotations.Test) TestFor(jetbrains.buildServer.util.TestFor)

Example 2 with Requirement

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());
}
Also used : Requirement(jetbrains.buildServer.requirements.Requirement) Test(org.testng.annotations.Test)

Example 3 with Requirement

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());
    }
}
Also used : Requirement(jetbrains.buildServer.requirements.Requirement) Test(org.testng.annotations.Test) TestFor(jetbrains.buildServer.util.TestFor)

Example 4 with Requirement

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());
}
Also used : Requirement(jetbrains.buildServer.requirements.Requirement) Test(org.testng.annotations.Test)

Example 5 with Requirement

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());
}
Also used : Requirement(jetbrains.buildServer.requirements.Requirement) BadRequestException(jetbrains.buildServer.server.rest.errors.BadRequestException) BuildTypeImpl(jetbrains.buildServer.serverSide.impl.BuildTypeImpl) Test(org.testng.annotations.Test) BaseFinderTest(jetbrains.buildServer.server.rest.data.BaseFinderTest)

Aggregations

Requirement (jetbrains.buildServer.requirements.Requirement)19 Test (org.testng.annotations.Test)10 ApiOperation (io.swagger.annotations.ApiOperation)6 BuildTypeOrTemplate (jetbrains.buildServer.server.rest.util.BuildTypeOrTemplate)6 BadRequestException (jetbrains.buildServer.server.rest.errors.BadRequestException)5 TestFor (jetbrains.buildServer.util.TestFor)3 BaseFinderTest (jetbrains.buildServer.server.rest.data.BaseFinderTest)2 NotNull (org.jetbrains.annotations.NotNull)2 ServiceLocator (jetbrains.buildServer.ServiceLocator)1 NotFoundException (jetbrains.buildServer.server.rest.errors.NotFoundException)1 OperationException (jetbrains.buildServer.server.rest.errors.OperationException)1 Build (jetbrains.buildServer.server.rest.model.build.Build)1 RequirementFactory (jetbrains.buildServer.serverSide.RequirementFactory)1 BuildTypeImpl (jetbrains.buildServer.serverSide.impl.BuildTypeImpl)1 SUser (jetbrains.buildServer.users.SUser)1