Search in sources :

Example 6 with Project

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

the class TestCampaignFolder method testFromJsonWithProject.

@Test(groups = { "ut" })
public void testFromJsonWithProject() {
    JSONObject json = new JSONObject();
    json.put("_type", "campaign-folder");
    json.put("id", 1);
    json.put("name", "foo");
    json.put("_links", new JSONObject("{\"self\" : {" + "          \"href\" : \"http://localhost:8080/api/rest/latest/campaign-folder/1\"" + "        }}"));
    json.put("project", new JSONObject("{\r\n" + "    \"_type\" : \"project\",\r\n" + "    \"id\" : 10,\r\n" + "    \"name\" : \"Mangrove\",\r\n" + "    \"_links\" : {\r\n" + "      \"self\" : {\r\n" + "        \"href\" : \"http://localhost:8080/api/rest/latest/project/10\"\r\n" + "      }\r\n" + "    }}"));
    CampaignFolder campaignFolder = CampaignFolder.fromJson(json);
    Assert.assertEquals(campaignFolder.getId(), 1);
    Assert.assertEquals(campaignFolder.getName(), "foo");
    Assert.assertEquals(campaignFolder.getUrl(), "http://localhost:8080/api/rest/latest/campaign-folder/1");
    Assert.assertTrue(campaignFolder.getProject() instanceof Project);
    Assert.assertEquals(campaignFolder.getProject().getId(), 10);
}
Also used : Project(com.seleniumtests.connectors.tms.squash.entities.Project) JSONObject(kong.unirest.json.JSONObject) CampaignFolder(com.seleniumtests.connectors.tms.squash.entities.CampaignFolder) Test(org.testng.annotations.Test) ConnectorsTest(com.seleniumtests.ConnectorsTest)

Example 7 with Project

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

the class TestCampaignFolder method init.

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

Example 8 with Project

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

the class TestCampaignFolder method testFromJsonParentIsProject.

@Test(groups = { "ut" })
public void testFromJsonParentIsProject() {
    JSONObject json = new JSONObject();
    json.put("_type", "campaign-folder");
    json.put("id", 1);
    json.put("name", "foo");
    json.put("_links", new JSONObject("{\"self\" : {" + "          \"href\" : \"http://localhost:8080/api/rest/latest/campaign-folder/1\"" + "        }}"));
    json.put("parent", new JSONObject("{\r\n" + "    \"_type\" : \"project\",\r\n" + "    \"id\" : 10,\r\n" + "    \"name\" : \"Mangrove\",\r\n" + "    \"_links\" : {\r\n" + "      \"self\" : {\r\n" + "        \"href\" : \"http://localhost:8080/api/rest/latest/project/10\"\r\n" + "      }\r\n" + "    }}"));
    CampaignFolder campaignFolder = CampaignFolder.fromJson(json);
    Assert.assertEquals(campaignFolder.getId(), 1);
    Assert.assertEquals(campaignFolder.getName(), "foo");
    Assert.assertEquals(campaignFolder.getUrl(), "http://localhost:8080/api/rest/latest/campaign-folder/1");
    Assert.assertTrue(campaignFolder.getParent() instanceof Project);
    Assert.assertEquals(campaignFolder.getParent().getId(), 10);
}
Also used : Project(com.seleniumtests.connectors.tms.squash.entities.Project) JSONObject(kong.unirest.json.JSONObject) CampaignFolder(com.seleniumtests.connectors.tms.squash.entities.CampaignFolder) Test(org.testng.annotations.Test) ConnectorsTest(com.seleniumtests.ConnectorsTest)

Example 9 with Project

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

the class TestProject method testFromJson.

@Test(groups = { "ut" })
public void testFromJson() {
    JSONObject json = new JSONObject();
    json.put("_type", "project");
    json.put("id", 1);
    json.put("name", "foo");
    json.put("_links", new JSONObject("{\"self\" : {" + "          \"href\" : \"http://localhost:8080/api/rest/latest/projects/1\"" + "        }}"));
    Project project = Project.fromJson(json);
    Assert.assertEquals(project.getId(), 1);
    Assert.assertEquals(project.getName(), "foo");
    Assert.assertEquals(project.getUrl(), "http://localhost:8080/api/rest/latest/projects/1");
}
Also used : Project(com.seleniumtests.connectors.tms.squash.entities.Project) JSONObject(kong.unirest.json.JSONObject) Test(org.testng.annotations.Test) ConnectorsTest(com.seleniumtests.ConnectorsTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 10 with Project

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

the class TestProject method testAsJson.

@Test(groups = { "ut" })
public void testAsJson() {
    Project project = new Project("http://localhost:8080/api/rest/latest/projects/1", 1, "project");
    JSONObject json = project.asJson();
    Assert.assertEquals(json.getInt("id"), 1);
    Assert.assertEquals(json.getString("_type"), "project");
}
Also used : Project(com.seleniumtests.connectors.tms.squash.entities.Project) JSONObject(kong.unirest.json.JSONObject) Test(org.testng.annotations.Test) ConnectorsTest(com.seleniumtests.ConnectorsTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

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