use of com.seleniumtests.connectors.tms.squash.entities.CampaignFolder in project seleniumRobot by bhecquet.
the class TestCampaign method testCreateCampaignWithError.
@Test(groups = { "ut" }, expectedExceptions = ScenarioException.class)
public void testCreateCampaignWithError() {
RequestBodyEntity postRequest = (RequestBodyEntity) createServerMock("POST", "/campaigns", 200, "{}", "requestBodyEntity");
when(postRequest.asJson()).thenThrow(UnirestException.class);
CampaignFolder campaignFolder = new CampaignFolder("http://localhost:8080/api/rest/latest/campaign-folders/7", 7, "folder", project, null);
Campaign.create(project, "myCampaign", campaignFolder);
}
use of com.seleniumtests.connectors.tms.squash.entities.CampaignFolder in project seleniumRobot by bhecquet.
the class TestCampaignFolder method testFromJsonNoParent.
@Test(groups = { "ut" })
public void testFromJsonNoParent() {
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\"" + " }}"));
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.assertNull(campaignFolder.getParent());
Assert.assertNull(campaignFolder.getProject());
}
use of com.seleniumtests.connectors.tms.squash.entities.CampaignFolder in project seleniumRobot by bhecquet.
the class TestCampaignFolder method testAsJson.
@Test(groups = { "ut" })
public void testAsJson() {
CampaignFolder campaignFolder = new CampaignFolder("http://localhost:8080/api/rest/latest/campaign-folders/7", 7, "folder", project, null);
JSONObject json = campaignFolder.asJson();
Assert.assertEquals(json.getInt("id"), 7);
Assert.assertEquals(json.getString("name"), "folder");
Assert.assertEquals(json.getString("_type"), "campaign-folder");
}
use of com.seleniumtests.connectors.tms.squash.entities.CampaignFolder in project seleniumRobot by bhecquet.
the class TestCampaignFolder method testCreateCampaignFolderWithParent.
@Test(groups = { "ut" })
public void testCreateCampaignFolderWithParent() {
HttpRequestWithBody postRequest = (HttpRequestWithBody) createServerMock("POST", "/campaign-folders", 200, "{\r\n" + " \"_type\" : \"campaign-folder\",\r\n" + " \"id\" : 33,\r\n" + " \"name\" : \"Campaign folder 1\",\r\n" + " \"project\" : {\r\n" + " \"_type\" : \"project\",\r\n" + " \"id\" : 14,\r\n" + " \"name\" : \"Test Project 1\",\r\n" + " \"_links\" : {\r\n" + " \"self\" : {\r\n" + " \"href\" : \"http://localhost:8080/api/rest/latest/projects/14\"\r\n" + " }\r\n" + " }\r\n" + " },\r\n" + " \"path\" : \"/Test Project 1/Campaign folder 1\",\r\n" + " \"parent\" : {\r\n" + " \"_type\" : \"campaign-folder\",\r\n" + " \"id\" : 10,\r\n" + " \"name\" : \"Campaign folder parent\",\r\n" + " \"_links\" : {\r\n" + " \"self\" : {\r\n" + " \"href\" : \"http://localhost:8080/api/rest/latest/campaign-folders/10\"\r\n" + " }\r\n" + " }\r\n" + " },\r\n" + " \"created_by\" : \"admin\",\r\n" + " \"created_on\" : \"2017-06-15T10:00:00.000+0000\",\r\n" + " \"last_modified_by\" : \"admin\",\r\n" + " \"last_modified_on\" : \"2017-06-15T10:00:00.000+0000\",\r\n" + " \"description\" : null,\r\n" + " \"custom_fields\" : [ {\r\n" + " \"code\" : \"cuf1\",\r\n" + " \"label\" : \"Lib Cuf1\",\r\n" + " \"value\" : \"Cuf1 Value\"\r\n" + " }, {\r\n" + " \"code\" : \"cuf2\",\r\n" + " \"label\" : \"Lib Cuf2\",\r\n" + " \"value\" : \"true\"\r\n" + " } ],\r\n" + " \"attachments\" : [ ],\r\n" + " \"_links\" : {\r\n" + " \"self\" : {\r\n" + " \"href\" : \"http://localhost:8080/api/rest/latest/campaign-folders/33\"\r\n" + " },\r\n" + " \"project\" : {\r\n" + " \"href\" : \"http://localhost:8080/api/rest/latest/projects/14\"\r\n" + " },\r\n" + " \"content\" : {\r\n" + " \"href\" : \"http://localhost:8080/api/rest/latest/campaign-folders/33/content\"\r\n" + " },\r\n" + " \"attachments\" : {\r\n" + " \"href\" : \"http://localhost:8080/api/rest/latest/campaign-folders/33/attachments\"\r\n" + " }\r\n" + " }\r\n" + "}", "request");
CampaignFolder campaignFolderParent = new CampaignFolder("http://localhost:8080/api/rest/latest/campaign-folders/10", 10, "Campaign folder parent", project, null);
CampaignFolder campaignFolder = CampaignFolder.create(project, campaignFolderParent, "Campaign folder 1");
verify(postRequest).body(new JSONObject("{\"_type\":\"campaign-folder\",\"name\":\"Campaign folder 1\",\"parent\":{\"_type\":\"campaign-folder\",\"id\":10,\"name\":\"Campaign folder parent\"}}"));
Assert.assertEquals(campaignFolder.getId(), 33);
Assert.assertEquals(campaignFolder.getName(), "Campaign folder 1");
Assert.assertEquals(campaignFolder.getParent().getId(), 10);
}
use of com.seleniumtests.connectors.tms.squash.entities.CampaignFolder in project seleniumRobot by bhecquet.
the class TestCampaignFolder method testCreateCampaignFolderNoParent.
@Test(groups = { "ut" })
public void testCreateCampaignFolderNoParent() {
HttpRequestWithBody postRequest = (HttpRequestWithBody) createServerMock("POST", "/campaign-folders", 200, "{\r\n" + " \"_type\" : \"campaign-folder\",\r\n" + " \"id\" : 33,\r\n" + " \"name\" : \"Campaign folder 1\",\r\n" + " \"project\" : {\r\n" + " \"_type\" : \"project\",\r\n" + " \"id\" : 14,\r\n" + " \"name\" : \"Test Project 1\",\r\n" + " \"_links\" : {\r\n" + " \"self\" : {\r\n" + " \"href\" : \"http://localhost:8080/api/rest/latest/projects/14\"\r\n" + " }\r\n" + " }\r\n" + " },\r\n" + " \"path\" : \"/Test Project 1/Campaign folder 1\",\r\n" + " \"parent\" : {\r\n" + " \"_type\" : \"project\",\r\n" + " \"id\" : 14,\r\n" + " \"name\" : \"Test Project 1\",\r\n" + " \"_links\" : {\r\n" + " \"self\" : {\r\n" + " \"href\" : \"http://localhost:8080/api/rest/latest/projects/14\"\r\n" + " }\r\n" + " }\r\n" + " },\r\n" + " \"created_by\" : \"admin\",\r\n" + " \"created_on\" : \"2017-06-15T10:00:00.000+0000\",\r\n" + " \"last_modified_by\" : \"admin\",\r\n" + " \"last_modified_on\" : \"2017-06-15T10:00:00.000+0000\",\r\n" + " \"description\" : null,\r\n" + " \"custom_fields\" : [ {\r\n" + " \"code\" : \"cuf1\",\r\n" + " \"label\" : \"Lib Cuf1\",\r\n" + " \"value\" : \"Cuf1 Value\"\r\n" + " }, {\r\n" + " \"code\" : \"cuf2\",\r\n" + " \"label\" : \"Lib Cuf2\",\r\n" + " \"value\" : \"true\"\r\n" + " } ],\r\n" + " \"attachments\" : [ ],\r\n" + " \"_links\" : {\r\n" + " \"self\" : {\r\n" + " \"href\" : \"http://localhost:8080/api/rest/latest/campaign-folders/33\"\r\n" + " },\r\n" + " \"project\" : {\r\n" + " \"href\" : \"http://localhost:8080/api/rest/latest/projects/14\"\r\n" + " },\r\n" + " \"content\" : {\r\n" + " \"href\" : \"http://localhost:8080/api/rest/latest/campaign-folders/33/content\"\r\n" + " },\r\n" + " \"attachments\" : {\r\n" + " \"href\" : \"http://localhost:8080/api/rest/latest/campaign-folders/33/attachments\"\r\n" + " }\r\n" + " }\r\n" + "}", "request");
CampaignFolder campaignFolder = CampaignFolder.create(project, null, "Campaign folder 1");
verify(postRequest).body(new JSONObject(" {\"_type\":\"campaign-folder\",\"name\":\"Campaign folder 1\",\"parent\":{\"_type\":\"project\",\"id\":14,\"name\":\"Test Project 1\"}}"));
Assert.assertEquals(campaignFolder.getId(), 33);
Assert.assertEquals(campaignFolder.getName(), "Campaign folder 1");
Assert.assertEquals(campaignFolder.getParent().getId(), 14);
}
Aggregations