use of com.seleniumtests.connectors.tms.squash.entities.Campaign in project seleniumRobot by bhecquet.
the class TestCampaign method testGetAllIterationsWithError.
@Test(groups = { "ut" }, expectedExceptions = ScenarioException.class)
public void testGetAllIterationsWithError() {
GetRequest getRequest = (GetRequest) createServerMock("GET", "/campaign/7/iterations", 200, "{}", "requestBodyEntity");
when(getRequest.asPaged(any(), (Function<HttpResponse<JsonNode>, String>) any(Function.class))).thenThrow(UnirestException.class);
Campaign campaign = new Campaign("http://localhost:4321/campaign/7", 7, "campaign");
List<Iteration> iterations = campaign.getIterations();
}
use of com.seleniumtests.connectors.tms.squash.entities.Campaign in project seleniumRobot by bhecquet.
the class TestCampaign method testFromJson.
@Test(groups = { "ut" })
public void testFromJson() {
JSONObject json = new JSONObject();
json.put("_type", "campaign");
json.put("id", 1);
json.put("name", "foo");
json.put("_links", new JSONObject("{\"self\" : {" + " \"href\" : \"http://localhost:8080/api/rest/latest/campaigns/41\"" + " }}"));
Campaign campaign = Campaign.fromJson(json);
Assert.assertEquals(campaign.getId(), 1);
Assert.assertEquals(campaign.getName(), "foo");
Assert.assertEquals(campaign.getUrl(), "http://localhost:8080/api/rest/latest/campaigns/41");
}
use of com.seleniumtests.connectors.tms.squash.entities.Campaign in project seleniumRobot by bhecquet.
the class TestIteration method testCreateIterationWithError.
@Test(groups = { "ut" }, expectedExceptions = ScenarioException.class)
public void testCreateIterationWithError() {
RequestBodyEntity postRequest = (RequestBodyEntity) createServerMock("POST", "/campaigns/2/iterations", 200, "{}", "requestBodyEntity");
when(postRequest.asJson()).thenThrow(UnirestException.class);
Campaign campaign = new Campaign("http://localhost:8080/api/rest/latest/campaigns/2", 2, "campaign");
Iteration.create(campaign, "new iteration");
}
use of com.seleniumtests.connectors.tms.squash.entities.Campaign 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);
}
use of com.seleniumtests.connectors.tms.squash.entities.Campaign in project seleniumRobot by bhecquet.
the class TestSquashTMApi method testCreateCampaignWithExistingFolder.
@Test(groups = { "ut" })
public void testCreateCampaignWithExistingFolder() {
PowerMockito.when(Project.getAll()).thenReturn(Arrays.asList(project1, project2));
doReturn(Arrays.asList(campaign1, campaign2)).when(project1).getCampaigns();
PowerMockito.when(CampaignFolder.getAll()).thenReturn(Arrays.asList(campaignFolder1, campaignFolder2));
Campaign myCampaign = new Campaign("http://localhost:4321/campaigns/3", 3, "mycampaign");
PowerMockito.when(Campaign.create(project1, "mycampaign", campaignFolder2)).thenReturn(myCampaign);
SquashTMApi api = new SquashTMApi("http://localhost:4321", "user", "password", "project1");
Campaign newCampaign = api.createCampaign("mycampaign", "campaignFolder1/campaignFolder2");
Assert.assertEquals(newCampaign, myCampaign);
// check campaign creation has been called
PowerMockito.verifyStatic(Campaign.class);
Campaign.create(project1, "mycampaign", campaignFolder2);
// check the 2 folders has not been created
PowerMockito.verifyStatic(CampaignFolder.class, never());
CampaignFolder.create(eq(project1), any(), eq("campaignFolder1"));
PowerMockito.verifyStatic(CampaignFolder.class, never());
CampaignFolder.create(eq(project1), any(), eq("campaignFolder2"));
}
Aggregations