Search in sources :

Example 1 with Project

use of com.seleniumtests.connectors.tms.squash.entities.Project in project seleniumRobot by bhecquet.

the class TestCampaign method init.

@BeforeMethod(groups = { "ut" })
public void init() {
    project = new Project("http://localhost:8080/api/rest/latest/projects/1", 1, "project");
    Campaign.configureEntity("user", "pwd", SERVER_URL + "/");
}
Also used : Project(com.seleniumtests.connectors.tms.squash.entities.Project) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 2 with Project

use of com.seleniumtests.connectors.tms.squash.entities.Project in project seleniumRobot by bhecquet.

the class TestIteration method init.

@BeforeMethod(groups = { "ut" })
public void init() {
    project = new Project("http://localhost:8080/api/rest/latest/projects/1", 1, "project");
    Campaign.configureEntity("user", "pwd", SERVER_URL + "/");
}
Also used : Project(com.seleniumtests.connectors.tms.squash.entities.Project) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 3 with Project

use of com.seleniumtests.connectors.tms.squash.entities.Project in project seleniumRobot by bhecquet.

the class TestIterationTestPlanItem method init.

@BeforeMethod(groups = { "ut" })
public void init() {
    project = new Project("http://localhost:8080/api/rest/latest/projects/1", 1, "project");
    Campaign.configureEntity("user", "pwd", SERVER_URL + "/");
}
Also used : Project(com.seleniumtests.connectors.tms.squash.entities.Project) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 4 with Project

use of com.seleniumtests.connectors.tms.squash.entities.Project in project seleniumRobot by bhecquet.

the class TestProject method testGetCampaignsInProject.

@Test(groups = { "ut" })
public void testGetCampaignsInProject() {
    GetRequest getRequest = (GetRequest) createServerMock("GET", "/projects/44/campaigns", 200, "{" + "  \"_embedded\" : {" + "    \"campaigns\" : [ {" + "      \"_type\" : \"campaign\"," + "      \"id\" : 255," + "      \"name\" : \"campaign 1\"," + "      \"reference\" : \"C-1\"," + "      \"_links\" : {" + "        \"self\" : {" + "          \"href\" : \"http://localhost:8080/api/rest/latest/campaigns/255\"" + "        }" + "      }" + "    }, {" + "      \"_type\" : \"campaign\"," + "      \"id\" : 122," + "      \"name\" : \"campaign 2\"," + "      \"reference\" : \"C-2\"," + "      \"_links\" : {" + "        \"self\" : {" + "          \"href\" : \"http://localhost:8080/api/rest/latest/campaigns/122\"" + "        }" + "      }" + "    }, {" + "      \"_type\" : \"campaign\"," + "      \"id\" : 147," + "      \"name\" : \"campaign 3\"," + "      \"reference\" : \"C-3\"," + "      \"_links\" : {" + "        \"self\" : {" + "          \"href\" : \"http://localhost:8080/api/rest/latest/campaigns/147\"" + "        }" + "      }" + "    } ]" + "  }," + "  \"_links\" : {" + "    \"first\" : {" + "      \"href\" : \"http://localhost:8080/api/rest/latest/projects/14/campaigns?page=0&size=3&sort=name,desc\"" + "    }," + "    \"prev\" : {" + "      \"href\" : \"http://localhost:8080/api/rest/latest/projects/14/campaigns?page=1&size=3&sort=name,desc\"" + "    }," + "    \"self\" : {" + "      \"href\" : \"http://localhost:8080/api/rest/latest/projects/14/campaigns?page=2&size=3&sort=name,desc\"" + "    }," + "    \"next\" : {" + "      \"href\" : \"http://localhost:8080/api/rest/latest/projects/14/campaigns?page=3&size=3&sort=name,desc\"" + "    }," + "    \"last\" : {" + "      \"href\" : \"http://localhost:8080/api/rest/latest/projects/14/campaigns?page=3&size=3&sort=name,desc\"" + "    }" + "  }," + "  \"page\" : {" + "    \"size\" : 3," + "    \"totalElements\" : 10," + "    \"totalPages\" : 4," + "    \"number\" : 2" + "  }" + "}", "request");
    Project project = new Project("http://localhost:4321/projects/44", 44, "project");
    List<Campaign> campaigns = project.getCampaigns();
    Assert.assertEquals(campaigns.size(), 3);
    Assert.assertEquals(campaigns.get(0).getName(), "campaign 1");
    Assert.assertEquals(campaigns.get(0).getId(), 255);
}
Also used : Project(com.seleniumtests.connectors.tms.squash.entities.Project) Campaign(com.seleniumtests.connectors.tms.squash.entities.Campaign) GetRequest(kong.unirest.GetRequest) Test(org.testng.annotations.Test) ConnectorsTest(com.seleniumtests.ConnectorsTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 5 with Project

use of com.seleniumtests.connectors.tms.squash.entities.Project in project seleniumRobot by bhecquet.

the class SquashTMApi method createCampaign.

/**
 * Creates a campaign if it does not exist
 * @param project		project in which this campaign will be created
 * @param campaignName	name of the campaign to create
 * @param folder		folder to which campaign will be created
 */
public Campaign createCampaign(String campaignName, String folder) {
    if (folder == null) {
        folder = "";
    }
    List<CampaignFolder> campaignFolders = CampaignFolder.getAll();
    // create folder where campaign will be located
    CampaignFolder parentFolder = null;
    for (String folderName : folder.split("/")) {
        if (folderName.isEmpty()) {
            continue;
        }
        boolean folderExists = false;
        for (CampaignFolder existingFolder : campaignFolders) {
            if (existingFolder.getName().equals(folderName) && (existingFolder.getProject() == null || existingFolder.getProject() != null && existingFolder.getProject().getId() == currentProject.getId()) && (existingFolder.getParent() == null || parentFolder == null && existingFolder.getParent() != null && existingFolder.getParent() instanceof Project || (parentFolder != null && existingFolder.getParent() != null && existingFolder.getParent() instanceof CampaignFolder && existingFolder.getParent().getId() == parentFolder.getId()))) {
                folderExists = true;
                parentFolder = existingFolder;
                break;
            }
        }
        if (!folderExists) {
            parentFolder = CampaignFolder.create(currentProject, parentFolder, folderName);
        }
    }
    // do not create campaign if it exists
    for (Campaign campaign : currentProject.getCampaigns()) {
        if (campaign.getName().equals(campaignName)) {
            return campaign;
        }
    }
    return Campaign.create(currentProject, campaignName, parentFolder);
}
Also used : Project(com.seleniumtests.connectors.tms.squash.entities.Project) Campaign(com.seleniumtests.connectors.tms.squash.entities.Campaign) CampaignFolder(com.seleniumtests.connectors.tms.squash.entities.CampaignFolder)

Aggregations

Project (com.seleniumtests.connectors.tms.squash.entities.Project)11 ConnectorsTest (com.seleniumtests.ConnectorsTest)6 Test (org.testng.annotations.Test)6 JSONObject (kong.unirest.json.JSONObject)4 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)4 BeforeMethod (org.testng.annotations.BeforeMethod)4 Campaign (com.seleniumtests.connectors.tms.squash.entities.Campaign)3 CampaignFolder (com.seleniumtests.connectors.tms.squash.entities.CampaignFolder)3 GetRequest (kong.unirest.GetRequest)2 HttpResponse (kong.unirest.HttpResponse)1